-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global defaultResponse/error #3082
Comments
One of the issues with having configurable default behavior in typespec is when using For example
The pattern we have been prefering is defining template operation
|
Ah, I understand. That's unfortunate, and seems a bit unintuitive. Since this is already causing problems in other spaces, is it something that you're planning on changing in the long run? |
We unfortunately don't have any plan to change that for now, as much as this case could benefit from having this, not all decorators would want to be carried over(so would want some sort of modifier here as well. In the There is some more or less hacky ways we can achieve the behavior you are looking for with the current system, it could also just not be something we recommend using in a library(which would mean we ignore the issue). But I do feel like we might want more feedback of this being a wanted/needed feature before considering it. |
Just chiming in to offer that you can also use a templated union, ala:
It is still verbose compared to a global setting, but it doesn't require an op template which can give some additional flexibility. |
Thanks for filing the issue. Considering the tradeoff, the proposed solution sounds like an adequate solution. |
I'm currently using |
Clear and concise description of the problem
It would be great if it was possible to globally define an Error type that all operations (or maybe just all operations within a namespace) use as a default response for OpenAPI.
This would enable defining something like a
ServerError
type that acts as a fallback, instead of having to useThing | NotFoundResponse | ServerError
for every operation.I'm not sure what this would look like code-wise, but I can try to come up with some imaginary code examples if you'd like to explain the feature request further.
Checklist
The text was updated successfully, but these errors were encountered: