I want to use the same error response status code twice for some endpoints (I dont want to debate if this is correct or not). Suppose I have two different types of conflicts, I would want to return two separate 409 errors. This is supported as of OpenAPI 3, which I am using. I can see how to manually add an additional error schema in the generated swagger, but I cannot see how to do this in TSOA.
TSOA simply will show the error defined last, and omit any preceding it. If I cannot have multiple errors with the same code in TSOA, is there a way I can add an additional example error? Here I am talking about when you load your spec into an editor, you get an 'examples' drop down - can I add my other 409 error here? (see image).
This is how I define my errors.
@Response<ErrorBody>('409', 'A 409 error', {
type: 'https://someurl.com',
status: 409,
code: 'error/409-error-one',
title: 'This is an example',
detail: 'You should provide error detail',
})
@Response<ErrorBody>('409', 'A 409 error called fred', {
type: 'https://someurl.com',
status: 409,
code: 'error/409-error-one-hundred-and-fifty',
title: 'This is an example of another error',
detail: 'You should provide error detail for all errors',
})
So although the above works as expected, so the errors are thrown correctly, the documentation generated only shows the last error for each status code.