File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,18 @@ export type OpenapiPaths<Paths> = {
1313 }
1414}
1515
16+ type JSONBody < T > =
17+ | {
18+ content : {
19+ 'application/json' : T
20+ }
21+ }
22+ | {
23+ content : {
24+ [ K in `application/json;${string } `] : T
25+ }
26+ }
27+
1628export type OpArgType < OP > = OP extends {
1729 parameters ?: {
1830 path ?: infer P
@@ -23,9 +35,14 @@ export type OpArgType<OP> = OP extends {
2335 }
2436 // openapi 3
2537 requestBody ?: {
26- content : {
27- 'application/json' : infer RB
28- }
38+ content :
39+ | {
40+ 'application/json' : infer RB
41+ }
42+ | {
43+ [ K in `application/json;${string } `] : infer RB
44+ }
45+ | { 'multipart/form-data' : infer FD }
2946 }
3047}
3148 ? P & Q & ( B extends Record < string , unknown > ? B [ keyof B ] : unknown ) & RB
@@ -37,7 +54,7 @@ type OpResponseTypes<OP> = OP extends {
3754 ? {
3855 [ S in keyof R ] : R [ S ] extends { schema ?: infer S } // openapi 2
3956 ? S
40- : R [ S ] extends { content : { 'application/json' : infer C } } // openapi 3
57+ : R [ S ] extends JSONBody < infer C > // openapi 3
4158 ? C
4259 : S extends 'default'
4360 ? R [ S ]
You can’t perform that action at this time.
0 commit comments