-
Notifications
You must be signed in to change notification settings - Fork 61
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
Improve type safety on error responses #61
Comments
Some points after a call with @SferaDev to have more context: The idea is to add a Then, since the type will be passed in every operations, this will force the user to implement every error cases (and typescript will warn on every new error introduce in openapi) |
Thinking a bit more about this, some ideas that I would love to integrate to improve the error type safety. 1. Adding an
|
@fabien0102 I like your proposals. Just make status a number please (as in And do we really need things like |
The thing is… in openapi, you can define And also |
Then yes it might make sense to use strings. Although maybe we could have a union without doing any parsing. type Status = 200 | 201 | 400 | 404 | "5xx" | "default"; And the fetcher will have to discriminate or build the logic they want per union member. Even though I like having the status code, I don't really see the real usage other than knowing that it's likely the error will happen so I need to make sure to treat the scenario. We already get the status code from the response error in runtime. |
Right now,
fetchers
do not have a way to include error responses types. Add them and make the default fetcher to type the union of them.Also, create types for inlined responses.
The text was updated successfully, but these errors were encountered: