Skip to content

Commit 90dded8

Browse files
committed
return type 201
1 parent 8af3907 commit 90dded8

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "openapi-typescript-fetch",
33
"description": "A typed fetch client for openapi-typescript",
4-
"version": "1.1.0",
4+
"version": "1.1.1",
55
"engines": {
66
"node": ">= 12.0.0",
77
"npm": ">= 7.0.0"

src/types.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ type OpResponseTypes<OP> = OP extends {
4545

4646
type _OpReturnType<T> = 200 extends keyof T
4747
? T[200]
48+
: 201 extends keyof T
49+
? T[201]
4850
: 'default' extends keyof T
4951
? T['default']
5052
: unknown
@@ -61,11 +63,11 @@ export type OpDefaultReturnType<OP> = _OpDefaultReturnType<OpResponseTypes<OP>>
6163
const never: unique symbol = Symbol()
6264

6365
type _OpErrorType<T> = {
64-
[S in Exclude<keyof T, 200>]: {
66+
[S in Exclude<keyof T, 200 | 201>]: {
6567
status: S extends 'default' ? typeof never : S
6668
data: T[S]
6769
}
68-
}[Exclude<keyof T, 200>]
70+
}[Exclude<keyof T, 200 | 201>]
6971

7072
type Coalesce<T, D> = [T] extends [never] ? D : T
7173

test/paths.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type BodyAndQuery = {
2828
query: { scalar: string }
2929
body: { payload: { list: string[] } }
3030
}
31-
responses: { 200: { schema: Data } }
31+
responses: { 201: { schema: Data } }
3232
}
3333

3434
export type paths = {

0 commit comments

Comments
 (0)