problem with known StatusCodes and code generation
I defined known status codes of 400,401,403 in swagger doc. In generated client classes exception is not thrown for this error codes but i feel like it should be.
@unclepaul84 https://github.com/Azure/azure-rest-api-specs/blob/master/documentation/creating-swagger.md#negative-responses
@unclepaul84 As Amar's link states, this behavior is intended. Known negative responses are expected outcomes and therefore don't throw exceptions. I'm closing this issue, but feel free to re-open it if this didn't fully cover the issue.
@amarzavery @tbombach I'm struggling with this as well. I've got a 409 (Conflict) which an API uses to indicate concurrency problems. Another example is a 400 (Bad Request) which an API may use to indicate that there was a problem with the parameters (query, url, body, header) of the request. In instances like that it is not good, if a client just 'swallows' these status codes and they could go unnoticed and/or cause weird behaviour if they are not treated appropriately.
The swagger (Open API) specification does not prescribe how a status code should be treated. The assumption that every status code that is known does not need to raise attention (e.g. by throwing an exception) is a dangerous one, since handling these status code is kind of complicated. Using the ...WithHttpMessagesAsync methods directly, handling the disposable HttpOperationResponse, asking for the StatusCode of the Response of the response is not really that obvious and easily forgotten. Converting status codes into Exceptions or alternatively providing the results of all operations as OperationResult