Plumber: Swagger handle error body in bad responses

Created on 9 Nov 2018  路  4Comments  路  Source: rstudio/plumber

I may be doing something wrong here, but I am following the docs to return a body that has information about the 400 response being thrown for a bad stock ticker input.

In the Swagger, this is not visible:

image

However, in curl, you can see the body:

$ curl -X GET "http://127.0.0.1:4479/price?ticker=OTHER" -H  "accept: application/json"
{"error":["Invalid ticker. Please use one of 'AAPL', 'AMZN', 'FB', 'GOOG', 'INTC', 'MSFT'"]}

Is it possible to include this type of response in Swagger even for non-200 responses?

intermediate low medium swagger bug

All 4 comments

Apparently the "Warning" header is one that we should be using based on the spec, but that is not shown in Swagger either.

res$status <- 400
res$headers$Message <- "Message"
res$headers$Warning <- "Warning"

https://stackoverflow.com/a/51935913/6570011

@colearendt I believe swagger in general needs a good once-over and an update to the latest version. If you find any more unexpected behavior, please make an issue so I can track them. Thank you in advance!

This issue (https://github.com/swagger-api/swagger-ui/issues/3041) is apparently fixed in Swagger 3.0.18 馃槃

swagger has been updated to use swagger-ui 3.33.0

Closing

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dpmccabe picture dpmccabe  路  6Comments

jeffkeller87 picture jeffkeller87  路  6Comments

dmenne picture dmenne  路  4Comments

emmanuelchevallier picture emmanuelchevallier  路  3Comments

meztez picture meztez  路  4Comments