File tree Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Expand file tree Collapse file tree 3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -156,21 +156,27 @@ import './fetch-polyfill'
156
156
- ` OpErrorType ` - Infer error type of an operation
157
157
- ` FetchArgType ` - Argument type of a typed fetch operation
158
158
- ` FetchReturnType ` - Return type of a typed fetch operation
159
- - ` FetchErrorType ` - Return error type of a typed fetch operation
159
+ - ` FetchErrorType ` - Error type of a typed fetch operation
160
+ - ` TypedFetch ` - Fetch operation type
160
161
161
162
``` ts
162
163
import { paths , operations } from ' ./petstore'
163
164
164
165
type Arg = OpArgType <operations [' findPetsByStatus' ]>
165
166
type Ret = OpReturnType <operations [' findPetsByStatus' ]>
167
+ type Err = OpErrorType <operations [' findPetsByStatus' ]>
166
168
167
169
type Arg = OpArgType <paths [' /pet/findByStatus' ][' get' ]>
168
170
type Ret = OpReturnType <paths [' /pet/findByStatus' ][' get' ]>
171
+ type Err = OpErrorType <paths [' /pet/findByStatus' ][' get' ]>
172
+
173
+ type FindPetsByStatus = TypedFetch <operations [' findPetsByStatus' ]>
169
174
170
175
const findPetsByStatus = fetcher .path (' /pet/findByStatus' ).method (' get' ).create ()
171
176
172
177
type Arg = FetchArgType <typeof findPetsByStatus >
173
178
type Ret = FetchReturnType <typeof findPetsByStatus >
179
+ type Err = FetchErrorType <typeof findPetsByStatus >
174
180
` ` `
175
181
176
182
Happy fetching! 👍
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " openapi-typescript-fetch" ,
3
3
"description" : " A typed fetch client for openapi-typescript" ,
4
- "version" : " 1.1.1 " ,
4
+ "version" : " 1.1.2 " ,
5
5
"engines" : {
6
6
"node" : " >= 12.0.0" ,
7
7
"npm" : " >= 7.0.0"
Original file line number Diff line number Diff line change 7
7
OpDefaultReturnType ,
8
8
OpErrorType ,
9
9
OpReturnType ,
10
+ TypedFetch ,
10
11
} from '../src'
11
12
import { paths as paths2 } from './examples/stripe-openapi2'
12
13
import { paths as paths3 } from './examples/stripe-openapi3'
@@ -66,8 +67,13 @@ describe('infer', () => {
66
67
} )
67
68
68
69
describe ( 'fetch' , ( ) => {
70
+ type CreateLink = TypedFetch < Op2 >
71
+
69
72
const fetcher = Fetcher . for < paths2 > ( )
70
- const createLink = fetcher . path ( '/v1/account_links' ) . method ( 'post' ) . create ( )
73
+ const createLink : CreateLink = fetcher
74
+ . path ( '/v1/account_links' )
75
+ . method ( 'post' )
76
+ . create ( )
71
77
72
78
type Arg = FetchArgType < typeof createLink >
73
79
type Ret = FetchReturnType < typeof createLink >
You can’t perform that action at this time.
0 commit comments