swagger-api / swagger-api/swagger-ui
Unable to resolve references in schema
Open
Nobody has claimed this yet.
P3
specification: 3.1
type: bug
- 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: macOS
- Browser: chrome, safari
- Version: 133, 18.3
- Method of installation: npm
- Swagger-UI version: 5.20.0
- Swagger/OpenAPI version: OpenAPI 3.1
Content & configuration
Example Swagger/OpenAPI definition:
openapi: 3.1.0
info:
title: Cat/ Dog Pet Store API
description: An example API for a pet store
version: 1.0.0
paths:
/pets:
get:
summary: List all pets
operationId: listPets
responses:
'200':
description: A list of pets.
content:
application/json:
schema:
$ref: '#/components/schemas/PetList'
components:
schemas:
PetList:
type: array
items:
$ref: '#/components/schemas/Pet'
Pet:
type: object
required:
- petType
properties:
petType:
type: string
discriminator:
propertyName: petType
mapping:
dog: '#/components/schemas/Dog'
cat: '#/components/schemas/Cat'
x-custom-extension: This is a custom extension for the discriminator
Dog:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
properties:
breed:
type: string
barkVolume:
type: integer
description: Volume of the bark
Cat:
allOf:
- $ref: '#/components/schemas/Pet'
- type: object
properties:
color:
type: string
purrLoudness:
type: integer
description: Loudness of the purr
Swagger-UI configuration options:
SwaggerUI({
spec: apiSpec,
dom_id: '#api-ui-container',
defaultModelRendering: 'model',
showExtensions: true,
deepLinking: true,
plugins: [DisableTryItOutPlugin],
onComplete(): void {
setTimeout(() => that.swaggerUiOnComplete(that), 1000);
},
})
Describe the bug you're encountering
- On clicking 'Expand All' button, nothing happens.
- The refs are not correctly resolved
Expected behavior
The refs should be resolved properly
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
Start by reproducing the issue in Swagger UI 5.20.0 with the supplied OpenAPI 3.1 definition and SwaggerUI configuration. Trace the schema reference and discriminator rendering behavior, then verify that Expand All works and the PetList, Pet, Dog, and Cat references resolve correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100