Unexpected defaultModelExpandDepth behavior
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.
Same issue here:
- OS: All
- Browser: Firefox
- Version: 101
- Method of installation: dist assets
- Swagger-UI version: 4.12.0
- Swagger/OpenAPI version: OpenAPI 3.0
"defaultModelExpandDepth" is just broken currently. Seems to be some kind of regression as this used to work in older versions.
The config option is working correctly in 4.6.2. Issue comes up in 4.7.0.
I also wanted to upgrade to latest version but this is a deal-breaker. As an additional note, this happens for all models that have a value greater than the one specified in defaultModelExpandDepth.
Hello,
I'll take a look at it today :)
Hello you all,
I created a PR to fix this issue -> https://github.com/swagger-api/swagger-ui/pull/8186