swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Unexpected defaultModelExpandDepth behavior

Open alexrejto opened this issue 3 years ago • 5 comments

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.

image

Expected rendering, shown below, is only accessible if defaultModelExpandDepth is 2 or less. image

Additional context or thoughts

Please let me know if you need any additional information! I am happy to help.

alexrejto avatar May 04 '22 06:05 alexrejto

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.

M-Reimer avatar Jun 27 '22 09:06 M-Reimer

The config option is working correctly in 4.6.2. Issue comes up in 4.7.0.

kchaitanya1195 avatar Sep 09 '22 11:09 kchaitanya1195

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.

gcardoso22 avatar Sep 13 '22 13:09 gcardoso22

Hello,

I'll take a look at it today :)

twjasa avatar Sep 13 '22 13:09 twjasa

Hello you all,

I created a PR to fix this issue -> https://github.com/swagger-api/swagger-ui/pull/8186

twjasa avatar Sep 20 '22 19:09 twjasa