swagger-api / swagger-api/swagger-ui
Circular reference in schema leads to Could not resolve reference: undefined undefined
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
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:
- Scroll down to 'schemas'
- Click on 'Person' to expand it
- Scroll up to the top of the page
- See error
Expected behavior
No error should occur.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file or test is named. Start by loading the provided OpenAPI 3.0 definition in Swagger UI and expanding the Person schema, then trace the schema resolver entry point used for recursive $ref values. Done means circular parent and brother references render without the “Could not resolve reference” error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100