Swagger-ui: Circular reference in schema leads to Could not resolve reference: undefined undefined

Created on 24 Nov 2019  路  4Comments  路  Source: swagger-api/swagger-ui

Q&A (please complete the following information)

  • OS: Alpine Linux
  • Browser: Vivaldi
  • Version: 2.9
  • Method of installation: docker
  • Swagger-UI version: actually unknown, should be latest
  • Swagger/OpenAPI version: OpenAPI 3.0

Content & configuration

Example Swagger/OpenAPI definition:

openapi: "3.0.0"
info:
  title: "Test API For Self Reference"
  version: "1.0"


paths:
  /greeting:
    get:
      tags:
        - Client
      description: 'Get the current client session identifier.'
      responses:
        200: 
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Person'

components:
  schemas:
    Person:
      type: object
      required:
        - name
        - age
      properties:
        name:
         type: string
         example: 'John Doe'
        age:
          type: integer
          example: 42
        parent:
          $ref: '#/components/schemas/Person'
        brother:
          $ref: '#/components/schemas/Person'

Swagger-UI configuration options:
Where do I find it?

Describe the bug you're encountering

When expanding the Person schema, Swagger-UI displays this error on top of the page:
Resolver error at components.schemas.Person.properties.parent.$ref
Could not resolve reference: undefined undefined

To reproduce...

Steps to reproduce the behavior:

  1. Scroll down to 'schemas'
  2. Click on 'Person' to expand it
  3. Scroll up to the top of the page
  4. See error

Expected behavior

No error should occur.

Most helpful comment

I have met the same issue for using 3.25.2.
I have a quick check and figure out the issue happened from 3.22.3
Have check on editor.swagger.io

it's empty instead of throwing a warning on the top of the page.

image

All 4 comments

Hmm, I kind of fixed it by entering the absolute path (instead of relative one) to the yaml file in the Explore text field. I'm not sure whether this is the way it is meant to be...

Are you sure you're using the latest version? Can't seem to reproduce it on editor.swagger.io.

I have met the same issue for using 3.25.2.
I have a quick check and figure out the issue happened from 3.22.3
Have check on editor.swagger.io

it's empty instead of throwing a warning on the top of the page.

image

The issue is still there (5 months later).
Any fix foreseen ?

Was this page helpful?
0 / 5 - 0 ratings