-
-
Notifications
You must be signed in to change notification settings - Fork 507
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
Fix 2XX, 4XX, 5XX responses #1251
Conversation
🦋 Changeset detectedLatest commit: bd72890 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -29,9 +29,9 @@ export interface OperationObject { | |||
responses: any; | |||
} | |||
export type HttpMethod = "get" | "put" | "post" | "delete" | "options" | "head" | "patch" | "trace"; | |||
export type OkStatus = 200 | 201 | 202 | 203 | 204 | 206 | 207; | |||
export type OkStatus = 200 | 201 | 202 | 203 | 204 | 206 | 207 | "2XX"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Random fact: the status codes are numbers because that’s what openapi-typescript
actually exports. See #380
Deploying with
|
Latest commit: |
bd72890
|
Status: | ✅ Deploy successful! |
Preview URL: | https://bf99acf2.openapi-ts.pages.dev |
Branch Preview URL: | https://fix-ranges.openapi-ts.pages.dev |
expect(generated).toBe(`{ | ||
responses: { | ||
/** @description OK */ | ||
"2XX": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😅 Glad this worked! Added a test just cuz I got scared
Changes
Adds support for
2XX
,4XX
, and5XX
responses in schema, which is supported by the spec.Funny enough, I have never used this or seen this; just happened to skim over that definition and saw it was allowed. In
openapi-typescript
we just skip right over this and never needed to parse it (still added a test just to be sure). Butopenapi-fetch
requires all valid status codes explicitly stated for TS inference to work.So for that one random person out there using this in your schema, this goes out to you 🥂
How to Review
Tests should pass.
Checklist
examples/
directory updated (only applicable for openapi-typescript)