Skip to content

kin-openapi bug found: circular schema reference not handled error is thrown randomly #764

Closed
@mthaak

Description

@mthaak

Sometimes I can use oapi-codegen to generate Go types and sometimes it fails:

> oapi-codegen -config oapi-config.yml spec.yaml
: kin-openapi bug found: circular schema reference not handled - #/components/schemas/QueryComponent -> #/components/schemas/AndQuery -> #/components/schemas/AndQueryGroup -> #/components/schemas/QueryComponent -> #/components/schemas/AndQuery -> #/components/schemas/AndQueryGroup -> #/components/schemas/QueryComponent -> #/components/schemas/OrQuery -> #/components/schemas/OrQueryGroup -> #/components/schemas/QueryComponent error loading swagger spec in spec.yaml

This flakiness is especially confusing. I get around it by just re-running but it's strange.

This is spec.yaml:

openapi: 3.0.3
info:
  title: API
  version: 1.0.0
paths: { }
components:
  schemas:
    QueryComponent:
      oneOf:
        - $ref: '#/components/schemas/AndQuery'
        - $ref: '#/components/schemas/OrQuery'

    OrQuery:
      required:
        - dis_max
      properties:
        dis_max:
          $ref: '#/components/schemas/OrQueryGroup'

    OrQueryGroup:
      description: A query that returns the OR of the child queries
      required:
        - queries
      properties:
        queries:
          type: array
          items:
            $ref: '#/components/schemas/QueryComponent'

    AndQuery:
      required:
        - bool
      properties:
        bool:
          $ref: '#/components/schemas/AndQueryGroup'

    AndQueryGroup:
      description: A query that returns the AND of the child queries
      properties:
        filter:
          type: array
          items:
            $ref: '#/components/schemas/QueryComponent'
        must_not:
          type: array
          items:
            $ref: '#/components/schemas/QueryComponent'

    Request:
      properties:
        query:
          $ref: '#/components/schemas/QueryComponent'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions