Skip to content

Commit 69ce916

Browse files
committed
feat(client-angular): enhance Angular client with resource generation and injectable services
1 parent f5efa9f commit 69ce916

File tree

5 files changed

+662
-3
lines changed

5 files changed

+662
-3
lines changed

examples/openapi-ts-angular/openapi-ts.config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ export default defineConfig({
1111
plugins: [
1212
'@hey-api/client-angular',
1313
'@hey-api/schemas',
14-
'@hey-api/sdk',
14+
{
15+
asClass: false,
16+
name: '@hey-api/sdk',
17+
},
1518
{
1619
enums: 'javascript',
1720
name: '@hey-api/typescript',
Lines changed: 263 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,263 @@
1+
// This file is auto-generated by @hey-api/openapi-ts
2+
3+
import { resource } from '@angular/core';
4+
5+
import type {
6+
AddPetData,
7+
CreateUserData,
8+
CreateUsersWithListInputData,
9+
DeleteOrderData,
10+
DeletePetData,
11+
DeleteUserData,
12+
FindPetsByStatusData,
13+
FindPetsByTagsData,
14+
GetInventoryData,
15+
GetOrderByIdData,
16+
GetPetByIdData,
17+
GetUserByNameData,
18+
LoginUserData,
19+
LogoutUserData,
20+
PlaceOrderData,
21+
UpdatePetData,
22+
UpdatePetWithFormData,
23+
UpdateUserData,
24+
UploadFileData,
25+
} from './types.gen';
26+
27+
/**
28+
* Add a new pet to the store.
29+
* Add a new pet to the store.
30+
*/
31+
export const addPetResource = (options: Omit<AddPetData, 'url'>) =>
32+
resource({
33+
loader: () => {
34+
throw new Error('Not implemented');
35+
},
36+
params: () => options,
37+
});
38+
39+
/**
40+
* Update an existing pet.
41+
* Update an existing pet by Id.
42+
*/
43+
export const updatePetResource = (options: Omit<UpdatePetData, 'url'>) =>
44+
resource({
45+
loader: () => {
46+
throw new Error('Not implemented');
47+
},
48+
params: () => options,
49+
});
50+
51+
/**
52+
* Finds Pets by status.
53+
* Multiple status values can be provided with comma separated strings.
54+
*/
55+
export const findPetsByStatusResource = (
56+
options: Omit<FindPetsByStatusData, 'url'>,
57+
) =>
58+
resource({
59+
loader: () => {
60+
throw new Error('Not implemented');
61+
},
62+
params: () => options,
63+
});
64+
65+
/**
66+
* Finds Pets by tags.
67+
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
68+
*/
69+
export const findPetsByTagsResource = (
70+
options: Omit<FindPetsByTagsData, 'url'>,
71+
) =>
72+
resource({
73+
loader: () => {
74+
throw new Error('Not implemented');
75+
},
76+
params: () => options,
77+
});
78+
79+
/**
80+
* Deletes a pet.
81+
* Delete a pet.
82+
*/
83+
export const deletePetResource = (options: Omit<DeletePetData, 'url'>) =>
84+
resource({
85+
loader: () => {
86+
throw new Error('Not implemented');
87+
},
88+
params: () => options,
89+
});
90+
91+
/**
92+
* Find pet by ID.
93+
* Returns a single pet.
94+
*/
95+
export const getPetByIdResource = (options: Omit<GetPetByIdData, 'url'>) =>
96+
resource({
97+
loader: () => {
98+
throw new Error('Not implemented');
99+
},
100+
params: () => options,
101+
});
102+
103+
/**
104+
* Updates a pet in the store with form data.
105+
* Updates a pet resource based on the form data.
106+
*/
107+
export const updatePetWithFormResource = (
108+
options: Omit<UpdatePetWithFormData, 'url'>,
109+
) =>
110+
resource({
111+
loader: () => {
112+
throw new Error('Not implemented');
113+
},
114+
params: () => options,
115+
});
116+
117+
/**
118+
* Uploads an image.
119+
* Upload image of the pet.
120+
*/
121+
export const uploadFileResource = (options: Omit<UploadFileData, 'url'>) =>
122+
resource({
123+
loader: () => {
124+
throw new Error('Not implemented');
125+
},
126+
params: () => options,
127+
});
128+
129+
/**
130+
* Returns pet inventories by status.
131+
* Returns a map of status codes to quantities.
132+
*/
133+
export const getInventoryResource = (options?: Omit<GetInventoryData, 'url'>) =>
134+
resource({
135+
loader: () => {
136+
throw new Error('Not implemented');
137+
},
138+
params: () => options,
139+
});
140+
141+
/**
142+
* Place an order for a pet.
143+
* Place a new order in the store.
144+
*/
145+
export const placeOrderResource = (options?: Omit<PlaceOrderData, 'url'>) =>
146+
resource({
147+
loader: () => {
148+
throw new Error('Not implemented');
149+
},
150+
params: () => options,
151+
});
152+
153+
/**
154+
* Delete purchase order by identifier.
155+
* For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors.
156+
*/
157+
export const deleteOrderResource = (options: Omit<DeleteOrderData, 'url'>) =>
158+
resource({
159+
loader: () => {
160+
throw new Error('Not implemented');
161+
},
162+
params: () => options,
163+
});
164+
165+
/**
166+
* Find purchase order by ID.
167+
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions.
168+
*/
169+
export const getOrderByIdResource = (options: Omit<GetOrderByIdData, 'url'>) =>
170+
resource({
171+
loader: () => {
172+
throw new Error('Not implemented');
173+
},
174+
params: () => options,
175+
});
176+
177+
/**
178+
* Create user.
179+
* This can only be done by the logged in user.
180+
*/
181+
export const createUserResource = (options?: Omit<CreateUserData, 'url'>) =>
182+
resource({
183+
loader: () => {
184+
throw new Error('Not implemented');
185+
},
186+
params: () => options,
187+
});
188+
189+
/**
190+
* Creates list of users with given input array.
191+
* Creates list of users with given input array.
192+
*/
193+
export const createUsersWithListInputResource = (
194+
options?: Omit<CreateUsersWithListInputData, 'url'>,
195+
) =>
196+
resource({
197+
loader: () => {
198+
throw new Error('Not implemented');
199+
},
200+
params: () => options,
201+
});
202+
203+
/**
204+
* Logs user into the system.
205+
* Log into the system.
206+
*/
207+
export const loginUserResource = (options?: Omit<LoginUserData, 'url'>) =>
208+
resource({
209+
loader: () => {
210+
throw new Error('Not implemented');
211+
},
212+
params: () => options,
213+
});
214+
215+
/**
216+
* Logs out current logged in user session.
217+
* Log user out of the system.
218+
*/
219+
export const logoutUserResource = (options?: Omit<LogoutUserData, 'url'>) =>
220+
resource({
221+
loader: () => {
222+
throw new Error('Not implemented');
223+
},
224+
params: () => options,
225+
});
226+
227+
/**
228+
* Delete user resource.
229+
* This can only be done by the logged in user.
230+
*/
231+
export const deleteUserResource = (options: Omit<DeleteUserData, 'url'>) =>
232+
resource({
233+
loader: () => {
234+
throw new Error('Not implemented');
235+
},
236+
params: () => options,
237+
});
238+
239+
/**
240+
* Get user by user name.
241+
* Get user detail based on username.
242+
*/
243+
export const getUserByNameResource = (
244+
options: Omit<GetUserByNameData, 'url'>,
245+
) =>
246+
resource({
247+
loader: () => {
248+
throw new Error('Not implemented');
249+
},
250+
params: () => options,
251+
});
252+
253+
/**
254+
* Update user resource.
255+
* This can only be done by the logged in user.
256+
*/
257+
export const updateUserResource = (options: Omit<UpdateUserData, 'url'>) =>
258+
resource({
259+
loader: () => {
260+
throw new Error('Not implemented');
261+
},
262+
params: () => options,
263+
});

packages/openapi-ts/src/plugins/@hey-api/client-angular/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { definePluginConfig } from '../../shared/utils/config';
22
import { clientDefaultConfig, clientDefaultMeta } from '../client-core/config';
3-
import { clientPluginHandler } from '../client-core/plugin';
3+
import { angularClientPluginHandler } from './plugin';
44
import type { HeyApiClientAngularPlugin } from './types';
55

66
export const defaultConfig: HeyApiClientAngularPlugin['Config'] = {
@@ -10,7 +10,7 @@ export const defaultConfig: HeyApiClientAngularPlugin['Config'] = {
1010
httpResource: false,
1111
throwOnError: false,
1212
},
13-
handler: clientPluginHandler as HeyApiClientAngularPlugin['Handler'],
13+
handler: angularClientPluginHandler,
1414
name: '@hey-api/client-angular',
1515
};
1616

0 commit comments

Comments
 (0)