C
C#•2y ago
pox

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
Patrick
Patrick•2y ago
drive by opinion: i'd hate using that API 😄 i doubt swagger UI supports it
Zendist
Zendist•2y ago
Why? 😊. In a sense, I could appreciate the clarity of the possible error conditions.
pox
pox•2y ago
The errors inherit a base class which they fill out and sometimes extend the class if more values are needed
Patrick
Patrick•2y ago
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.
pox
pox•2y ago
Kinda got it working atleast.
pox
pox•2y ago
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
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
pox
pox•2y ago
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
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
pox
pox•2y ago
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
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
pox
pox•2y ago
Yes but if you don’t want the exception to bubble up, sometimes you want to handle things differently
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
pox
pox•2y ago
I mean we do use an exception handler, but it’s for exceptional errors Not invalid input etc
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server
More Posts