Generating components.responses objects #8149
Unanswered
happenslol
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a global catch-all error type that can be returned from every endpoint:
Then, I wrap all of my ops return types with
Result
. This allows me to have typed internal server errors for every endpoint. This results in the following OpenAPI spec:However, my backend codegen sees each default response as a seperate response, which means that a seperate type is generated for the default error of every endpoint.
From an OpenAPI standpoint, I think the best practice here would be to have a schema in
components.responses
like so:This would result in the response type only being generated once.
I see no way of defining a response as a component with typespec. Is this just not possible or am I just going about it the wrong way?
Beta Was this translation helpful? Give feedback.
All reactions