tangled
alpha
login
or
join now
mokkenstorm.dev
/
openapi-ts
0
fork
atom
fork of hey-api/openapi-ts because I need some additional things
0
fork
atom
overview
issues
pulls
pipelines
chore: update axios example to match fetch
Lubos
2 years ago
c7262f30
a0421224
+835
-796
12 changed files
expand all
collapse all
unified
split
examples
openapi-ts-axios
index.html
openapi-ts.config.ts
package.json
postcss.config.js
src
App.css
App.tsx
client
services.gen.ts
types.gen.ts
index.css
main.tsx
tailwind.config.js
pnpm-lock.yaml
+1
-1
examples/openapi-ts-axios/index.html
···
2
2
<html lang="en">
3
3
<head>
4
4
<meta charset="UTF-8" />
5
5
-
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
5
5
+
<!-- <link rel="icon" type="image/svg+xml" href="/vite.svg" /> -->
6
6
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
<title>Hey API + Axios Demo</title>
8
8
</head>
+12
-3
examples/openapi-ts-axios/openapi-ts.config.ts
···
1
1
import { defineConfig } from '@hey-api/openapi-ts';
2
2
3
3
export default defineConfig({
4
4
-
format: 'prettier',
4
4
+
base: 'https://petstore3.swagger.io/api/v3',
5
5
+
client: '@hey-api/client-axios',
5
6
input:
6
7
'https://raw.githubusercontent.com/swagger-api/swagger-petstore/master/src/main/resources/openapi.yaml',
7
7
-
lint: 'eslint',
8
8
-
output: './src/client',
8
8
+
// 'https://raw.githubusercontent.com/Redocly/museum-openapi-example/main/openapi.yaml',
9
9
+
// '../../packages/openapi-ts/test/spec/v3.json',
10
10
+
output: {
11
11
+
format: 'prettier',
12
12
+
lint: 'eslint',
13
13
+
path: './src/client',
14
14
+
},
15
15
+
types: {
16
16
+
enums: 'javascript',
17
17
+
},
9
18
});
+6
examples/openapi-ts-axios/package.json
···
13
13
},
14
14
"dependencies": {
15
15
"@hey-api/client-axios": "workspace:*",
16
16
+
"@radix-ui/react-form": "0.0.3",
17
17
+
"@radix-ui/react-icons": "1.3.0",
18
18
+
"@radix-ui/themes": "3.0.5",
16
19
"axios": "1.7.2",
17
20
"react": "18.3.1",
18
21
"react-dom": "18.3.1"
···
24
27
"@typescript-eslint/eslint-plugin": "7.10.0",
25
28
"@typescript-eslint/parser": "7.10.0",
26
29
"@vitejs/plugin-react": "4.3.0",
30
30
+
"autoprefixer": "10.4.19",
27
31
"eslint": "9.3.0",
28
32
"eslint-plugin-react-hooks": "4.6.2",
29
33
"eslint-plugin-react-refresh": "0.4.7",
34
34
+
"postcss": "8.4.38",
30
35
"prettier": "3.2.5",
36
36
+
"tailwindcss": "3.4.3",
31
37
"typescript": "5.4.5",
32
38
"vite": "5.2.11"
33
39
}
+6
examples/openapi-ts-axios/postcss.config.js
···
1
1
+
export default {
2
2
+
plugins: {
3
3
+
autoprefixer: {},
4
4
+
tailwindcss: {},
5
5
+
},
6
6
+
};
+3
-87
examples/openapi-ts-axios/src/App.css
···
1
1
-
:root {
2
2
-
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3
3
-
line-height: 1.5;
4
4
-
font-weight: 400;
5
5
-
6
6
-
color-scheme: light dark;
7
7
-
color: rgba(255, 255, 255, 0.87);
8
8
-
background-color: #242424;
9
9
-
10
10
-
font-synthesis: none;
11
11
-
text-rendering: optimizeLegibility;
12
12
-
-webkit-font-smoothing: antialiased;
13
13
-
-moz-osx-font-smoothing: grayscale;
14
14
-
}
15
15
-
16
16
-
.flex {
17
17
-
align-items: center;
18
18
-
display: flex;
19
19
-
padding: 1em 0;
20
20
-
}
21
21
-
22
22
-
.pet-name {
23
23
-
padding: 0 1em;
24
24
-
}
25
25
-
26
26
-
.button {
27
27
-
border: 1px solid #444;
28
28
-
}
29
29
-
30
30
-
#root {
31
31
-
max-width: 1280px;
32
32
-
margin: 0 auto;
33
33
-
padding: 0.5rem 2rem;
34
34
-
}
35
35
-
36
36
-
body {
37
37
-
margin: 0;
38
38
-
display: flex;
39
39
-
place-items: center;
40
40
-
min-width: 320px;
41
41
-
min-height: 100vh;
42
42
-
}
43
43
-
44
44
-
.h1 {
45
45
-
font-size: 1.2em;
46
46
-
line-height: 1.1;
47
47
-
}
1
1
+
@tailwind base;
2
2
+
@tailwind components;
3
3
+
@tailwind utilities;
48
4
49
5
.logo {
50
6
height: 4em;
51
7
will-change: filter;
52
8
transition: filter 300ms;
53
9
}
54
54
-
.logo:hover {
55
55
-
filter: drop-shadow(0 0 2em #646cffaa);
56
56
-
}
57
57
-
.logo.react:hover {
58
58
-
filter: drop-shadow(0 0 2em #61dafbaa);
59
59
-
}
60
10
61
11
@keyframes logo-spin {
62
12
from {
···
66
16
transform: rotate(360deg);
67
17
}
68
18
}
69
69
-
70
70
-
@media (prefers-reduced-motion: no-preference) {
71
71
-
a:nth-of-type(2) .logo {
72
72
-
animation: logo-spin infinite 20s linear;
73
73
-
}
74
74
-
}
75
75
-
76
76
-
.card {
77
77
-
padding: 2em;
78
78
-
}
79
79
-
80
80
-
.container {
81
81
-
align-items: center;
82
82
-
display: flex;
83
83
-
grid-gap: 1em;
84
84
-
text-align: center;
85
85
-
}
86
86
-
87
87
-
.openapi-ts {
88
88
-
color: #444;
89
89
-
}
90
90
-
91
91
-
@media (prefers-color-scheme: light) {
92
92
-
:root {
93
93
-
color: #213547;
94
94
-
background-color: #ffffff;
95
95
-
}
96
96
-
a:hover {
97
97
-
color: #747bff;
98
98
-
}
99
99
-
button {
100
100
-
background-color: #f9f9f9;
101
101
-
}
102
102
-
}
+227
-38
examples/openapi-ts-axios/src/App.tsx
···
1
1
import './App.css';
2
2
3
3
-
import { client, createClient } from '@hey-api/client-axios';
3
3
+
import { createClient } from '@hey-api/client-axios';
4
4
+
import * as Form from '@radix-ui/react-form';
5
5
+
import { DownloadIcon, PlusIcon, ReloadIcon } from '@radix-ui/react-icons';
6
6
+
import {
7
7
+
Avatar,
8
8
+
Box,
9
9
+
Button,
10
10
+
Card,
11
11
+
Container,
12
12
+
Flex,
13
13
+
Heading,
14
14
+
Section,
15
15
+
Text,
16
16
+
TextField,
17
17
+
} from '@radix-ui/themes';
4
18
import { useState } from 'react';
5
19
6
20
import { $Pet } from './client/schemas.gen';
7
7
-
import { PetService } from './client/services.gen';
21
21
+
import { addPet, getPetById, updatePet } from './client/services.gen';
22
22
+
import type { Pet } from './client/types.gen';
8
23
9
24
createClient({
25
25
+
// set default base url for requests
10
26
baseUrl: 'https://petstore3.swagger.io/api/v3',
27
27
+
// set default headers for requests
28
28
+
headers: {
29
29
+
Authorization: 'Bearer <token_from_global_client>',
30
30
+
},
11
31
});
12
32
13
13
-
// OpenAPI.interceptors.response.use((response) => {
14
14
-
// if (response.status === 200) {
15
15
-
// console.log(`request to ${response.url} was successful`);
16
16
-
// }
17
17
-
// return response;
18
18
-
// });
33
33
+
const localClient = createClient({
34
34
+
// set default base url for requests made by this client
35
35
+
baseUrl: 'https://petstore3.swagger.io/api/v3',
36
36
+
global: false,
37
37
+
/**
38
38
+
* Set default headers only for requests made by this client. This is to
39
39
+
* demonstrate local clients and their configuration taking precedence over
40
40
+
* global configuration.
41
41
+
*/
42
42
+
headers: {
43
43
+
Authorization: 'Bearer <token_from_local_client>',
44
44
+
},
45
45
+
});
46
46
+
47
47
+
localClient.interceptors.request.use((request, options) => {
48
48
+
// Middleware is great for adding authorization tokens to requests made to
49
49
+
// protected paths. Headers are set randomly here to allow surfacing the
50
50
+
// default headers, too.
51
51
+
if (
52
52
+
options.url === '/pet/{petId}' &&
53
53
+
options.method === 'GET' &&
54
54
+
Math.random() < 0.5
55
55
+
) {
56
56
+
request.headers.set('Authorization', 'Bearer <token_from_interceptor>');
57
57
+
}
58
58
+
return request;
59
59
+
});
19
60
20
61
function App() {
21
21
-
const [pet, setPet] =
22
22
-
useState<Awaited<ReturnType<typeof PetService.getPetById>>>();
62
62
+
const [pet, setPet] = useState<Pet>();
63
63
+
const [isRequiredNameError, setIsRequiredNameError] = useState(false);
64
64
+
65
65
+
const onAddPet = async (formData: FormData) => {
66
66
+
// simple form field validation to demonstrate using schemas
67
67
+
if ($Pet.required.includes('name') && !formData.get('name')) {
68
68
+
setIsRequiredNameError(true);
69
69
+
return;
70
70
+
}
71
71
+
72
72
+
const { data, error } = await addPet({
73
73
+
body: {
74
74
+
category: {
75
75
+
id: 0,
76
76
+
name: formData.get('category') as string,
77
77
+
},
78
78
+
id: 0,
79
79
+
name: formData.get('name') as string,
80
80
+
photoUrls: ['string'],
81
81
+
status: 'available',
82
82
+
tags: [
83
83
+
{
84
84
+
id: 0,
85
85
+
name: 'string',
86
86
+
},
87
87
+
],
88
88
+
},
89
89
+
});
90
90
+
if (error) {
91
91
+
console.log(error);
92
92
+
return;
93
93
+
}
94
94
+
setPet(data!);
95
95
+
setIsRequiredNameError(false);
96
96
+
};
23
97
24
24
-
const onFetchPet = async () => {
25
25
-
client.get('/pet/{petId}');
26
26
-
const pet = await PetService.getPetById({
27
27
-
// random id 1-10
28
28
-
petId: Math.floor(Math.random() * (10 - 1 + 1) + 1),
98
98
+
const onGetPetById = async () => {
99
99
+
const { data, error } = await getPetById({
100
100
+
client: localClient,
101
101
+
path: {
102
102
+
// random id 1-10
103
103
+
petId: Math.floor(Math.random() * (10 - 1 + 1) + 1),
104
104
+
},
105
105
+
});
106
106
+
if (error) {
107
107
+
console.log(error);
108
108
+
return;
109
109
+
}
110
110
+
setPet(data!);
111
111
+
};
112
112
+
113
113
+
const onUpdatePet = async () => {
114
114
+
const { data, error } = await updatePet({
115
115
+
body: {
116
116
+
category: {
117
117
+
id: 0,
118
118
+
name: 'Cats',
119
119
+
},
120
120
+
id: 2,
121
121
+
name: 'Updated Kitty',
122
122
+
photoUrls: ['string'],
123
123
+
status: 'available',
124
124
+
tags: [
125
125
+
{
126
126
+
id: 0,
127
127
+
name: 'string',
128
128
+
},
129
129
+
],
130
130
+
},
131
131
+
// setting headers per request
132
132
+
headers: {
133
133
+
Authorization: 'Bearer <token_from_method>',
134
134
+
},
29
135
});
30
30
-
setPet(pet);
136
136
+
if (error) {
137
137
+
console.log(error);
138
138
+
return;
139
139
+
}
140
140
+
setPet(data!);
31
141
};
32
142
33
143
return (
34
34
-
<>
35
35
-
<div className="container">
36
36
-
<a href="https://heyapi.vercel.app/" target="_blank">
37
37
-
<img
38
38
-
src="https://heyapi.vercel.app/logo.png"
39
39
-
className="logo vanilla"
40
40
-
alt="Hey API logo"
41
41
-
/>
42
42
-
</a>
43
43
-
<h1 className="h1">@hey-api/openapi-ts 🤝 Axios</h1>
44
44
-
</div>
45
45
-
<div className="flex">
46
46
-
<button className="button" onClick={onFetchPet}>
47
47
-
Fetch random pet
48
48
-
</button>
49
49
-
<span className="pet-name">Fetched pet's name: {pet?.name}</span>
50
50
-
</div>
51
51
-
<div className="openapi-ts">
52
52
-
<code>{"import { $Pet } from './client/schemas.gen'"}</code>
53
53
-
<pre>{JSON.stringify($Pet, null, 2)}</pre>
54
54
-
</div>
55
55
-
</>
144
144
+
<Box
145
145
+
style={{ background: 'var(--gray-a2)', borderRadius: 'var(--radius-3)' }}
146
146
+
>
147
147
+
<Container size="1">
148
148
+
<Section size="1" />
149
149
+
<Flex align="center">
150
150
+
<a href="https://heyapi.vercel.app/" target="_blank">
151
151
+
<img
152
152
+
src="https://heyapi.vercel.app/logo.png"
153
153
+
className="logo vanilla"
154
154
+
alt="Hey API logo"
155
155
+
/>
156
156
+
</a>
157
157
+
<Heading>@hey-api/openapi-ts 🤝 Axios</Heading>
158
158
+
</Flex>
159
159
+
<Section size="1" />
160
160
+
<Flex direction="column" gapY="2">
161
161
+
<Box maxWidth="240px">
162
162
+
<Card>
163
163
+
<Flex gap="3" align="center">
164
164
+
<Avatar
165
165
+
size="3"
166
166
+
src={pet?.photoUrls[0]}
167
167
+
radius="full"
168
168
+
fallback={pet?.name.slice(0, 1) ?? 'N'}
169
169
+
/>
170
170
+
<Box>
171
171
+
<Text as="div" size="2" weight="bold">
172
172
+
Name: {pet?.name ?? 'N/A'}
173
173
+
</Text>
174
174
+
<Text as="div" size="2" color="gray">
175
175
+
Category: {pet?.category?.name ?? 'N/A'}
176
176
+
</Text>
177
177
+
</Box>
178
178
+
</Flex>
179
179
+
</Card>
180
180
+
</Box>
181
181
+
<Button onClick={onGetPetById}>
182
182
+
<DownloadIcon /> Get Random Pet
183
183
+
</Button>
184
184
+
</Flex>
185
185
+
<Section size="1" />
186
186
+
<Flex direction="column" gapY="2">
187
187
+
<Form.Root
188
188
+
className="w-[260px]"
189
189
+
onSubmit={(event) => {
190
190
+
event.preventDefault();
191
191
+
onAddPet(new FormData(event.currentTarget));
192
192
+
}}
193
193
+
>
194
194
+
<Form.Field className="grid mb-[10px]" name="email">
195
195
+
<div className="flex items-baseline justify-between">
196
196
+
<Form.Label className="text-[15px] font-medium leading-[35px] text-white">
197
197
+
Name
198
198
+
</Form.Label>
199
199
+
{isRequiredNameError && (
200
200
+
<Form.Message className="text-[13px] text-white opacity-[0.8]">
201
201
+
Please enter a name
202
202
+
</Form.Message>
203
203
+
)}
204
204
+
</div>
205
205
+
<Form.Control asChild>
206
206
+
<TextField.Root placeholder="Kitty" name="name" type="text" />
207
207
+
</Form.Control>
208
208
+
</Form.Field>
209
209
+
<Form.Field className="grid mb-[10px]" name="question">
210
210
+
<div className="flex items-baseline justify-between">
211
211
+
<Form.Label className="text-[15px] font-medium leading-[35px] text-white">
212
212
+
Category
213
213
+
</Form.Label>
214
214
+
<Form.Message
215
215
+
className="text-[13px] text-white opacity-[0.8]"
216
216
+
match="valueMissing"
217
217
+
>
218
218
+
Please enter a category
219
219
+
</Form.Message>
220
220
+
</div>
221
221
+
<Form.Control asChild>
222
222
+
<TextField.Root
223
223
+
placeholder="Cats"
224
224
+
name="category"
225
225
+
type="text"
226
226
+
required
227
227
+
/>
228
228
+
</Form.Control>
229
229
+
</Form.Field>
230
230
+
<Flex gapX="2">
231
231
+
<Form.Submit asChild>
232
232
+
<Button type="submit">
233
233
+
<PlusIcon /> Add Pet
234
234
+
</Button>
235
235
+
</Form.Submit>
236
236
+
<Button onClick={onUpdatePet} type="button">
237
237
+
<ReloadIcon /> Update Pet
238
238
+
</Button>
239
239
+
</Flex>
240
240
+
</Form.Root>
241
241
+
</Flex>
242
242
+
<Section size="1" />
243
243
+
</Container>
244
244
+
</Box>
56
245
);
57
246
}
58
247
+216
-422
examples/openapi-ts-axios/src/client/services.gen.ts
···
1
1
// This file is auto-generated by @hey-api/openapi-ts
2
2
3
3
-
import type { CancelablePromise } from '@hey-api/client-axios';
4
4
-
import { OpenAPI } from '@hey-api/client-axios';
5
5
-
import { request as __request } from '@hey-api/client-axios';
3
3
+
import { client, type Options } from '@hey-api/client-axios';
6
4
7
7
-
import type { $OpenApiTs } from './types.gen';
5
5
+
import type {
6
6
+
AddPetData,
7
7
+
AddPetError,
8
8
+
AddPetResponse,
9
9
+
CreateUserData,
10
10
+
CreateUserError,
11
11
+
CreateUserResponse,
12
12
+
CreateUsersWithListInputData,
13
13
+
CreateUsersWithListInputError,
14
14
+
CreateUsersWithListInputResponse,
15
15
+
DeleteOrderData,
16
16
+
DeletePetData,
17
17
+
DeleteUserData,
18
18
+
FindPetsByStatusData,
19
19
+
FindPetsByStatusError,
20
20
+
FindPetsByStatusResponse,
21
21
+
FindPetsByTagsData,
22
22
+
FindPetsByTagsError,
23
23
+
FindPetsByTagsResponse,
24
24
+
GetInventoryError,
25
25
+
GetInventoryResponse,
26
26
+
GetOrderByIdData,
27
27
+
GetOrderByIdError,
28
28
+
GetOrderByIdResponse,
29
29
+
GetPetByIdData,
30
30
+
GetPetByIdError,
31
31
+
GetPetByIdResponse,
32
32
+
GetUserByNameData,
33
33
+
GetUserByNameError,
34
34
+
GetUserByNameResponse,
35
35
+
LoginUserData,
36
36
+
LoginUserError,
37
37
+
LoginUserResponse,
38
38
+
LogoutUserError,
39
39
+
LogoutUserResponse,
40
40
+
PlaceOrderData,
41
41
+
PlaceOrderError,
42
42
+
PlaceOrderResponse,
43
43
+
UpdatePetData,
44
44
+
UpdatePetError,
45
45
+
UpdatePetResponse,
46
46
+
UpdatePetWithFormData,
47
47
+
UpdateUserData,
48
48
+
UpdateUserError,
49
49
+
UpdateUserResponse,
50
50
+
UploadFileData,
51
51
+
UploadFileError,
52
52
+
UploadFileResponse,
53
53
+
} from './types.gen';
8
54
9
9
-
export class PetService {
10
10
-
/**
11
11
-
* Add a new pet to the store
12
12
-
* Add a new pet to the store
13
13
-
* @param data The data for the request.
14
14
-
* @param data.requestBody Create a new pet in the store
15
15
-
* @returns Pet Successful operation
16
16
-
* @throws ApiError
17
17
-
*/
18
18
-
public static addPet(
19
19
-
data: $OpenApiTs['/pet']['post']['req'],
20
20
-
): CancelablePromise<$OpenApiTs['/pet']['post']['res'][200]> {
21
21
-
return __request(OpenAPI, {
22
22
-
body: data.requestBody,
23
23
-
errors: {
24
24
-
405: 'Invalid input',
25
25
-
},
26
26
-
mediaType: 'application/json',
27
27
-
method: 'POST',
28
28
-
url: '/pet',
29
29
-
});
30
30
-
}
55
55
+
/**
56
56
+
* Add a new pet to the store
57
57
+
* Add a new pet to the store
58
58
+
*/
59
59
+
export const addPet = (options: Options<AddPetData>) => (options?.client ?? client).post<AddPetResponse, AddPetError>({
60
60
+
...options,
61
61
+
url: '/pet',
62
62
+
});
31
63
32
32
-
/**
33
33
-
* Update an existing pet
34
34
-
* Update an existing pet by Id
35
35
-
* @param data The data for the request.
36
36
-
* @param data.requestBody Update an existent pet in the store
37
37
-
* @returns Pet Successful operation
38
38
-
* @throws ApiError
39
39
-
*/
40
40
-
public static updatePet(
41
41
-
data: $OpenApiTs['/pet']['put']['req'],
42
42
-
): CancelablePromise<$OpenApiTs['/pet']['put']['res'][200]> {
43
43
-
return __request(OpenAPI, {
44
44
-
body: data.requestBody,
45
45
-
errors: {
46
46
-
400: 'Invalid ID supplied',
47
47
-
404: 'Pet not found',
48
48
-
405: 'Validation exception',
49
49
-
},
50
50
-
mediaType: 'application/json',
51
51
-
method: 'PUT',
52
52
-
url: '/pet',
53
53
-
});
54
54
-
}
64
64
+
/**
65
65
+
* Update an existing pet
66
66
+
* Update an existing pet by Id
67
67
+
*/
68
68
+
export const updatePet = (options: Options<UpdatePetData>) => (options?.client ?? client).put<UpdatePetResponse, UpdatePetError>({
69
69
+
...options,
70
70
+
url: '/pet',
71
71
+
});
55
72
56
56
-
/**
57
57
-
* Finds Pets by status
58
58
-
* Multiple status values can be provided with comma separated strings
59
59
-
* @param data The data for the request.
60
60
-
* @param data.status Status values that need to be considered for filter
61
61
-
* @returns Pet successful operation
62
62
-
* @throws ApiError
63
63
-
*/
64
64
-
public static findPetsByStatus(
65
65
-
data: $OpenApiTs['/pet/findByStatus']['get']['req'] = {},
66
66
-
): CancelablePromise<$OpenApiTs['/pet/findByStatus']['get']['res'][200]> {
67
67
-
return __request(OpenAPI, {
68
68
-
errors: {
69
69
-
400: 'Invalid status value',
70
70
-
},
71
71
-
method: 'GET',
72
72
-
query: {
73
73
-
status: data.status,
74
74
-
},
75
75
-
url: '/pet/findByStatus',
76
76
-
});
77
77
-
}
73
73
+
/**
74
74
+
* Finds Pets by status
75
75
+
* Multiple status values can be provided with comma separated strings
76
76
+
*/
77
77
+
export const findPetsByStatus = (options?: Options<FindPetsByStatusData>) => (options?.client ?? client).get<
78
78
+
FindPetsByStatusResponse,
79
79
+
FindPetsByStatusError
80
80
+
>({
81
81
+
...options,
82
82
+
url: '/pet/findByStatus',
83
83
+
});
78
84
79
79
-
/**
80
80
-
* Finds Pets by tags
81
81
-
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
82
82
-
* @param data The data for the request.
83
83
-
* @param data.tags Tags to filter by
84
84
-
* @returns Pet successful operation
85
85
-
* @throws ApiError
86
86
-
*/
87
87
-
public static findPetsByTags(
88
88
-
data: $OpenApiTs['/pet/findByTags']['get']['req'] = {},
89
89
-
): CancelablePromise<$OpenApiTs['/pet/findByTags']['get']['res'][200]> {
90
90
-
return __request(OpenAPI, {
91
91
-
errors: {
92
92
-
400: 'Invalid tag value',
93
93
-
},
94
94
-
method: 'GET',
95
95
-
query: {
96
96
-
tags: data.tags,
97
97
-
},
98
98
-
url: '/pet/findByTags',
99
99
-
});
100
100
-
}
85
85
+
/**
86
86
+
* Finds Pets by tags
87
87
+
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
88
88
+
*/
89
89
+
export const findPetsByTags = (options?: Options<FindPetsByTagsData>) => (options?.client ?? client).get<
90
90
+
FindPetsByTagsResponse,
91
91
+
FindPetsByTagsError
92
92
+
>({
93
93
+
...options,
94
94
+
url: '/pet/findByTags',
95
95
+
});
101
96
102
102
-
/**
103
103
-
* Find pet by ID
104
104
-
* Returns a single pet
105
105
-
* @param data The data for the request.
106
106
-
* @param data.petId ID of pet to return
107
107
-
* @returns Pet successful operation
108
108
-
* @throws ApiError
109
109
-
*/
110
110
-
public static getPetById(
111
111
-
data: $OpenApiTs['/pet/{petId}']['get']['req'],
112
112
-
): CancelablePromise<$OpenApiTs['/pet/{petId}']['get']['res'][200]> {
113
113
-
return __request(OpenAPI, {
114
114
-
errors: {
115
115
-
400: 'Invalid ID supplied',
116
116
-
404: 'Pet not found',
117
117
-
},
118
118
-
method: 'GET',
119
119
-
path: {
120
120
-
petId: data.petId,
121
121
-
},
122
122
-
url: '/pet/{petId}',
123
123
-
});
124
124
-
}
97
97
+
/**
98
98
+
* Find pet by ID
99
99
+
* Returns a single pet
100
100
+
*/
101
101
+
export const getPetById = (options: Options<GetPetByIdData>) => (options?.client ?? client).get<GetPetByIdResponse, GetPetByIdError>({
102
102
+
...options,
103
103
+
url: '/pet/{petId}',
104
104
+
});
125
105
126
126
-
/**
127
127
-
* Updates a pet in the store with form data
128
128
-
* @param data The data for the request.
129
129
-
* @param data.petId ID of pet that needs to be updated
130
130
-
* @param data.name Name of pet that needs to be updated
131
131
-
* @param data.status Status of pet that needs to be updated
132
132
-
* @throws ApiError
133
133
-
*/
134
134
-
public static updatePetWithForm(
135
135
-
data: $OpenApiTs['/pet/{petId}']['post']['req'],
136
136
-
): CancelablePromise<void> {
137
137
-
return __request(OpenAPI, {
138
138
-
errors: {
139
139
-
405: 'Invalid input',
140
140
-
},
141
141
-
method: 'POST',
142
142
-
path: {
143
143
-
petId: data.petId,
144
144
-
},
145
145
-
query: {
146
146
-
name: data.name,
147
147
-
status: data.status,
148
148
-
},
149
149
-
url: '/pet/{petId}',
150
150
-
});
151
151
-
}
106
106
+
/**
107
107
+
* Updates a pet in the store with form data
108
108
+
*/
109
109
+
export const updatePetWithForm = (options: Options<UpdatePetWithFormData>) => (options?.client ?? client).post<void>({
110
110
+
...options,
111
111
+
url: '/pet/{petId}',
112
112
+
});
152
113
153
153
-
/**
154
154
-
* Deletes a pet
155
155
-
* @param data The data for the request.
156
156
-
* @param data.petId Pet id to delete
157
157
-
* @param data.apiKey
158
158
-
* @throws ApiError
159
159
-
*/
160
160
-
public static deletePet(
161
161
-
data: $OpenApiTs['/pet/{petId}']['delete']['req'],
162
162
-
): CancelablePromise<void> {
163
163
-
return __request(OpenAPI, {
164
164
-
errors: {
165
165
-
400: 'Invalid pet value',
166
166
-
},
167
167
-
headers: {
168
168
-
api_key: data.apiKey,
169
169
-
},
170
170
-
method: 'DELETE',
171
171
-
path: {
172
172
-
petId: data.petId,
173
173
-
},
174
174
-
url: '/pet/{petId}',
175
175
-
});
176
176
-
}
114
114
+
/**
115
115
+
* Deletes a pet
116
116
+
*/
117
117
+
export const deletePet = (options: Options<DeletePetData>) => (options?.client ?? client).delete<void>({
118
118
+
...options,
119
119
+
url: '/pet/{petId}',
120
120
+
});
177
121
178
178
-
/**
179
179
-
* uploads an image
180
180
-
* @param data The data for the request.
181
181
-
* @param data.petId ID of pet to update
182
182
-
* @param data.additionalMetadata Additional Metadata
183
183
-
* @param data.requestBody
184
184
-
* @returns ApiResponse successful operation
185
185
-
* @throws ApiError
186
186
-
*/
187
187
-
public static uploadFile(
188
188
-
data: $OpenApiTs['/pet/{petId}/uploadImage']['post']['req'],
189
189
-
): CancelablePromise<
190
190
-
$OpenApiTs['/pet/{petId}/uploadImage']['post']['res'][200]
191
191
-
> {
192
192
-
return __request(OpenAPI, {
193
193
-
body: data.requestBody,
194
194
-
mediaType: 'application/octet-stream',
195
195
-
method: 'POST',
196
196
-
path: {
197
197
-
petId: data.petId,
198
198
-
},
199
199
-
query: {
200
200
-
additionalMetadata: data.additionalMetadata,
201
201
-
},
202
202
-
url: '/pet/{petId}/uploadImage',
203
203
-
});
204
204
-
}
205
205
-
}
122
122
+
/**
123
123
+
* uploads an image
124
124
+
*/
125
125
+
export const uploadFile = (options: Options<UploadFileData>) => (options?.client ?? client).post<UploadFileResponse, UploadFileError>({
126
126
+
...options,
127
127
+
url: '/pet/{petId}/uploadImage',
128
128
+
});
206
129
207
207
-
export class StoreService {
208
208
-
/**
209
209
-
* Returns pet inventories by status
210
210
-
* Returns a map of status codes to quantities
211
211
-
* @returns number successful operation
212
212
-
* @throws ApiError
213
213
-
*/
214
214
-
public static getInventory(): CancelablePromise<
215
215
-
$OpenApiTs['/store/inventory']['get']['res'][200]
216
216
-
> {
217
217
-
return __request(OpenAPI, {
218
218
-
method: 'GET',
219
219
-
url: '/store/inventory',
220
220
-
});
221
221
-
}
130
130
+
/**
131
131
+
* Returns pet inventories by status
132
132
+
* Returns a map of status codes to quantities
133
133
+
*/
134
134
+
export const getInventory = (options?: Options) => (options?.client ?? client).get<
135
135
+
GetInventoryResponse,
136
136
+
GetInventoryError
137
137
+
>({
138
138
+
...options,
139
139
+
url: '/store/inventory',
140
140
+
});
222
141
223
223
-
/**
224
224
-
* Place an order for a pet
225
225
-
* Place a new order in the store
226
226
-
* @param data The data for the request.
227
227
-
* @param data.requestBody
228
228
-
* @returns Order successful operation
229
229
-
* @throws ApiError
230
230
-
*/
231
231
-
public static placeOrder(
232
232
-
data: $OpenApiTs['/store/order']['post']['req'] = {},
233
233
-
): CancelablePromise<$OpenApiTs['/store/order']['post']['res'][200]> {
234
234
-
return __request(OpenAPI, {
235
235
-
body: data.requestBody,
236
236
-
errors: {
237
237
-
405: 'Invalid input',
238
238
-
},
239
239
-
mediaType: 'application/json',
240
240
-
method: 'POST',
241
241
-
url: '/store/order',
242
242
-
});
243
243
-
}
142
142
+
/**
143
143
+
* Place an order for a pet
144
144
+
* Place a new order in the store
145
145
+
*/
146
146
+
export const placeOrder = (options?: Options<PlaceOrderData>) => (options?.client ?? client).post<PlaceOrderResponse, PlaceOrderError>({
147
147
+
...options,
148
148
+
url: '/store/order',
149
149
+
});
244
150
245
245
-
/**
246
246
-
* Find purchase order by ID
247
247
-
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
248
248
-
* @param data The data for the request.
249
249
-
* @param data.orderId ID of order that needs to be fetched
250
250
-
* @returns Order successful operation
251
251
-
* @throws ApiError
252
252
-
*/
253
253
-
public static getOrderById(
254
254
-
data: $OpenApiTs['/store/order/{orderId}']['get']['req'],
255
255
-
): CancelablePromise<
256
256
-
$OpenApiTs['/store/order/{orderId}']['get']['res'][200]
257
257
-
> {
258
258
-
return __request(OpenAPI, {
259
259
-
errors: {
260
260
-
400: 'Invalid ID supplied',
261
261
-
404: 'Order not found',
262
262
-
},
263
263
-
method: 'GET',
264
264
-
path: {
265
265
-
orderId: data.orderId,
266
266
-
},
267
267
-
url: '/store/order/{orderId}',
268
268
-
});
269
269
-
}
151
151
+
/**
152
152
+
* Find purchase order by ID
153
153
+
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
154
154
+
*/
155
155
+
export const getOrderById = (options: Options<GetOrderByIdData>) => (options?.client ?? client).get<
156
156
+
GetOrderByIdResponse,
157
157
+
GetOrderByIdError
158
158
+
>({
159
159
+
...options,
160
160
+
url: '/store/order/{orderId}',
161
161
+
});
270
162
271
271
-
/**
272
272
-
* Delete purchase order by ID
273
273
-
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
274
274
-
* @param data The data for the request.
275
275
-
* @param data.orderId ID of the order that needs to be deleted
276
276
-
* @throws ApiError
277
277
-
*/
278
278
-
public static deleteOrder(
279
279
-
data: $OpenApiTs['/store/order/{orderId}']['delete']['req'],
280
280
-
): CancelablePromise<void> {
281
281
-
return __request(OpenAPI, {
282
282
-
errors: {
283
283
-
400: 'Invalid ID supplied',
284
284
-
404: 'Order not found',
285
285
-
},
286
286
-
method: 'DELETE',
287
287
-
path: {
288
288
-
orderId: data.orderId,
289
289
-
},
290
290
-
url: '/store/order/{orderId}',
291
291
-
});
292
292
-
}
293
293
-
}
163
163
+
/**
164
164
+
* Delete purchase order by ID
165
165
+
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
166
166
+
*/
167
167
+
export const deleteOrder = (options: Options<DeleteOrderData>) => (options?.client ?? client).delete<void>({
168
168
+
...options,
169
169
+
url: '/store/order/{orderId}',
170
170
+
});
294
171
295
295
-
export class UserService {
296
296
-
/**
297
297
-
* Create user
298
298
-
* This can only be done by the logged in user.
299
299
-
* @param data The data for the request.
300
300
-
* @param data.requestBody Created user object
301
301
-
* @returns User successful operation
302
302
-
* @throws ApiError
303
303
-
*/
304
304
-
public static createUser(
305
305
-
data: $OpenApiTs['/user']['post']['req'] = {},
306
306
-
): CancelablePromise<$OpenApiTs['/user']['post']['res'][200]> {
307
307
-
return __request(OpenAPI, {
308
308
-
body: data.requestBody,
309
309
-
mediaType: 'application/json',
310
310
-
method: 'POST',
311
311
-
url: '/user',
312
312
-
});
313
313
-
}
172
172
+
/**
173
173
+
* Create user
174
174
+
* This can only be done by the logged in user.
175
175
+
*/
176
176
+
export const createUser = (options?: Options<CreateUserData>) => (options?.client ?? client).post<CreateUserResponse, CreateUserError>({
177
177
+
...options,
178
178
+
url: '/user',
179
179
+
});
314
180
315
315
-
/**
316
316
-
* Creates list of users with given input array
317
317
-
* Creates list of users with given input array
318
318
-
* @param data The data for the request.
319
319
-
* @param data.requestBody
320
320
-
* @returns User Successful operation
321
321
-
* @returns unknown successful operation
322
322
-
* @throws ApiError
323
323
-
*/
324
324
-
public static createUsersWithListInput(
325
325
-
data: $OpenApiTs['/user/createWithList']['post']['req'] = {},
326
326
-
): CancelablePromise<
327
327
-
| $OpenApiTs['/user/createWithList']['post']['res'][200]
328
328
-
| $OpenApiTs['/user/createWithList']['post']['res'][200]
329
329
-
> {
330
330
-
return __request(OpenAPI, {
331
331
-
body: data.requestBody,
332
332
-
mediaType: 'application/json',
333
333
-
method: 'POST',
334
334
-
url: '/user/createWithList',
335
335
-
});
336
336
-
}
181
181
+
/**
182
182
+
* Creates list of users with given input array
183
183
+
* Creates list of users with given input array
184
184
+
*/
185
185
+
export const createUsersWithListInput = (
186
186
+
options?: Options<CreateUsersWithListInputData>,
187
187
+
) => (options?.client ?? client).post<
188
188
+
CreateUsersWithListInputResponse,
189
189
+
CreateUsersWithListInputError
190
190
+
>({
191
191
+
...options,
192
192
+
url: '/user/createWithList',
193
193
+
});
337
194
338
338
-
/**
339
339
-
* Logs user into the system
340
340
-
* @param data The data for the request.
341
341
-
* @param data.username The user name for login
342
342
-
* @param data.password The password for login in clear text
343
343
-
* @returns string successful operation
344
344
-
* @throws ApiError
345
345
-
*/
346
346
-
public static loginUser(
347
347
-
data: $OpenApiTs['/user/login']['get']['req'] = {},
348
348
-
): CancelablePromise<$OpenApiTs['/user/login']['get']['res'][200]> {
349
349
-
return __request(OpenAPI, {
350
350
-
errors: {
351
351
-
400: 'Invalid username/password supplied',
352
352
-
},
353
353
-
method: 'GET',
354
354
-
query: {
355
355
-
password: data.password,
356
356
-
username: data.username,
357
357
-
},
358
358
-
url: '/user/login',
359
359
-
});
360
360
-
}
195
195
+
/**
196
196
+
* Logs user into the system
197
197
+
*/
198
198
+
export const loginUser = (options?: Options<LoginUserData>) => (options?.client ?? client).get<LoginUserResponse, LoginUserError>({
199
199
+
...options,
200
200
+
url: '/user/login',
201
201
+
});
361
202
362
362
-
/**
363
363
-
* Logs out current logged in user session
364
364
-
* @returns unknown successful operation
365
365
-
* @throws ApiError
366
366
-
*/
367
367
-
public static logoutUser(): CancelablePromise<
368
368
-
$OpenApiTs['/user/logout']['get']['res'][200]
369
369
-
> {
370
370
-
return __request(OpenAPI, {
371
371
-
method: 'GET',
372
372
-
url: '/user/logout',
373
373
-
});
374
374
-
}
203
203
+
/**
204
204
+
* Logs out current logged in user session
205
205
+
*/
206
206
+
export const logoutUser = (options?: Options) => (options?.client ?? client).get<LogoutUserResponse, LogoutUserError>({
207
207
+
...options,
208
208
+
url: '/user/logout',
209
209
+
});
375
210
376
376
-
/**
377
377
-
* Get user by user name
378
378
-
* @param data The data for the request.
379
379
-
* @param data.username The name that needs to be fetched. Use user1 for testing.
380
380
-
* @returns User successful operation
381
381
-
* @throws ApiError
382
382
-
*/
383
383
-
public static getUserByName(
384
384
-
data: $OpenApiTs['/user/{username}']['get']['req'],
385
385
-
): CancelablePromise<$OpenApiTs['/user/{username}']['get']['res'][200]> {
386
386
-
return __request(OpenAPI, {
387
387
-
errors: {
388
388
-
400: 'Invalid username supplied',
389
389
-
404: 'User not found',
390
390
-
},
391
391
-
method: 'GET',
392
392
-
path: {
393
393
-
username: data.username,
394
394
-
},
395
395
-
url: '/user/{username}',
396
396
-
});
397
397
-
}
211
211
+
/**
212
212
+
* Get user by user name
213
213
+
*/
214
214
+
export const getUserByName = (options: Options<GetUserByNameData>) => (options?.client ?? client).get<
215
215
+
GetUserByNameResponse,
216
216
+
GetUserByNameError
217
217
+
>({
218
218
+
...options,
219
219
+
url: '/user/{username}',
220
220
+
});
398
221
399
399
-
/**
400
400
-
* Update user
401
401
-
* This can only be done by the logged in user.
402
402
-
* @param data The data for the request.
403
403
-
* @param data.username name that needs to be updated
404
404
-
* @param data.requestBody Update an existent user in the store
405
405
-
* @returns unknown successful operation
406
406
-
* @throws ApiError
407
407
-
*/
408
408
-
public static updateUser(
409
409
-
data: $OpenApiTs['/user/{username}']['put']['req'],
410
410
-
): CancelablePromise<$OpenApiTs['/user/{username}']['put']['res'][200]> {
411
411
-
return __request(OpenAPI, {
412
412
-
body: data.requestBody,
413
413
-
mediaType: 'application/json',
414
414
-
method: 'PUT',
415
415
-
path: {
416
416
-
username: data.username,
417
417
-
},
418
418
-
url: '/user/{username}',
419
419
-
});
420
420
-
}
222
222
+
/**
223
223
+
* Update user
224
224
+
* This can only be done by the logged in user.
225
225
+
*/
226
226
+
export const updateUser = (options: Options<UpdateUserData>) => (options?.client ?? client).put<UpdateUserResponse, UpdateUserError>({
227
227
+
...options,
228
228
+
url: '/user/{username}',
229
229
+
});
421
230
422
422
-
/**
423
423
-
* Delete user
424
424
-
* This can only be done by the logged in user.
425
425
-
* @param data The data for the request.
426
426
-
* @param data.username The name that needs to be deleted
427
427
-
* @throws ApiError
428
428
-
*/
429
429
-
public static deleteUser(
430
430
-
data: $OpenApiTs['/user/{username}']['delete']['req'],
431
431
-
): CancelablePromise<void> {
432
432
-
return __request(OpenAPI, {
433
433
-
errors: {
434
434
-
400: 'Invalid username supplied',
435
435
-
404: 'User not found',
436
436
-
},
437
437
-
method: 'DELETE',
438
438
-
path: {
439
439
-
username: data.username,
440
440
-
},
441
441
-
url: '/user/{username}',
442
442
-
});
443
443
-
}
444
444
-
}
231
231
+
/**
232
232
+
* Delete user
233
233
+
* This can only be done by the logged in user.
234
234
+
*/
235
235
+
export const deleteUser = (options: Options<DeleteUserData>) => (options?.client ?? client).delete<void>({
236
236
+
...options,
237
237
+
url: '/user/{username}',
238
238
+
});
+311
-153
examples/openapi-ts-axios/src/client/types.gen.ts
···
12
12
complete?: boolean;
13
13
};
14
14
15
15
+
/**
16
16
+
* Order Status
17
17
+
*/
18
18
+
export type status = 'placed' | 'approved' | 'delivered';
19
19
+
20
20
+
/**
21
21
+
* Order Status
22
22
+
*/
23
23
+
export const status = {
24
24
+
APPROVED: 'approved',
25
25
+
DELIVERED: 'delivered',
26
26
+
PLACED: 'placed',
27
27
+
} as const;
28
28
+
15
29
export type Customer = {
16
30
id?: number;
17
31
username?: string;
···
61
75
status?: 'available' | 'pending' | 'sold';
62
76
};
63
77
78
78
+
/**
79
79
+
* pet status in the store
80
80
+
*/
81
81
+
export type status2 = 'available' | 'pending' | 'sold';
82
82
+
83
83
+
/**
84
84
+
* pet status in the store
85
85
+
*/
86
86
+
export const status2 = {
87
87
+
AVAILABLE: 'available',
88
88
+
PENDING: 'pending',
89
89
+
SOLD: 'sold',
90
90
+
} as const;
91
91
+
64
92
export type ApiResponse = {
65
93
code?: number;
66
94
type?: string;
67
95
message?: string;
68
96
};
69
97
98
98
+
export type AddPetData = {
99
99
+
/**
100
100
+
* Create a new pet in the store
101
101
+
*/
102
102
+
body: Pet;
103
103
+
};
104
104
+
105
105
+
export type AddPetResponse = Pet;
106
106
+
107
107
+
export type AddPetError = unknown;
108
108
+
109
109
+
export type UpdatePetData = {
110
110
+
/**
111
111
+
* Update an existent pet in the store
112
112
+
*/
113
113
+
body: Pet;
114
114
+
};
115
115
+
116
116
+
export type UpdatePetResponse = Pet;
117
117
+
118
118
+
export type UpdatePetError = unknown;
119
119
+
120
120
+
export type FindPetsByStatusData = {
121
121
+
query?: {
122
122
+
/**
123
123
+
* Status values that need to be considered for filter
124
124
+
*/
125
125
+
status?: 'available' | 'pending' | 'sold';
126
126
+
};
127
127
+
};
128
128
+
129
129
+
export type FindPetsByStatusResponse = Array<Pet>;
130
130
+
131
131
+
export type FindPetsByStatusError = unknown;
132
132
+
133
133
+
export type FindPetsByTagsData = {
134
134
+
query?: {
135
135
+
/**
136
136
+
* Tags to filter by
137
137
+
*/
138
138
+
tags?: Array<string>;
139
139
+
};
140
140
+
};
141
141
+
142
142
+
export type FindPetsByTagsResponse = Array<Pet>;
143
143
+
144
144
+
export type FindPetsByTagsError = unknown;
145
145
+
146
146
+
export type GetPetByIdData = {
147
147
+
path: {
148
148
+
/**
149
149
+
* ID of pet to return
150
150
+
*/
151
151
+
petId: number;
152
152
+
};
153
153
+
};
154
154
+
155
155
+
export type GetPetByIdResponse = Pet;
156
156
+
157
157
+
export type GetPetByIdError = unknown;
158
158
+
159
159
+
export type UpdatePetWithFormData = {
160
160
+
path: {
161
161
+
/**
162
162
+
* ID of pet that needs to be updated
163
163
+
*/
164
164
+
petId: number;
165
165
+
};
166
166
+
query?: {
167
167
+
/**
168
168
+
* Name of pet that needs to be updated
169
169
+
*/
170
170
+
name?: string;
171
171
+
/**
172
172
+
* Status of pet that needs to be updated
173
173
+
*/
174
174
+
status?: string;
175
175
+
};
176
176
+
};
177
177
+
178
178
+
export type DeletePetData = {
179
179
+
headers?: {
180
180
+
api_key?: string;
181
181
+
};
182
182
+
path: {
183
183
+
/**
184
184
+
* Pet id to delete
185
185
+
*/
186
186
+
petId: number;
187
187
+
};
188
188
+
};
189
189
+
190
190
+
export type UploadFileData = {
191
191
+
body?: Blob | File;
192
192
+
path: {
193
193
+
/**
194
194
+
* ID of pet to update
195
195
+
*/
196
196
+
petId: number;
197
197
+
};
198
198
+
query?: {
199
199
+
/**
200
200
+
* Additional Metadata
201
201
+
*/
202
202
+
additionalMetadata?: string;
203
203
+
};
204
204
+
};
205
205
+
206
206
+
export type UploadFileResponse = ApiResponse;
207
207
+
208
208
+
export type UploadFileError = unknown;
209
209
+
210
210
+
export type GetInventoryResponse = {
211
211
+
[key: string]: number;
212
212
+
};
213
213
+
214
214
+
export type GetInventoryError = unknown;
215
215
+
216
216
+
export type PlaceOrderData = {
217
217
+
body?: Order;
218
218
+
};
219
219
+
220
220
+
export type PlaceOrderResponse = Order;
221
221
+
222
222
+
export type PlaceOrderError = unknown;
223
223
+
224
224
+
export type GetOrderByIdData = {
225
225
+
path: {
226
226
+
/**
227
227
+
* ID of order that needs to be fetched
228
228
+
*/
229
229
+
orderId: number;
230
230
+
};
231
231
+
};
232
232
+
233
233
+
export type GetOrderByIdResponse = Order;
234
234
+
235
235
+
export type GetOrderByIdError = unknown;
236
236
+
237
237
+
export type DeleteOrderData = {
238
238
+
path: {
239
239
+
/**
240
240
+
* ID of the order that needs to be deleted
241
241
+
*/
242
242
+
orderId: number;
243
243
+
};
244
244
+
};
245
245
+
246
246
+
export type CreateUserData = {
247
247
+
/**
248
248
+
* Created user object
249
249
+
*/
250
250
+
body?: User;
251
251
+
};
252
252
+
253
253
+
export type CreateUserResponse = User;
254
254
+
255
255
+
export type CreateUserError = unknown;
256
256
+
257
257
+
export type CreateUsersWithListInputData = {
258
258
+
body?: Array<User>;
259
259
+
};
260
260
+
261
261
+
export type CreateUsersWithListInputResponse = User;
262
262
+
263
263
+
export type CreateUsersWithListInputError = unknown;
264
264
+
265
265
+
export type LoginUserData = {
266
266
+
query?: {
267
267
+
/**
268
268
+
* The password for login in clear text
269
269
+
*/
270
270
+
password?: string;
271
271
+
/**
272
272
+
* The user name for login
273
273
+
*/
274
274
+
username?: string;
275
275
+
};
276
276
+
};
277
277
+
278
278
+
export type LoginUserResponse = string;
279
279
+
280
280
+
export type LoginUserError = unknown;
281
281
+
282
282
+
export type LogoutUserResponse = unknown;
283
283
+
284
284
+
export type LogoutUserError = unknown;
285
285
+
286
286
+
export type GetUserByNameData = {
287
287
+
path: {
288
288
+
/**
289
289
+
* The name that needs to be fetched. Use user1 for testing.
290
290
+
*/
291
291
+
username: string;
292
292
+
};
293
293
+
};
294
294
+
295
295
+
export type GetUserByNameResponse = User;
296
296
+
297
297
+
export type GetUserByNameError = unknown;
298
298
+
299
299
+
export type UpdateUserData = {
300
300
+
/**
301
301
+
* Update an existent user in the store
302
302
+
*/
303
303
+
body?: User;
304
304
+
path: {
305
305
+
/**
306
306
+
* name that needs to be updated
307
307
+
*/
308
308
+
username: string;
309
309
+
};
310
310
+
};
311
311
+
312
312
+
export type UpdateUserResponse = unknown;
313
313
+
314
314
+
export type UpdateUserError = unknown;
315
315
+
316
316
+
export type DeleteUserData = {
317
317
+
path: {
318
318
+
/**
319
319
+
* The name that needs to be deleted
320
320
+
*/
321
321
+
username: string;
322
322
+
};
323
323
+
};
324
324
+
70
325
export type $OpenApiTs = {
71
326
'/pet': {
72
327
post: {
73
73
-
req: {
74
74
-
/**
75
75
-
* Create a new pet in the store
76
76
-
*/
77
77
-
requestBody: Pet;
78
78
-
};
328
328
+
req: AddPetData;
79
329
res: {
80
330
/**
81
331
* Successful operation
82
332
*/
83
83
-
200: Pet;
333
333
+
'200': Pet;
84
334
/**
85
335
* Invalid input
86
336
*/
87
87
-
405: unknown;
337
337
+
'405': unknown;
88
338
};
89
339
};
90
340
put: {
91
91
-
req: {
92
92
-
/**
93
93
-
* Update an existent pet in the store
94
94
-
*/
95
95
-
requestBody: Pet;
96
96
-
};
341
341
+
req: UpdatePetData;
97
342
res: {
98
343
/**
99
344
* Successful operation
100
345
*/
101
101
-
200: Pet;
346
346
+
'200': Pet;
102
347
/**
103
348
* Invalid ID supplied
104
349
*/
105
105
-
400: unknown;
350
350
+
'400': unknown;
106
351
/**
107
352
* Pet not found
108
353
*/
109
109
-
404: unknown;
354
354
+
'404': unknown;
110
355
/**
111
356
* Validation exception
112
357
*/
113
113
-
405: unknown;
358
358
+
'405': unknown;
114
359
};
115
360
};
116
361
};
117
362
'/pet/findByStatus': {
118
363
get: {
119
119
-
req: {
120
120
-
/**
121
121
-
* Status values that need to be considered for filter
122
122
-
*/
123
123
-
status?: 'available' | 'pending' | 'sold';
124
124
-
};
364
364
+
req: FindPetsByStatusData;
125
365
res: {
126
366
/**
127
367
* successful operation
128
368
*/
129
129
-
200: Array<Pet>;
369
369
+
'200': Array<Pet>;
130
370
/**
131
371
* Invalid status value
132
372
*/
133
133
-
400: unknown;
373
373
+
'400': unknown;
134
374
};
135
375
};
136
376
};
137
377
'/pet/findByTags': {
138
378
get: {
139
139
-
req: {
140
140
-
/**
141
141
-
* Tags to filter by
142
142
-
*/
143
143
-
tags?: Array<string>;
144
144
-
};
379
379
+
req: FindPetsByTagsData;
145
380
res: {
146
381
/**
147
382
* successful operation
148
383
*/
149
149
-
200: Array<Pet>;
384
384
+
'200': Array<Pet>;
150
385
/**
151
386
* Invalid tag value
152
387
*/
153
153
-
400: unknown;
388
388
+
'400': unknown;
154
389
};
155
390
};
156
391
};
157
392
'/pet/{petId}': {
158
393
get: {
159
159
-
req: {
160
160
-
/**
161
161
-
* ID of pet to return
162
162
-
*/
163
163
-
petId: number;
164
164
-
};
394
394
+
req: GetPetByIdData;
165
395
res: {
166
396
/**
167
397
* successful operation
168
398
*/
169
169
-
200: Pet;
399
399
+
'200': Pet;
170
400
/**
171
401
* Invalid ID supplied
172
402
*/
173
173
-
400: unknown;
403
403
+
'400': unknown;
174
404
/**
175
405
* Pet not found
176
406
*/
177
177
-
404: unknown;
407
407
+
'404': unknown;
178
408
};
179
409
};
180
410
post: {
181
181
-
req: {
182
182
-
/**
183
183
-
* Name of pet that needs to be updated
184
184
-
*/
185
185
-
name?: string;
186
186
-
/**
187
187
-
* ID of pet that needs to be updated
188
188
-
*/
189
189
-
petId: number;
190
190
-
/**
191
191
-
* Status of pet that needs to be updated
192
192
-
*/
193
193
-
status?: string;
194
194
-
};
411
411
+
req: UpdatePetWithFormData;
195
412
res: {
196
413
/**
197
414
* Invalid input
198
415
*/
199
199
-
405: unknown;
416
416
+
'405': unknown;
200
417
};
201
418
};
202
419
delete: {
203
203
-
req: {
204
204
-
apiKey?: string;
205
205
-
/**
206
206
-
* Pet id to delete
207
207
-
*/
208
208
-
petId: number;
209
209
-
};
420
420
+
req: DeletePetData;
210
421
res: {
211
422
/**
212
423
* Invalid pet value
213
424
*/
214
214
-
400: unknown;
425
425
+
'400': unknown;
215
426
};
216
427
};
217
428
};
218
429
'/pet/{petId}/uploadImage': {
219
430
post: {
220
220
-
req: {
221
221
-
/**
222
222
-
* Additional Metadata
223
223
-
*/
224
224
-
additionalMetadata?: string;
225
225
-
/**
226
226
-
* ID of pet to update
227
227
-
*/
228
228
-
petId: number;
229
229
-
requestBody?: Blob | File;
230
230
-
};
431
431
+
req: UploadFileData;
231
432
res: {
232
433
/**
233
434
* successful operation
234
435
*/
235
235
-
200: ApiResponse;
436
436
+
'200': ApiResponse;
236
437
};
237
438
};
238
439
};
···
242
443
/**
243
444
* successful operation
244
445
*/
245
245
-
200: {
446
446
+
'200': {
246
447
[key: string]: number;
247
448
};
248
449
};
···
250
451
};
251
452
'/store/order': {
252
453
post: {
253
253
-
req: {
254
254
-
requestBody?: Order;
255
255
-
};
454
454
+
req: PlaceOrderData;
256
455
res: {
257
456
/**
258
457
* successful operation
259
458
*/
260
260
-
200: Order;
459
459
+
'200': Order;
261
460
/**
262
461
* Invalid input
263
462
*/
264
264
-
405: unknown;
463
463
+
'405': unknown;
265
464
};
266
465
};
267
466
};
268
467
'/store/order/{orderId}': {
269
468
get: {
270
270
-
req: {
271
271
-
/**
272
272
-
* ID of order that needs to be fetched
273
273
-
*/
274
274
-
orderId: number;
275
275
-
};
469
469
+
req: GetOrderByIdData;
276
470
res: {
277
471
/**
278
472
* successful operation
279
473
*/
280
280
-
200: Order;
474
474
+
'200': Order;
281
475
/**
282
476
* Invalid ID supplied
283
477
*/
284
284
-
400: unknown;
478
478
+
'400': unknown;
285
479
/**
286
480
* Order not found
287
481
*/
288
288
-
404: unknown;
482
482
+
'404': unknown;
289
483
};
290
484
};
291
485
delete: {
292
292
-
req: {
293
293
-
/**
294
294
-
* ID of the order that needs to be deleted
295
295
-
*/
296
296
-
orderId: number;
297
297
-
};
486
486
+
req: DeleteOrderData;
298
487
res: {
299
488
/**
300
489
* Invalid ID supplied
301
490
*/
302
302
-
400: unknown;
491
491
+
'400': unknown;
303
492
/**
304
493
* Order not found
305
494
*/
306
306
-
404: unknown;
495
495
+
'404': unknown;
307
496
};
308
497
};
309
498
};
310
499
'/user': {
311
500
post: {
312
312
-
req: {
313
313
-
/**
314
314
-
* Created user object
315
315
-
*/
316
316
-
requestBody?: User;
317
317
-
};
501
501
+
req: CreateUserData;
318
502
res: {
319
503
/**
320
504
* successful operation
321
505
*/
322
322
-
200: User;
506
506
+
default: User;
323
507
};
324
508
};
325
509
};
326
510
'/user/createWithList': {
327
511
post: {
328
328
-
req: {
329
329
-
requestBody?: Array<User>;
330
330
-
};
512
512
+
req: CreateUsersWithListInputData;
331
513
res: {
332
514
/**
515
515
+
* Successful operation
516
516
+
*/
517
517
+
'200': User;
518
518
+
/**
333
519
* successful operation
334
520
*/
335
335
-
200: unknown;
521
521
+
default: unknown;
336
522
};
337
523
};
338
524
};
339
525
'/user/login': {
340
526
get: {
341
341
-
req: {
342
342
-
/**
343
343
-
* The password for login in clear text
344
344
-
*/
345
345
-
password?: string;
346
346
-
/**
347
347
-
* The user name for login
348
348
-
*/
349
349
-
username?: string;
350
350
-
};
527
527
+
req: LoginUserData;
351
528
res: {
352
529
/**
353
530
* successful operation
354
531
*/
355
355
-
200: string;
532
532
+
'200': string;
356
533
/**
357
534
* Invalid username/password supplied
358
535
*/
359
359
-
400: unknown;
536
536
+
'400': unknown;
360
537
};
361
538
};
362
539
};
···
366
543
/**
367
544
* successful operation
368
545
*/
369
369
-
200: unknown;
546
546
+
default: unknown;
370
547
};
371
548
};
372
549
};
373
550
'/user/{username}': {
374
551
get: {
375
375
-
req: {
376
376
-
/**
377
377
-
* The name that needs to be fetched. Use user1 for testing.
378
378
-
*/
379
379
-
username: string;
380
380
-
};
552
552
+
req: GetUserByNameData;
381
553
res: {
382
554
/**
383
555
* successful operation
384
556
*/
385
385
-
200: User;
557
557
+
'200': User;
386
558
/**
387
559
* Invalid username supplied
388
560
*/
389
389
-
400: unknown;
561
561
+
'400': unknown;
390
562
/**
391
563
* User not found
392
564
*/
393
393
-
404: unknown;
565
565
+
'404': unknown;
394
566
};
395
567
};
396
568
put: {
397
397
-
req: {
398
398
-
/**
399
399
-
* Update an existent user in the store
400
400
-
*/
401
401
-
requestBody?: User;
402
402
-
/**
403
403
-
* name that needs to be updated
404
404
-
*/
405
405
-
username: string;
406
406
-
};
569
569
+
req: UpdateUserData;
407
570
res: {
408
571
/**
409
572
* successful operation
410
573
*/
411
411
-
200: unknown;
574
574
+
default: unknown;
412
575
};
413
576
};
414
577
delete: {
415
415
-
req: {
416
416
-
/**
417
417
-
* The name that needs to be deleted
418
418
-
*/
419
419
-
username: string;
420
420
-
};
578
578
+
req: DeleteUserData;
421
579
res: {
422
580
/**
423
581
* Invalid username supplied
424
582
*/
425
425
-
400: unknown;
583
583
+
'400': unknown;
426
584
/**
427
585
* User not found
428
586
*/
429
429
-
404: unknown;
587
587
+
'404': unknown;
430
588
};
431
589
};
432
590
};
-68
examples/openapi-ts-axios/src/index.css
···
1
1
-
:root {
2
2
-
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3
3
-
line-height: 1.5;
4
4
-
font-weight: 400;
5
5
-
6
6
-
color-scheme: light dark;
7
7
-
color: rgba(255, 255, 255, 0.87);
8
8
-
background-color: #242424;
9
9
-
10
10
-
font-synthesis: none;
11
11
-
text-rendering: optimizeLegibility;
12
12
-
-webkit-font-smoothing: antialiased;
13
13
-
-moz-osx-font-smoothing: grayscale;
14
14
-
}
15
15
-
16
16
-
a {
17
17
-
font-weight: 500;
18
18
-
color: #646cff;
19
19
-
text-decoration: inherit;
20
20
-
}
21
21
-
a:hover {
22
22
-
color: #535bf2;
23
23
-
}
24
24
-
25
25
-
body {
26
26
-
margin: 0;
27
27
-
display: flex;
28
28
-
place-items: center;
29
29
-
min-width: 320px;
30
30
-
min-height: 100vh;
31
31
-
}
32
32
-
33
33
-
h1 {
34
34
-
font-size: 3.2em;
35
35
-
line-height: 1.1;
36
36
-
}
37
37
-
38
38
-
button {
39
39
-
border-radius: 8px;
40
40
-
border: 1px solid transparent;
41
41
-
padding: 0.6em 1.2em;
42
42
-
font-size: 1em;
43
43
-
font-weight: 500;
44
44
-
font-family: inherit;
45
45
-
background-color: #1a1a1a;
46
46
-
cursor: pointer;
47
47
-
transition: border-color 0.25s;
48
48
-
}
49
49
-
button:hover {
50
50
-
border-color: #646cff;
51
51
-
}
52
52
-
button:focus,
53
53
-
button:focus-visible {
54
54
-
outline: 4px auto -webkit-focus-ring-color;
55
55
-
}
56
56
-
57
57
-
@media (prefers-color-scheme: light) {
58
58
-
:root {
59
59
-
color: #213547;
60
60
-
background-color: #ffffff;
61
61
-
}
62
62
-
a:hover {
63
63
-
color: #747bff;
64
64
-
}
65
65
-
button {
66
66
-
background-color: #f9f9f9;
67
67
-
}
68
68
-
}
+5
-2
examples/openapi-ts-axios/src/main.tsx
···
1
1
-
import './index.css';
1
1
+
import '@radix-ui/themes/styles.css';
2
2
3
3
+
import { Theme } from '@radix-ui/themes';
3
4
import React from 'react';
4
5
import ReactDOM from 'react-dom/client';
5
6
···
7
8
8
9
ReactDOM.createRoot(document.getElementById('root')!).render(
9
10
<React.StrictMode>
10
10
-
<App />
11
11
+
<Theme appearance="dark">
12
12
+
<App />
13
13
+
</Theme>
11
14
</React.StrictMode>,
12
15
);
+8
examples/openapi-ts-axios/tailwind.config.js
···
1
1
+
/** @type {import('tailwindcss').Config} */
2
2
+
export default {
3
3
+
content: ['./index.html', './src/**/*.{html,js,ts,jsx,tsx}'],
4
4
+
plugins: [],
5
5
+
theme: {
6
6
+
extend: {},
7
7
+
},
8
8
+
};
+40
-22
pnpm-lock.yaml
···
87
87
'@hey-api/client-axios':
88
88
specifier: workspace:*
89
89
version: link:../../packages/client-axios
90
90
+
'@radix-ui/react-form':
91
91
+
specifier: 0.0.3
92
92
+
version: 0.0.3(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
93
93
+
'@radix-ui/react-icons':
94
94
+
specifier: 1.3.0
95
95
+
version: 1.3.0(react@18.3.1)
96
96
+
'@radix-ui/themes':
97
97
+
specifier: 3.0.5
98
98
+
version: 3.0.5(@types/react-dom@18.3.0)(@types/react@18.3.3)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)
90
99
axios:
91
100
specifier: 1.7.2
92
101
version: 1.7.2
···
115
124
'@vitejs/plugin-react':
116
125
specifier: 4.3.0
117
126
version: 4.3.0(vite@5.2.11(@types/node@20.12.12)(less@4.2.0)(sass@1.71.1)(terser@5.31.0))
127
127
+
autoprefixer:
128
128
+
specifier: 10.4.19
129
129
+
version: 10.4.19(postcss@8.4.38)
118
130
eslint:
119
131
specifier: 9.3.0
120
132
version: 9.3.0
···
124
136
eslint-plugin-react-refresh:
125
137
specifier: 0.4.7
126
138
version: 0.4.7(eslint@9.3.0)
139
139
+
postcss:
140
140
+
specifier: 8.4.38
141
141
+
version: 8.4.38
127
142
prettier:
128
143
specifier: 3.2.5
129
144
version: 3.2.5
145
145
+
tailwindcss:
146
146
+
specifier: 3.4.3
147
147
+
version: 3.4.3(ts-node@10.9.2(@types/node@20.12.12)(typescript@5.4.5))
130
148
typescript:
131
149
specifier: 5.4.5
132
150
version: 5.4.5
···
10624
10642
dom-serializer: 2.0.0
10625
10643
domhandler: 5.0.3
10626
10644
htmlparser2: 8.0.2
10627
10627
-
postcss: 8.4.35
10645
10645
+
postcss: 8.4.38
10628
10646
postcss-media-query-parser: 0.2.3
10629
10647
10630
10648
cross-spawn@5.1.0:
···
10641
10659
10642
10660
css-loader@6.10.0(webpack@5.90.3(esbuild@0.20.1)):
10643
10661
dependencies:
10644
10644
-
icss-utils: 5.1.0(postcss@8.4.35)
10645
10645
-
postcss: 8.4.35
10646
10646
-
postcss-modules-extract-imports: 3.1.0(postcss@8.4.35)
10647
10647
-
postcss-modules-local-by-default: 4.0.5(postcss@8.4.35)
10648
10648
-
postcss-modules-scope: 3.2.0(postcss@8.4.35)
10649
10649
-
postcss-modules-values: 4.0.0(postcss@8.4.35)
10662
10662
+
icss-utils: 5.1.0(postcss@8.4.38)
10663
10663
+
postcss: 8.4.38
10664
10664
+
postcss-modules-extract-imports: 3.1.0(postcss@8.4.38)
10665
10665
+
postcss-modules-local-by-default: 4.0.5(postcss@8.4.38)
10666
10666
+
postcss-modules-scope: 3.2.0(postcss@8.4.38)
10667
10667
+
postcss-modules-values: 4.0.0(postcss@8.4.38)
10650
10668
postcss-value-parser: 4.2.0
10651
10669
semver: 7.6.2
10652
10670
optionalDependencies:
···
11661
11679
dependencies:
11662
11680
safer-buffer: 2.1.2
11663
11681
11664
11664
-
icss-utils@5.1.0(postcss@8.4.35):
11682
11682
+
icss-utils@5.1.0(postcss@8.4.38):
11665
11683
dependencies:
11666
11666
-
postcss: 8.4.35
11684
11684
+
postcss: 8.4.38
11667
11685
11668
11686
ieee754@1.2.1: {}
11669
11687
···
12757
12775
12758
12776
postcss-media-query-parser@0.2.3: {}
12759
12777
12760
12760
-
postcss-modules-extract-imports@3.1.0(postcss@8.4.35):
12778
12778
+
postcss-modules-extract-imports@3.1.0(postcss@8.4.38):
12761
12779
dependencies:
12762
12762
-
postcss: 8.4.35
12780
12780
+
postcss: 8.4.38
12763
12781
12764
12764
-
postcss-modules-local-by-default@4.0.5(postcss@8.4.35):
12782
12782
+
postcss-modules-local-by-default@4.0.5(postcss@8.4.38):
12765
12783
dependencies:
12766
12766
-
icss-utils: 5.1.0(postcss@8.4.35)
12767
12767
-
postcss: 8.4.35
12784
12784
+
icss-utils: 5.1.0(postcss@8.4.38)
12785
12785
+
postcss: 8.4.38
12768
12786
postcss-selector-parser: 6.0.16
12769
12787
postcss-value-parser: 4.2.0
12770
12788
12771
12771
-
postcss-modules-scope@3.2.0(postcss@8.4.35):
12789
12789
+
postcss-modules-scope@3.2.0(postcss@8.4.38):
12772
12790
dependencies:
12773
12773
-
postcss: 8.4.35
12791
12791
+
postcss: 8.4.38
12774
12792
postcss-selector-parser: 6.0.16
12775
12793
12776
12776
-
postcss-modules-values@4.0.0(postcss@8.4.35):
12794
12794
+
postcss-modules-values@4.0.0(postcss@8.4.38):
12777
12795
dependencies:
12778
12778
-
icss-utils: 5.1.0(postcss@8.4.35)
12779
12779
-
postcss: 8.4.35
12796
12796
+
icss-utils: 5.1.0(postcss@8.4.38)
12797
12797
+
postcss: 8.4.38
12780
12798
12781
12799
postcss-nested@6.0.1(postcss@8.4.38):
12782
12800
dependencies:
···
13080
13098
adjust-sourcemap-loader: 4.0.0
13081
13099
convert-source-map: 1.9.0
13082
13100
loader-utils: 2.0.4
13083
13083
-
postcss: 8.4.35
13101
13101
+
postcss: 8.4.38
13084
13102
source-map: 0.6.1
13085
13103
13086
13104
resolve@1.22.8:
···
13580
13598
is-glob: 4.0.3
13581
13599
jiti: 1.21.0
13582
13600
lilconfig: 2.1.0
13583
13583
-
micromatch: 4.0.6
13601
13601
+
micromatch: 4.0.7
13584
13602
normalize-path: 3.0.0
13585
13603
object-hash: 3.0.0
13586
13604
picocolors: 1.0.1
···
13911
13929
vite@5.1.7(@types/node@20.12.12)(less@4.2.0)(sass@1.71.1)(terser@5.29.1):
13912
13930
dependencies:
13913
13931
esbuild: 0.19.12
13914
13914
-
postcss: 8.4.35
13932
13932
+
postcss: 8.4.38
13915
13933
rollup: 4.18.0
13916
13934
optionalDependencies:
13917
13935
'@types/node': 20.12.12