swagger-api / swagger-api/swagger-ui
Unexpected defaultModelExpandDepth behavior
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: macOS
- Browser: Chrome
- Version: 100.0.4896.127
- Method of installation: yarn swagger-ui-react
- Swagger-UI version: 4.10.3
- Swagger/OpenAPI version: OpenAPI 2.0.0
Content & configuration
Example Swagger/OpenAPI definition:
This request body is referenced by a POST request in the request body.
AppCreate:
additionalProperties: false
properties:
name:
type: string
example: My First App
minLength: 3
maxLength: 255
description:
type: string
example: This is my first App!
maxLength: 8192
required:
- name
Swagger-UI configuration options:
<SwaggerUI
url='url'
docExpansion={'none'}
deepLinking={true}
// @ts-expect-error: TS2769 Expected @types issue
defaultModelRendering="model"
defaultModelsExpandDepth={-1}
defaultModelExpandDepth={3} // Issues arise when this is larger than 3
/>
Describe the bug you're encountering
When defaultModelExpandDepth is 3 or larger, the requestBody is rendered as below on load. Notably, the string-typed name and description fields are hidden behind the carat.
Expected rendering, shown below, is only accessible if defaultModelExpandDepth is 2 or less.

Additional context or thoughts
Please let me know if you need any additional information! I am happy to help.
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
Reproduce the issue in swagger-ui-react with the supplied OpenAPI 2.0 requestBody definition and SwaggerUI configuration, comparing defaultModelExpandDepth values of 2 and 3 in Chrome. Trace the model rendering behavior from that configuration and verify that the name and description fields are visible on load when the depth is 3 or larger.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100