Swagger multiple error types
I want to show examples of multiple error types, all for StatusCode 400
The images shows how I do it today but the swagger only shows the first for 400.
OpenApi 3.0 should have support for multiple
15 Replies
drive by opinion: i'd hate using that API 😄
i doubt swagger UI supports it
Why? 😊. In a sense, I could appreciate the clarity of the possible error conditions.
The errors inherit a base class which they fill out and sometimes extend the class if more values are needed
because as a consumer i have a hell of a challenge to get to the deserialized state where i can even find out what went wrong in the first place
i know it's a bad request, so give me a reason string
my consumer end suddenly ends up as a loosely coupled pseudo contract of if statements and attempts to deserialize if the code is terrible
no way of knowing if you'll ever actually use all of the types, remove or add
terrible addition to OpenAPI if this is actually allowed now.
Kinda got it working atleast.
I can see the problems you talk about, but how would you different between errors with only a reason string? The api we are connecting to have requirements that we show what went wrong to our end users from their api. These would atleast provide a strongly typed errors that one could then show the user with the aid of translations etc
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Its based on https://www.rfc-editor.org/rfc/rfc7807 (kinda). the type field explains what kind of error, some errors extend the base error type when additional info is needed
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Multiple reasons, I kinda need to sleep but w/e
For one it can be hard to know what exceptions each endpoint can throw
Sometimes you want to handle the error paths in an underlaying service, try catching can turn kinda ugly etc
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Yes but if you don’t want the exception to bubble up, sometimes you want to handle things differently
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I mean we do use an exception handler, but it’s for exceptional errors
Not invalid input etc
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View