@@ -23,6 +23,26 @@ type Op3 = Omit<paths3['/v1/account_links']['post'], 'requestBody'> & {
23
23
}
24
24
}
25
25
26
+ type Op4 = Omit < paths3 [ '/v1/account_links' ] [ 'post' ] , 'requestBody' > & {
27
+ requestBody : {
28
+ content : {
29
+ 'application/json;charset=utf-8' : paths3 [ '/v1/account_links' ] [ 'post' ] [ 'requestBody' ] [ 'content' ] [ 'application/x-www-form-urlencoded' ]
30
+ }
31
+ }
32
+ responses : {
33
+ 200 : {
34
+ content : {
35
+ 'application/json;charset=UTF-8' : paths3 [ '/v1/account_links' ] [ 'post' ] [ 'responses' ] [ '200' ] [ 'content' ] [ 'application/json' ]
36
+ }
37
+ }
38
+ default : {
39
+ content : {
40
+ 'application/json; charset=UTF-8' : paths3 [ '/v1/account_links' ] [ 'post' ] [ 'responses' ] [ 'default' ] [ 'content' ] [ 'application/json' ]
41
+ }
42
+ }
43
+ }
44
+ }
45
+
26
46
interface Openapi2 {
27
47
Argument : OpArgType < Op2 >
28
48
Return : OpReturnType < Op2 >
@@ -37,6 +57,13 @@ interface Openapi3 {
37
57
Error : Pick < OpErrorType < Op3 > [ 'data' ] [ 'error' ] , 'type' | 'message' >
38
58
}
39
59
60
+ interface Openapi4 {
61
+ Argument : OpArgType < Op4 >
62
+ Return : OpReturnType < Op4 >
63
+ Default : Pick < OpDefaultReturnType < Op4 > [ 'error' ] , 'type' | 'message' >
64
+ Error : Pick < OpErrorType < Op4 > [ 'data' ] [ 'error' ] , 'type' | 'message' >
65
+ }
66
+
40
67
type Same < A , B > = A extends B ? ( B extends A ? true : false ) : false
41
68
42
69
describe ( 'infer' , ( ) => {
@@ -128,4 +155,34 @@ describe('infer', () => {
128
155
const err : Err = { data : { error : { } } } as any
129
156
expect ( err . data . error . charge ) . toBeUndefined ( )
130
157
} )
158
+
159
+ describe ( 'application/json with charset' , ( ) => {
160
+ it ( 'argument' , ( ) => {
161
+ const same : Same < Openapi4 [ 'Argument' ] , Openapi3 [ 'Argument' ] > = true
162
+ expect ( same ) . toBe ( true )
163
+
164
+ // @ts -expect-error -- missing properties
165
+ const arg : Openapi4 [ 'Argument' ] = { }
166
+ expect ( arg . account ) . toBeUndefined ( )
167
+ } )
168
+
169
+ it ( 'return' , ( ) => {
170
+ const same : Same < Openapi4 [ 'Return' ] , Openapi3 [ 'Return' ] > = true
171
+ expect ( same ) . toBe ( true )
172
+
173
+ // @ts -expect-error -- missing properties
174
+ const ret : Openapi4 [ 'Return' ] = { }
175
+ expect ( ret . url ) . toBeUndefined ( )
176
+ } )
177
+
178
+ it ( 'default' , ( ) => {
179
+ const same : Same < Openapi4 [ 'Default' ] , Openapi3 [ 'Default' ] > = true
180
+ expect ( same ) . toBe ( true )
181
+ } )
182
+
183
+ it ( 'error' , ( ) => {
184
+ const same : Same < Openapi4 [ 'Error' ] , Openapi3 [ 'Error' ] > = true
185
+ expect ( same ) . toBe ( true )
186
+ } )
187
+ } )
131
188
} )
0 commit comments