If the authorization endpoint returns an error response and that response's body is a complex object (such as an array), Swagger UI will fail to stringify it and the result will be:
If, however, the status code of the response is 200, the response body is correctly stringified:
To reproduce...
My API is not public, but any endpoint that returns complex objects in an error response (see schema above) will cause the bug to occur.
If the status code is 200, line #205 is executed and since we have a non-null error property, Swagger correctly identifies the authorization failed and, since response.ok is true, the error is stringified. This is not the case, however, if the status code is an error (such as 422 or 400).
Q&A (please complete the following information)
Content & configuration
Example Swagger/OpenAPI definition:
Swagger-UI configuration options:
All defaults
Describe the bug you're encountering
If the authorization endpoint returns an error response and that response's body is a complex object (such as an array), Swagger UI will fail to stringify it and the result will be:
If, however, the status code of the response is 200, the response body is correctly stringified:
To reproduce...
My API is not public, but any endpoint that returns complex objects in an error response (see schema above) will cause the bug to occur.
Expected behavior
Complex objects in error response
Screenshots
Embedded above
Additional context or thoughts
I believe the issue is here: https://github.com/swagger-api/swagger-ui/blob/master/src/core/plugins/auth/actions.js
If the status code is 200, line #205 is executed and since we have a non-null error property, Swagger correctly identifies the authorization failed and, since
response.ok
is true, the error is stringified. This is not the case, however, if the status code is an error (such as 422 or 400).Stack Overflow question: https://stackoverflow.com/questions/78960147/objects-in-error-response-cant-be-parsed-by-swagger-ui