swagger-ui: Response body and headers are not displayed for errors

This happens with responses with code 500 and 422 (and maybe others).
Steps to reproduce:
-
Place an order for a pet (
POST /store/order) with the following request body{ "id": 0, "petId": 12321312312312312, "quantity": -1, "shipDate": "asdasdasd", "status": "asdasdas", "complete": 12312312 }
- swagger-ui version: 3.0.8
- a swagger file reproducing the issue: http://petstore.swagger.io/v2/swagger.json
Probably related to #3021.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 19
- Comments: 39 (8 by maintainers)
+1
Same here, @dario30186 .
Folks, Do you agree that this issue is the most important of all that you have with Swagger-UI? For me, yes. In overall Swagger UI is so great.
The same here. It is very strange that no response body is displayed.
Same issue here with 3.0.12. When sending an incorrectly formatted POST request, the UI only shows “Error: Bad Request” whereas e.g. CURL returns the complete response body (in our case with additional info about the malformed input).
@dataexpert9 there are no error models mapped with your responses. I think that for other users like for me, the problem is that we don’t have any body in case of error response even if we map it with the right model
@dataexpert9, could you give us a code example that works with this issue? I tried a lot of things.
same here, also happens with version 3.0.10
On version 3.0.21 I am still seeing “Unknown response type” returned in Swagger UI for the response object, though the headers do display fine. If I execute the curl command manually I receive the json response that I expect (and have defined in my swagger).
Edit: Sorry please disregard. I forgot to add “application/json” to my produces definition. This is working fine.
I just update to 3.0.15, and as @EvgenyOrekhov said, no headers displayed in server response, and the response body is not formatted as human-readable: (XML example already showed in Evgeny’s screenshot)
Sure, we’d be happy to review a PR that fixes that too, just like we reviewed the PR that fixed the response rendering itself.
Check the master branch, the fix is there, just not released yet (will be this Friday).
I have just checked version 3.0.14/gf23b7044 (the one that’s at http://petstore.swagger.io/) and it still doesn’t work.
@dataexpert9 maybe you could describe your error in the documentation. So it could help others to fix it, too.
P.S. @yuricamara had the same intention. For me, swagger validator and swagger-editor both giving no failures