Skip to content

Commit 3774a30

Browse files
fedorgaurabirb
authored andcommitted
fix request body type being ignored
1 parent 8aecdf6 commit 3774a30

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/types.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ export type OpArgType<OP> = OP extends {
1818
path?: infer P
1919
query?: infer Q
2020
body?: infer B
21-
header?: unknown // ignore
22-
cookie?: unknown // ignore
21+
[k: string]: any
2322
}
2423
// openapi 3
2524
requestBody?: {

test/stations.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { OpArgType } from '../src'
2+
3+
import { components, paths } from './examples/stations'
4+
type Op = paths['/stations']['post']
5+
type Argument = components['schemas']['CreateStation']
6+
7+
type InferredArgument = OpArgType<Op>
8+
9+
type Same<A, B> = A extends B ? (B extends A ? true : false) : false
10+
11+
describe('infer', () => {
12+
it('argument', () => {
13+
const same: Same<Argument, InferredArgument> = true
14+
expect(same).toBe(true)
15+
})
16+
})

0 commit comments

Comments
 (0)