k1LoW/runn

OpenAPI validation fails on circular references

takanohi opened this issue · 2 comments

Hi, maintainers.
There is a valid usecase using circular references in arrays in openapi schema but I'm getting this error.
Error: failed to add runners (hello.yaml): runner req error: infinite circular reference detected: Row: Response -> Row -> Row [33:11]

libopenapi has a parameter to ignore them, which is IgnoreArrayCircularReferences.
https://pb33f.io/libopenapi/circular-references/

But runn is not able to being accessed to this option.
https://github.com/k1LoW/runn/blob/main/runner_option.go#L13-L16

I would like to make this behavior configurable so love to hear what you think of this.

Sample files

runners:
  req:
    endpoint: https://example.com
    openapi3: ./openapi.yaml
steps:
  TestHello:
    req:
      /api/hello:
        get:
    test: |
      current.res.status == 200
openapi: 3.1.0
info:
  title: For debugging
  version: 1.0.0
paths:
  /api/hello:
    get:
      responses:
        "200":
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Response"
          description: Debugging
components:
  schemas:
    Response:
      type: object
      properties:
        rows:
          type: array
          items:
            $ref: "#/components/schemas/Row"
      required:
        - rows
    Row:
      type: object
      properties:
        name:
          description: Name of the row
          type: string
        rows:
          description: A collection of row
          type: array
          items:
            $ref: "#/components/schemas/Row"
      required:
        - name
        - rows

@takanohi Thank you for your request.

Even with the circular reference check disabled, libopenapi (libopenapi-validator) could not validate this response.

I don't know if this will have the results you are hoping for, but I would like to take action because it is effective in some use cases.

@k1LoW Thank you for quick updates! I confirmed it was fixed too.