Well, hello there Stephen!
Let’s start off by saying this – there’s no need to argue! We can solve it all calmly and peacefully. Eventually you’ll even all go out and have a drink together, look back and laugh at how things went.
I won’t go into the code generation part, will leave that to Tony or William but I can assist with the intent of the spec.
So you went ahead and decided to use `default` to describe a generic failed response.
Now technically, `default` is not the generic error response, but rather what the client should expect for all http codes that are not described. Yes, that can actually mean successful ones as well. In many cases it doesn’t make sense to return more than one 2XX response, but that’s the meaning of it.
What the codegen should be doing is assume that if the HTTP code is 200, it should call one function that accepts the Device, and one that is called for all other HTTP codes that accepts the Error. What happens if no Error is actually returned from the server (for example in case of a 5xx), well that should be handled in a generic well as well, to make the client error-proof.
API-design-wise, it makes perfect sense to use some sort of an Error entity, at least to me, and I try to encourage people to that. At minimum, the Error entity should include an error code and a message. The error code should allow the client to add additional business logic (that’s out of scope for Swagger) and the message, well, that’s something for the logs or to pass on to the user (depending how you manage your L10N/I18N, if you need that). Keep in mind that while HTTP status codes can cover some cases (404 is fairly simple), some simply don’t provide info. Take 400 for example on a faulty user input – that won’t help the user besides telling them they did something wrong. Personally, I wouldn’t try to adhere to the ‘RESTful ways’ as rules, but rather as a guideline (which is fairly good). Keep things in the spirit, but make your API usable.