-
Notifications
You must be signed in to change notification settings - Fork 9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OpenAPI 3.1.0 support: SwaggerUI 5.6.1 incorrectly renders responses that do not have a content field defined. #9199
Comments
I also have the same problem in v5.7.2, however, apparently it has no connection with the swagger-ui version. The problem occurs when I set the |
That is good observation, one that I had not encountered. |
I also have similar problem. I have a response without a schema, but SwaggerUI tries to show it and I end up getting the same error with emoji. I can reproduce that with this schema:
When I open SwaggerUI 5.9 with defaultModelRendering set to model, the above problem happens. Should i open separate issue for that case? |
Hi everybody, I can confirm that this is bug related to OpenAPI 3.1.0 exclusively. The issue is in two plugins: json-schema-2020-12-samplesWhen samples are being generated and neither schema nor example override is provided, the sample generator should return oas31In this plugins
This results in using JSON Schema 5 sample generator for JSON Schema 2020-12, which is source of another issues. Both issues have been addressed in #9664 |
Q&A (please complete the following information)
Content & configuration
Example Swagger/OpenAPI definition:
Swagger-UI configuration options:
Describe the bug you're encountering
We recently upgraded our SwaggerUI (unsure of our previous version) to v5.6.1 so that we could make use of OAS v3.1.0 in our spec documents. We also prefer to have our Swagger configured so that the Schema Models are rendered when the page is initially loaded, instead of the default to display the Example Value (i.e. configuration setting
defaultModelRendering
set to "model").We are now encountering a rendering anomaly for our Responses that have no content. According to the OAS document, no content is an acceptable definition for a response object. (To clarify, by "no content response" we mean the definition of the response object does not include a
content
field; just adescription
field.)What we see on the page in these cases is a warning (with a "screaming" emoji) that states "Could not render ModelWrapper, see the console." (Details are in the screenshots below.) If we change the configuration to initially display the Example Value (swagger default behavior), we no longer see the warning, but we still get a rendered code block where we shouldn't see anything at all (just the text from the
description
field for the response object). We cannot reproduce this specifically in the Swagger Editor (https://editor-next.swagger.io/) as we cannot configure the initial rendering as stated above. However, you can see that there are code blocks being rendered for the empty content responses, which should not be happening.To reproduce...
Steps to reproduce the behavior:
defaultModelRendering
to "example" and re-render the Swagger spec page.Expected behavior
In the described scenario, we would expect that a "no content response" would not attempt to render any object below the text from the
description
field in the response object definition. This is the behavior that was present in older versions (at least v4.x.x?) of the Swagger UI files.Screenshots
Example of "no content responses" (404, 500) where
defaultModelRendering
is set to "example" (default Swagger behavior):Example of "no content responses" (404, 500) where
defaultModelRendering
is set to "model":Screen grab of the console:
Additional context or thoughts
defaultModelRendering
configuration to "model", as we like having developers see the Schema definitions on initial view of the page. And we don't like staying on the "example" default rendering as it still looks unprofessional, even if it isn't a warning message; the code blocks being rendered for empty content look like we are missing information when we are not.The text was updated successfully, but these errors were encountered: