File tree Expand file tree Collapse file tree 5 files changed +279
-144
lines changed
examples/openapi-ts-sample/src Expand file tree Collapse file tree 5 files changed +279
-144
lines changed Original file line number Diff line number Diff line change @@ -9,14 +9,14 @@ import {
9
9
Section ,
10
10
} from '@radix-ui/themes' ;
11
11
12
- // @ts -expect-error
13
- import { postFoo } from './client/sdk.gen' ;
12
+ import { addPet } from './client/sdk.gen' ;
14
13
15
14
function App ( ) {
16
15
const onClick = async ( ) => {
17
- postFoo ( {
16
+ addPet ( {
18
17
body : {
19
- foo : [ [ 1 , 2 ] ] ,
18
+ name : 'test' ,
19
+ photoUrls : [ 'test' ] ,
20
20
} ,
21
21
} ) ;
22
22
} ;
Original file line number Diff line number Diff line change 1
1
// This file is auto-generated by @hey-api/openapi-ts
2
2
3
- import { createClient , createConfig } from '@hey-api/client-fetch' ;
3
+ import {
4
+ type ClientOptions as DefaultClientOptions ,
5
+ type Config ,
6
+ createClient ,
7
+ createConfig ,
8
+ } from '@hey-api/client-fetch' ;
4
9
5
10
import { createClientConfig } from '../hey-api' ;
11
+ import type { ClientOptions } from './types.gen' ;
6
12
7
- export const client = createClient ( createClientConfig ( createConfig ( ) ) ) ;
13
+ /**
14
+ * The `createClientConfig()` function will be called on client initialization
15
+ * and the returned object will become the client's initial configuration.
16
+ *
17
+ * You may want to initialize your client this way instead of calling
18
+ * `setConfig()`. This is useful for example if you're using Next.js
19
+ * to ensure your client always has the correct values.
20
+ */
21
+ export type CreateClientConfig < T extends DefaultClientOptions = ClientOptions > =
22
+ (
23
+ override ?: Config < DefaultClientOptions & T > ,
24
+ ) => Config < Required < DefaultClientOptions > & T > ;
25
+
26
+ export const client = createClient (
27
+ createClientConfig (
28
+ createConfig < ClientOptions > ( {
29
+ baseUrl : 'https://petstore3.swagger.io/api/v3' ,
30
+ } ) ,
31
+ ) ,
32
+ ) ;
Original file line number Diff line number Diff line change @@ -38,59 +38,6 @@ export const OrderSchema = {
38
38
} ,
39
39
} as const ;
40
40
41
- export const CustomerSchema = {
42
- properties : {
43
- address : {
44
- items : {
45
- $ref : '#/components/schemas/Address' ,
46
- } ,
47
- type : 'array' ,
48
- xml : {
49
- name : 'addresses' ,
50
- wrapped : true ,
51
- } ,
52
- } ,
53
- id : {
54
- example : 100000 ,
55
- format : 'int64' ,
56
- type : 'integer' ,
57
- } ,
58
- username : {
59
- example : 'fehguy' ,
60
- type : 'string' ,
61
- } ,
62
- } ,
63
- type : 'object' ,
64
- xml : {
65
- name : 'customer' ,
66
- } ,
67
- } as const ;
68
-
69
- export const AddressSchema = {
70
- properties : {
71
- city : {
72
- example : 'Palo Alto' ,
73
- type : 'string' ,
74
- } ,
75
- state : {
76
- example : 'CA' ,
77
- type : 'string' ,
78
- } ,
79
- street : {
80
- example : '437 Lytton' ,
81
- type : 'string' ,
82
- } ,
83
- zip : {
84
- example : 94301 ,
85
- type : 'string' ,
86
- } ,
87
- } ,
88
- type : 'object' ,
89
- xml : {
90
- name : 'address' ,
91
- } ,
92
- } as const ;
93
-
94
41
export const CategorySchema = {
95
42
properties : {
96
43
id : {
@@ -130,11 +77,11 @@ export const UserSchema = {
130
77
type : 'string' ,
131
78
} ,
132
79
password : {
133
- example : 12345 ,
80
+ example : ' 12345' ,
134
81
type : 'string' ,
135
82
} ,
136
83
phone : {
137
- example : 12345 ,
84
+ example : ' 12345' ,
138
85
type : 'string' ,
139
86
} ,
140
87
userStatus : {
@@ -206,9 +153,6 @@ export const PetSchema = {
206
153
tags : {
207
154
items : {
208
155
$ref : '#/components/schemas/Tag' ,
209
- xml : {
210
- name : 'tag' ,
211
- } ,
212
156
} ,
213
157
type : 'array' ,
214
158
xml : {
You can’t perform that action at this time.
0 commit comments