fork of hey-api/openapi-ts because I need some additional things

feat: add @hey-api/angular-resource plugin with Angular resource generation

- Introduced the @hey-api/angular-resource plugin to facilitate Angular resource generation.
- Implemented configuration options for generating resources as classes or functions.
- Created necessary types and interfaces for the plugin.
- Developed the plugin handler to generate Angular services based on SDK operations.
- Added auto-generated resource methods for Pet, Store, and User entities.
- Updated the plugin configuration map to include the new angular-resource plugin.
- Removed deprecated httpResource option from the client-angular plugin.

Max Scopp fd6326a0 69ce916b

+1571 -682
+6 -1
examples/openapi-ts-angular/openapi-ts.config.ts
··· 10 10 }, 11 11 plugins: [ 12 12 '@hey-api/client-angular', 13 + '@tanstack/angular-query-experimental', 14 + { 15 + // asClass: true, 16 + name: '@hey-api/angular-resource', 17 + }, 13 18 '@hey-api/schemas', 14 19 { 15 - asClass: false, 20 + asClass: true, 16 21 name: '@hey-api/sdk', 17 22 }, 18 23 {
+289
examples/openapi-ts-angular/src/client/@hey-api/angular-resource.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { Injectable, resource } from '@angular/core'; 4 + 5 + import type { Options } from '../sdk.gen'; 6 + import { Pet, Store, User } from '../sdk.gen'; 7 + import type { 8 + AddPetData, 9 + CreateUserData, 10 + CreateUsersWithListInputData, 11 + DeleteOrderData, 12 + DeletePetData, 13 + DeleteUserData, 14 + FindPetsByStatusData, 15 + FindPetsByTagsData, 16 + GetInventoryData, 17 + GetOrderByIdData, 18 + GetPetByIdData, 19 + GetUserByNameData, 20 + LoginUserData, 21 + LogoutUserData, 22 + PlaceOrderData, 23 + UpdatePetData, 24 + UpdatePetWithFormData, 25 + UpdateUserData, 26 + UploadFileData, 27 + } from '../types.gen'; 28 + 29 + @Injectable({ 30 + providedIn: 'root', 31 + }) 32 + export class PetResource { 33 + /** 34 + * Add a new pet to the store. 35 + * Add a new pet to the store. 36 + */ 37 + public addPet<ThrowOnError extends boolean = false>( 38 + options: Options<AddPetData, ThrowOnError>, 39 + ) { 40 + return resource({ 41 + loader: async ({ params }) => Pet.addPet(params), 42 + params: () => options, 43 + }); 44 + } 45 + 46 + /** 47 + * Update an existing pet. 48 + * Update an existing pet by Id. 49 + */ 50 + public updatePet<ThrowOnError extends boolean = false>( 51 + options: Options<UpdatePetData, ThrowOnError>, 52 + ) { 53 + return resource({ 54 + loader: async ({ params }) => Pet.updatePet(params), 55 + params: () => options, 56 + }); 57 + } 58 + 59 + /** 60 + * Finds Pets by status. 61 + * Multiple status values can be provided with comma separated strings. 62 + */ 63 + public findPetsByStatus<ThrowOnError extends boolean = false>( 64 + options: Options<FindPetsByStatusData, ThrowOnError>, 65 + ) { 66 + return resource({ 67 + loader: async ({ params }) => Pet.findPetsByStatus(params), 68 + params: () => options, 69 + }); 70 + } 71 + 72 + /** 73 + * Finds Pets by tags. 74 + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. 75 + */ 76 + public findPetsByTags<ThrowOnError extends boolean = false>( 77 + options: Options<FindPetsByTagsData, ThrowOnError>, 78 + ) { 79 + return resource({ 80 + loader: async ({ params }) => Pet.findPetsByTags(params), 81 + params: () => options, 82 + }); 83 + } 84 + 85 + /** 86 + * Deletes a pet. 87 + * Delete a pet. 88 + */ 89 + public deletePet<ThrowOnError extends boolean = false>( 90 + options: Options<DeletePetData, ThrowOnError>, 91 + ) { 92 + return resource({ 93 + loader: async ({ params }) => Pet.deletePet(params), 94 + params: () => options, 95 + }); 96 + } 97 + 98 + /** 99 + * Find pet by ID. 100 + * Returns a single pet. 101 + */ 102 + public getPetById<ThrowOnError extends boolean = false>( 103 + options: Options<GetPetByIdData, ThrowOnError>, 104 + ) { 105 + return resource({ 106 + loader: async ({ params }) => Pet.getPetById(params), 107 + params: () => options, 108 + }); 109 + } 110 + 111 + /** 112 + * Updates a pet in the store with form data. 113 + * Updates a pet resource based on the form data. 114 + */ 115 + public updatePetWithForm<ThrowOnError extends boolean = false>( 116 + options: Options<UpdatePetWithFormData, ThrowOnError>, 117 + ) { 118 + return resource({ 119 + loader: async ({ params }) => Pet.updatePetWithForm(params), 120 + params: () => options, 121 + }); 122 + } 123 + 124 + /** 125 + * Uploads an image. 126 + * Upload image of the pet. 127 + */ 128 + public uploadFile<ThrowOnError extends boolean = false>( 129 + options: Options<UploadFileData, ThrowOnError>, 130 + ) { 131 + return resource({ 132 + loader: async ({ params }) => Pet.uploadFile(params), 133 + params: () => options, 134 + }); 135 + } 136 + } 137 + 138 + @Injectable({ 139 + providedIn: 'root', 140 + }) 141 + export class StoreResource { 142 + /** 143 + * Returns pet inventories by status. 144 + * Returns a map of status codes to quantities. 145 + */ 146 + public getInventory<ThrowOnError extends boolean = false>( 147 + options?: Options<GetInventoryData, ThrowOnError>, 148 + ) { 149 + return resource({ 150 + loader: async ({ params }) => Store.getInventory(params), 151 + params: () => options, 152 + }); 153 + } 154 + 155 + /** 156 + * Place an order for a pet. 157 + * Place a new order in the store. 158 + */ 159 + public placeOrder<ThrowOnError extends boolean = false>( 160 + options?: Options<PlaceOrderData, ThrowOnError>, 161 + ) { 162 + return resource({ 163 + loader: async ({ params }) => Store.placeOrder(params), 164 + params: () => options, 165 + }); 166 + } 167 + 168 + /** 169 + * Delete purchase order by identifier. 170 + * For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors. 171 + */ 172 + public deleteOrder<ThrowOnError extends boolean = false>( 173 + options: Options<DeleteOrderData, ThrowOnError>, 174 + ) { 175 + return resource({ 176 + loader: async ({ params }) => Store.deleteOrder(params), 177 + params: () => options, 178 + }); 179 + } 180 + 181 + /** 182 + * Find purchase order by ID. 183 + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions. 184 + */ 185 + public getOrderById<ThrowOnError extends boolean = false>( 186 + options: Options<GetOrderByIdData, ThrowOnError>, 187 + ) { 188 + return resource({ 189 + loader: async ({ params }) => Store.getOrderById(params), 190 + params: () => options, 191 + }); 192 + } 193 + } 194 + 195 + @Injectable({ 196 + providedIn: 'root', 197 + }) 198 + export class UserResource { 199 + /** 200 + * Create user. 201 + * This can only be done by the logged in user. 202 + */ 203 + public createUser<ThrowOnError extends boolean = false>( 204 + options?: Options<CreateUserData, ThrowOnError>, 205 + ) { 206 + return resource({ 207 + loader: async ({ params }) => User.createUser(params), 208 + params: () => options, 209 + }); 210 + } 211 + 212 + /** 213 + * Creates list of users with given input array. 214 + * Creates list of users with given input array. 215 + */ 216 + public createUsersWithListInput<ThrowOnError extends boolean = false>( 217 + options?: Options<CreateUsersWithListInputData, ThrowOnError>, 218 + ) { 219 + return resource({ 220 + loader: async ({ params }) => User.createUsersWithListInput(params), 221 + params: () => options, 222 + }); 223 + } 224 + 225 + /** 226 + * Logs user into the system. 227 + * Log into the system. 228 + */ 229 + public loginUser<ThrowOnError extends boolean = false>( 230 + options?: Options<LoginUserData, ThrowOnError>, 231 + ) { 232 + return resource({ 233 + loader: async ({ params }) => User.loginUser(params), 234 + params: () => options, 235 + }); 236 + } 237 + 238 + /** 239 + * Logs out current logged in user session. 240 + * Log user out of the system. 241 + */ 242 + public logoutUser<ThrowOnError extends boolean = false>( 243 + options?: Options<LogoutUserData, ThrowOnError>, 244 + ) { 245 + return resource({ 246 + loader: async ({ params }) => User.logoutUser(params), 247 + params: () => options, 248 + }); 249 + } 250 + 251 + /** 252 + * Delete user resource. 253 + * This can only be done by the logged in user. 254 + */ 255 + public deleteUser<ThrowOnError extends boolean = false>( 256 + options: Options<DeleteUserData, ThrowOnError>, 257 + ) { 258 + return resource({ 259 + loader: async ({ params }) => User.deleteUser(params), 260 + params: () => options, 261 + }); 262 + } 263 + 264 + /** 265 + * Get user by user name. 266 + * Get user detail based on username. 267 + */ 268 + public getUserByName<ThrowOnError extends boolean = false>( 269 + options: Options<GetUserByNameData, ThrowOnError>, 270 + ) { 271 + return resource({ 272 + loader: async ({ params }) => User.getUserByName(params), 273 + params: () => options, 274 + }); 275 + } 276 + 277 + /** 278 + * Update user resource. 279 + * This can only be done by the logged in user. 280 + */ 281 + public updateUser<ThrowOnError extends boolean = false>( 282 + options: Options<UpdateUserData, ThrowOnError>, 283 + ) { 284 + return resource({ 285 + loader: async ({ params }) => User.updateUser(params), 286 + params: () => options, 287 + }); 288 + } 289 + }
+666
examples/openapi-ts-angular/src/client/@tanstack/angular-query-experimental.gen.ts
··· 1 + // This file is auto-generated by @hey-api/openapi-ts 2 + 3 + import { 4 + type DefaultError, 5 + type MutationOptions, 6 + queryOptions, 7 + } from '@tanstack/angular-query-experimental'; 8 + 9 + import { client as _heyApiClient } from '../client.gen'; 10 + import { type Options, Pet, Store, User } from '../sdk.gen'; 11 + import type { 12 + AddPetData, 13 + AddPetResponse, 14 + CreateUserData, 15 + CreateUserResponse, 16 + CreateUsersWithListInputData, 17 + CreateUsersWithListInputResponse, 18 + DeleteOrderData, 19 + DeletePetData, 20 + DeleteUserData, 21 + FindPetsByStatusData, 22 + FindPetsByTagsData, 23 + GetInventoryData, 24 + GetOrderByIdData, 25 + GetPetByIdData, 26 + GetUserByNameData, 27 + LoginUserData, 28 + LogoutUserData, 29 + PlaceOrderData, 30 + PlaceOrderResponse, 31 + UpdatePetData, 32 + UpdatePetResponse, 33 + UpdatePetWithFormData, 34 + UpdatePetWithFormResponse, 35 + UpdateUserData, 36 + UploadFileData, 37 + UploadFileResponse, 38 + } from '../types.gen'; 39 + 40 + export type QueryKey<TOptions extends Options> = [ 41 + Pick<TOptions, 'baseUrl' | 'body' | 'headers' | 'path' | 'query'> & { 42 + _id: string; 43 + _infinite?: boolean; 44 + tags?: ReadonlyArray<string>; 45 + }, 46 + ]; 47 + 48 + const createQueryKey = <TOptions extends Options>( 49 + id: string, 50 + options?: TOptions, 51 + infinite?: boolean, 52 + tags?: ReadonlyArray<string>, 53 + ): [QueryKey<TOptions>[0]] => { 54 + const params: QueryKey<TOptions>[0] = { 55 + _id: id, 56 + baseUrl: 57 + options?.baseUrl || 58 + (options?.client ?? _heyApiClient).getConfig().baseUrl, 59 + } as QueryKey<TOptions>[0]; 60 + if (infinite) { 61 + params._infinite = infinite; 62 + } 63 + if (tags) { 64 + params.tags = tags; 65 + } 66 + if (options?.body) { 67 + params.body = options.body; 68 + } 69 + if (options?.headers) { 70 + params.headers = options.headers; 71 + } 72 + if (options?.path) { 73 + params.path = options.path; 74 + } 75 + if (options?.query) { 76 + params.query = options.query; 77 + } 78 + return [params]; 79 + }; 80 + 81 + export const addPetQueryKey = (options: Options<AddPetData>) => 82 + createQueryKey('addPet', options); 83 + 84 + /** 85 + * Add a new pet to the store. 86 + * Add a new pet to the store. 87 + */ 88 + export const addPetOptions = (options: Options<AddPetData>) => 89 + queryOptions({ 90 + queryFn: async ({ queryKey, signal }) => { 91 + const { data } = await Pet.addPet({ 92 + ...options, 93 + ...queryKey[0], 94 + signal, 95 + throwOnError: true, 96 + }); 97 + return data; 98 + }, 99 + queryKey: addPetQueryKey(options), 100 + }); 101 + 102 + /** 103 + * Add a new pet to the store. 104 + * Add a new pet to the store. 105 + */ 106 + export const addPetMutation = ( 107 + options?: Partial<Options<AddPetData>>, 108 + ): MutationOptions<AddPetResponse, DefaultError, Options<AddPetData>> => { 109 + const mutationOptions: MutationOptions< 110 + AddPetResponse, 111 + DefaultError, 112 + Options<AddPetData> 113 + > = { 114 + mutationFn: async (localOptions) => { 115 + const { data } = await Pet.addPet({ 116 + ...options, 117 + ...localOptions, 118 + throwOnError: true, 119 + }); 120 + return data; 121 + }, 122 + }; 123 + return mutationOptions; 124 + }; 125 + 126 + /** 127 + * Update an existing pet. 128 + * Update an existing pet by Id. 129 + */ 130 + export const updatePetMutation = ( 131 + options?: Partial<Options<UpdatePetData>>, 132 + ): MutationOptions<UpdatePetResponse, DefaultError, Options<UpdatePetData>> => { 133 + const mutationOptions: MutationOptions< 134 + UpdatePetResponse, 135 + DefaultError, 136 + Options<UpdatePetData> 137 + > = { 138 + mutationFn: async (localOptions) => { 139 + const { data } = await Pet.updatePet({ 140 + ...options, 141 + ...localOptions, 142 + throwOnError: true, 143 + }); 144 + return data; 145 + }, 146 + }; 147 + return mutationOptions; 148 + }; 149 + 150 + export const findPetsByStatusQueryKey = ( 151 + options: Options<FindPetsByStatusData>, 152 + ) => createQueryKey('findPetsByStatus', options); 153 + 154 + /** 155 + * Finds Pets by status. 156 + * Multiple status values can be provided with comma separated strings. 157 + */ 158 + export const findPetsByStatusOptions = ( 159 + options: Options<FindPetsByStatusData>, 160 + ) => 161 + queryOptions({ 162 + queryFn: async ({ queryKey, signal }) => { 163 + const { data } = await Pet.findPetsByStatus({ 164 + ...options, 165 + ...queryKey[0], 166 + signal, 167 + throwOnError: true, 168 + }); 169 + return data; 170 + }, 171 + queryKey: findPetsByStatusQueryKey(options), 172 + }); 173 + 174 + export const findPetsByTagsQueryKey = (options: Options<FindPetsByTagsData>) => 175 + createQueryKey('findPetsByTags', options); 176 + 177 + /** 178 + * Finds Pets by tags. 179 + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. 180 + */ 181 + export const findPetsByTagsOptions = (options: Options<FindPetsByTagsData>) => 182 + queryOptions({ 183 + queryFn: async ({ queryKey, signal }) => { 184 + const { data } = await Pet.findPetsByTags({ 185 + ...options, 186 + ...queryKey[0], 187 + signal, 188 + throwOnError: true, 189 + }); 190 + return data; 191 + }, 192 + queryKey: findPetsByTagsQueryKey(options), 193 + }); 194 + 195 + /** 196 + * Deletes a pet. 197 + * Delete a pet. 198 + */ 199 + export const deletePetMutation = ( 200 + options?: Partial<Options<DeletePetData>>, 201 + ): MutationOptions<unknown, DefaultError, Options<DeletePetData>> => { 202 + const mutationOptions: MutationOptions< 203 + unknown, 204 + DefaultError, 205 + Options<DeletePetData> 206 + > = { 207 + mutationFn: async (localOptions) => { 208 + const { data } = await Pet.deletePet({ 209 + ...options, 210 + ...localOptions, 211 + throwOnError: true, 212 + }); 213 + return data; 214 + }, 215 + }; 216 + return mutationOptions; 217 + }; 218 + 219 + export const getPetByIdQueryKey = (options: Options<GetPetByIdData>) => 220 + createQueryKey('getPetById', options); 221 + 222 + /** 223 + * Find pet by ID. 224 + * Returns a single pet. 225 + */ 226 + export const getPetByIdOptions = (options: Options<GetPetByIdData>) => 227 + queryOptions({ 228 + queryFn: async ({ queryKey, signal }) => { 229 + const { data } = await Pet.getPetById({ 230 + ...options, 231 + ...queryKey[0], 232 + signal, 233 + throwOnError: true, 234 + }); 235 + return data; 236 + }, 237 + queryKey: getPetByIdQueryKey(options), 238 + }); 239 + 240 + export const updatePetWithFormQueryKey = ( 241 + options: Options<UpdatePetWithFormData>, 242 + ) => createQueryKey('updatePetWithForm', options); 243 + 244 + /** 245 + * Updates a pet in the store with form data. 246 + * Updates a pet resource based on the form data. 247 + */ 248 + export const updatePetWithFormOptions = ( 249 + options: Options<UpdatePetWithFormData>, 250 + ) => 251 + queryOptions({ 252 + queryFn: async ({ queryKey, signal }) => { 253 + const { data } = await Pet.updatePetWithForm({ 254 + ...options, 255 + ...queryKey[0], 256 + signal, 257 + throwOnError: true, 258 + }); 259 + return data; 260 + }, 261 + queryKey: updatePetWithFormQueryKey(options), 262 + }); 263 + 264 + /** 265 + * Updates a pet in the store with form data. 266 + * Updates a pet resource based on the form data. 267 + */ 268 + export const updatePetWithFormMutation = ( 269 + options?: Partial<Options<UpdatePetWithFormData>>, 270 + ): MutationOptions< 271 + UpdatePetWithFormResponse, 272 + DefaultError, 273 + Options<UpdatePetWithFormData> 274 + > => { 275 + const mutationOptions: MutationOptions< 276 + UpdatePetWithFormResponse, 277 + DefaultError, 278 + Options<UpdatePetWithFormData> 279 + > = { 280 + mutationFn: async (localOptions) => { 281 + const { data } = await Pet.updatePetWithForm({ 282 + ...options, 283 + ...localOptions, 284 + throwOnError: true, 285 + }); 286 + return data; 287 + }, 288 + }; 289 + return mutationOptions; 290 + }; 291 + 292 + export const uploadFileQueryKey = (options: Options<UploadFileData>) => 293 + createQueryKey('uploadFile', options); 294 + 295 + /** 296 + * Uploads an image. 297 + * Upload image of the pet. 298 + */ 299 + export const uploadFileOptions = (options: Options<UploadFileData>) => 300 + queryOptions({ 301 + queryFn: async ({ queryKey, signal }) => { 302 + const { data } = await Pet.uploadFile({ 303 + ...options, 304 + ...queryKey[0], 305 + signal, 306 + throwOnError: true, 307 + }); 308 + return data; 309 + }, 310 + queryKey: uploadFileQueryKey(options), 311 + }); 312 + 313 + /** 314 + * Uploads an image. 315 + * Upload image of the pet. 316 + */ 317 + export const uploadFileMutation = ( 318 + options?: Partial<Options<UploadFileData>>, 319 + ): MutationOptions< 320 + UploadFileResponse, 321 + DefaultError, 322 + Options<UploadFileData> 323 + > => { 324 + const mutationOptions: MutationOptions< 325 + UploadFileResponse, 326 + DefaultError, 327 + Options<UploadFileData> 328 + > = { 329 + mutationFn: async (localOptions) => { 330 + const { data } = await Pet.uploadFile({ 331 + ...options, 332 + ...localOptions, 333 + throwOnError: true, 334 + }); 335 + return data; 336 + }, 337 + }; 338 + return mutationOptions; 339 + }; 340 + 341 + export const getInventoryQueryKey = (options?: Options<GetInventoryData>) => 342 + createQueryKey('getInventory', options); 343 + 344 + /** 345 + * Returns pet inventories by status. 346 + * Returns a map of status codes to quantities. 347 + */ 348 + export const getInventoryOptions = (options?: Options<GetInventoryData>) => 349 + queryOptions({ 350 + queryFn: async ({ queryKey, signal }) => { 351 + const { data } = await Store.getInventory({ 352 + ...options, 353 + ...queryKey[0], 354 + signal, 355 + throwOnError: true, 356 + }); 357 + return data; 358 + }, 359 + queryKey: getInventoryQueryKey(options), 360 + }); 361 + 362 + export const placeOrderQueryKey = (options?: Options<PlaceOrderData>) => 363 + createQueryKey('placeOrder', options); 364 + 365 + /** 366 + * Place an order for a pet. 367 + * Place a new order in the store. 368 + */ 369 + export const placeOrderOptions = (options?: Options<PlaceOrderData>) => 370 + queryOptions({ 371 + queryFn: async ({ queryKey, signal }) => { 372 + const { data } = await Store.placeOrder({ 373 + ...options, 374 + ...queryKey[0], 375 + signal, 376 + throwOnError: true, 377 + }); 378 + return data; 379 + }, 380 + queryKey: placeOrderQueryKey(options), 381 + }); 382 + 383 + /** 384 + * Place an order for a pet. 385 + * Place a new order in the store. 386 + */ 387 + export const placeOrderMutation = ( 388 + options?: Partial<Options<PlaceOrderData>>, 389 + ): MutationOptions< 390 + PlaceOrderResponse, 391 + DefaultError, 392 + Options<PlaceOrderData> 393 + > => { 394 + const mutationOptions: MutationOptions< 395 + PlaceOrderResponse, 396 + DefaultError, 397 + Options<PlaceOrderData> 398 + > = { 399 + mutationFn: async (localOptions) => { 400 + const { data } = await Store.placeOrder({ 401 + ...options, 402 + ...localOptions, 403 + throwOnError: true, 404 + }); 405 + return data; 406 + }, 407 + }; 408 + return mutationOptions; 409 + }; 410 + 411 + /** 412 + * Delete purchase order by identifier. 413 + * For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors. 414 + */ 415 + export const deleteOrderMutation = ( 416 + options?: Partial<Options<DeleteOrderData>>, 417 + ): MutationOptions<unknown, DefaultError, Options<DeleteOrderData>> => { 418 + const mutationOptions: MutationOptions< 419 + unknown, 420 + DefaultError, 421 + Options<DeleteOrderData> 422 + > = { 423 + mutationFn: async (localOptions) => { 424 + const { data } = await Store.deleteOrder({ 425 + ...options, 426 + ...localOptions, 427 + throwOnError: true, 428 + }); 429 + return data; 430 + }, 431 + }; 432 + return mutationOptions; 433 + }; 434 + 435 + export const getOrderByIdQueryKey = (options: Options<GetOrderByIdData>) => 436 + createQueryKey('getOrderById', options); 437 + 438 + /** 439 + * Find purchase order by ID. 440 + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions. 441 + */ 442 + export const getOrderByIdOptions = (options: Options<GetOrderByIdData>) => 443 + queryOptions({ 444 + queryFn: async ({ queryKey, signal }) => { 445 + const { data } = await Store.getOrderById({ 446 + ...options, 447 + ...queryKey[0], 448 + signal, 449 + throwOnError: true, 450 + }); 451 + return data; 452 + }, 453 + queryKey: getOrderByIdQueryKey(options), 454 + }); 455 + 456 + export const createUserQueryKey = (options?: Options<CreateUserData>) => 457 + createQueryKey('createUser', options); 458 + 459 + /** 460 + * Create user. 461 + * This can only be done by the logged in user. 462 + */ 463 + export const createUserOptions = (options?: Options<CreateUserData>) => 464 + queryOptions({ 465 + queryFn: async ({ queryKey, signal }) => { 466 + const { data } = await User.createUser({ 467 + ...options, 468 + ...queryKey[0], 469 + signal, 470 + throwOnError: true, 471 + }); 472 + return data; 473 + }, 474 + queryKey: createUserQueryKey(options), 475 + }); 476 + 477 + /** 478 + * Create user. 479 + * This can only be done by the logged in user. 480 + */ 481 + export const createUserMutation = ( 482 + options?: Partial<Options<CreateUserData>>, 483 + ): MutationOptions< 484 + CreateUserResponse, 485 + DefaultError, 486 + Options<CreateUserData> 487 + > => { 488 + const mutationOptions: MutationOptions< 489 + CreateUserResponse, 490 + DefaultError, 491 + Options<CreateUserData> 492 + > = { 493 + mutationFn: async (localOptions) => { 494 + const { data } = await User.createUser({ 495 + ...options, 496 + ...localOptions, 497 + throwOnError: true, 498 + }); 499 + return data; 500 + }, 501 + }; 502 + return mutationOptions; 503 + }; 504 + 505 + export const createUsersWithListInputQueryKey = ( 506 + options?: Options<CreateUsersWithListInputData>, 507 + ) => createQueryKey('createUsersWithListInput', options); 508 + 509 + /** 510 + * Creates list of users with given input array. 511 + * Creates list of users with given input array. 512 + */ 513 + export const createUsersWithListInputOptions = ( 514 + options?: Options<CreateUsersWithListInputData>, 515 + ) => 516 + queryOptions({ 517 + queryFn: async ({ queryKey, signal }) => { 518 + const { data } = await User.createUsersWithListInput({ 519 + ...options, 520 + ...queryKey[0], 521 + signal, 522 + throwOnError: true, 523 + }); 524 + return data; 525 + }, 526 + queryKey: createUsersWithListInputQueryKey(options), 527 + }); 528 + 529 + /** 530 + * Creates list of users with given input array. 531 + * Creates list of users with given input array. 532 + */ 533 + export const createUsersWithListInputMutation = ( 534 + options?: Partial<Options<CreateUsersWithListInputData>>, 535 + ): MutationOptions< 536 + CreateUsersWithListInputResponse, 537 + DefaultError, 538 + Options<CreateUsersWithListInputData> 539 + > => { 540 + const mutationOptions: MutationOptions< 541 + CreateUsersWithListInputResponse, 542 + DefaultError, 543 + Options<CreateUsersWithListInputData> 544 + > = { 545 + mutationFn: async (localOptions) => { 546 + const { data } = await User.createUsersWithListInput({ 547 + ...options, 548 + ...localOptions, 549 + throwOnError: true, 550 + }); 551 + return data; 552 + }, 553 + }; 554 + return mutationOptions; 555 + }; 556 + 557 + export const loginUserQueryKey = (options?: Options<LoginUserData>) => 558 + createQueryKey('loginUser', options); 559 + 560 + /** 561 + * Logs user into the system. 562 + * Log into the system. 563 + */ 564 + export const loginUserOptions = (options?: Options<LoginUserData>) => 565 + queryOptions({ 566 + queryFn: async ({ queryKey, signal }) => { 567 + const { data } = await User.loginUser({ 568 + ...options, 569 + ...queryKey[0], 570 + signal, 571 + throwOnError: true, 572 + }); 573 + return data; 574 + }, 575 + queryKey: loginUserQueryKey(options), 576 + }); 577 + 578 + export const logoutUserQueryKey = (options?: Options<LogoutUserData>) => 579 + createQueryKey('logoutUser', options); 580 + 581 + /** 582 + * Logs out current logged in user session. 583 + * Log user out of the system. 584 + */ 585 + export const logoutUserOptions = (options?: Options<LogoutUserData>) => 586 + queryOptions({ 587 + queryFn: async ({ queryKey, signal }) => { 588 + const { data } = await User.logoutUser({ 589 + ...options, 590 + ...queryKey[0], 591 + signal, 592 + throwOnError: true, 593 + }); 594 + return data; 595 + }, 596 + queryKey: logoutUserQueryKey(options), 597 + }); 598 + 599 + /** 600 + * Delete user resource. 601 + * This can only be done by the logged in user. 602 + */ 603 + export const deleteUserMutation = ( 604 + options?: Partial<Options<DeleteUserData>>, 605 + ): MutationOptions<unknown, DefaultError, Options<DeleteUserData>> => { 606 + const mutationOptions: MutationOptions< 607 + unknown, 608 + DefaultError, 609 + Options<DeleteUserData> 610 + > = { 611 + mutationFn: async (localOptions) => { 612 + const { data } = await User.deleteUser({ 613 + ...options, 614 + ...localOptions, 615 + throwOnError: true, 616 + }); 617 + return data; 618 + }, 619 + }; 620 + return mutationOptions; 621 + }; 622 + 623 + export const getUserByNameQueryKey = (options: Options<GetUserByNameData>) => 624 + createQueryKey('getUserByName', options); 625 + 626 + /** 627 + * Get user by user name. 628 + * Get user detail based on username. 629 + */ 630 + export const getUserByNameOptions = (options: Options<GetUserByNameData>) => 631 + queryOptions({ 632 + queryFn: async ({ queryKey, signal }) => { 633 + const { data } = await User.getUserByName({ 634 + ...options, 635 + ...queryKey[0], 636 + signal, 637 + throwOnError: true, 638 + }); 639 + return data; 640 + }, 641 + queryKey: getUserByNameQueryKey(options), 642 + }); 643 + 644 + /** 645 + * Update user resource. 646 + * This can only be done by the logged in user. 647 + */ 648 + export const updateUserMutation = ( 649 + options?: Partial<Options<UpdateUserData>>, 650 + ): MutationOptions<unknown, DefaultError, Options<UpdateUserData>> => { 651 + const mutationOptions: MutationOptions< 652 + unknown, 653 + DefaultError, 654 + Options<UpdateUserData> 655 + > = { 656 + mutationFn: async (localOptions) => { 657 + const { data } = await User.updateUser({ 658 + ...options, 659 + ...localOptions, 660 + throwOnError: true, 661 + }); 662 + return data; 663 + }, 664 + }; 665 + return mutationOptions; 666 + };
-263
examples/openapi-ts-angular/src/client/client.resource.gen.ts
··· 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 - });
+405 -369
examples/openapi-ts-angular/src/client/sdk.gen.ts
··· 1 1 // This file is auto-generated by @hey-api/openapi-ts 2 2 3 + import { Injectable } from '@angular/core'; 4 + 3 5 import type { Client, Options as ClientOptions, TDataShape } from './client'; 4 6 import { client as _heyApiClient } from './client.gen'; 5 7 import type { ··· 79 81 meta?: Record<string, unknown>; 80 82 }; 81 83 82 - /** 83 - * Add a new pet to the store. 84 - * Add a new pet to the store. 85 - */ 86 - export const addPet = <ThrowOnError extends boolean = false>( 87 - options: Options<AddPetData, ThrowOnError>, 88 - ) => 89 - (options.client ?? _heyApiClient).post< 90 - AddPetResponses, 91 - AddPetErrors, 92 - ThrowOnError 93 - >({ 94 - security: [ 95 - { 96 - scheme: 'bearer', 97 - type: 'http', 84 + @Injectable({ 85 + providedIn: 'root', 86 + }) 87 + export class Pet { 88 + /** 89 + * Add a new pet to the store. 90 + * Add a new pet to the store. 91 + */ 92 + public static addPet<ThrowOnError extends boolean = false>( 93 + options: Options<AddPetData, ThrowOnError>, 94 + ) { 95 + return (options.client ?? _heyApiClient).post< 96 + AddPetResponses, 97 + AddPetErrors, 98 + ThrowOnError 99 + >({ 100 + security: [ 101 + { 102 + scheme: 'bearer', 103 + type: 'http', 104 + }, 105 + ], 106 + url: '/pet', 107 + ...options, 108 + headers: { 109 + 'Content-Type': 'application/json', 110 + ...options.headers, 98 111 }, 99 - ], 100 - url: '/pet', 101 - ...options, 102 - headers: { 103 - 'Content-Type': 'application/json', 104 - ...options.headers, 105 - }, 106 - }); 112 + }); 113 + } 107 114 108 - /** 109 - * Update an existing pet. 110 - * Update an existing pet by Id. 111 - */ 112 - export const updatePet = <ThrowOnError extends boolean = false>( 113 - options: Options<UpdatePetData, ThrowOnError>, 114 - ) => 115 - (options.client ?? _heyApiClient).put< 116 - UpdatePetResponses, 117 - UpdatePetErrors, 118 - ThrowOnError 119 - >({ 120 - security: [ 121 - { 122 - scheme: 'bearer', 123 - type: 'http', 115 + /** 116 + * Update an existing pet. 117 + * Update an existing pet by Id. 118 + */ 119 + public static updatePet<ThrowOnError extends boolean = false>( 120 + options: Options<UpdatePetData, ThrowOnError>, 121 + ) { 122 + return (options.client ?? _heyApiClient).put< 123 + UpdatePetResponses, 124 + UpdatePetErrors, 125 + ThrowOnError 126 + >({ 127 + security: [ 128 + { 129 + scheme: 'bearer', 130 + type: 'http', 131 + }, 132 + ], 133 + url: '/pet', 134 + ...options, 135 + headers: { 136 + 'Content-Type': 'application/json', 137 + ...options.headers, 124 138 }, 125 - ], 126 - url: '/pet', 127 - ...options, 128 - headers: { 129 - 'Content-Type': 'application/json', 130 - ...options.headers, 131 - }, 132 - }); 139 + }); 140 + } 133 141 134 - /** 135 - * Finds Pets by status. 136 - * Multiple status values can be provided with comma separated strings. 137 - */ 138 - export const findPetsByStatus = <ThrowOnError extends boolean = false>( 139 - options: Options<FindPetsByStatusData, ThrowOnError>, 140 - ) => 141 - (options.client ?? _heyApiClient).get< 142 - FindPetsByStatusResponses, 143 - FindPetsByStatusErrors, 144 - ThrowOnError 145 - >({ 146 - security: [ 147 - { 148 - scheme: 'bearer', 149 - type: 'http', 150 - }, 151 - ], 152 - url: '/pet/findByStatus', 153 - ...options, 154 - }); 142 + /** 143 + * Finds Pets by status. 144 + * Multiple status values can be provided with comma separated strings. 145 + */ 146 + public static findPetsByStatus<ThrowOnError extends boolean = false>( 147 + options: Options<FindPetsByStatusData, ThrowOnError>, 148 + ) { 149 + return (options.client ?? _heyApiClient).get< 150 + FindPetsByStatusResponses, 151 + FindPetsByStatusErrors, 152 + ThrowOnError 153 + >({ 154 + security: [ 155 + { 156 + scheme: 'bearer', 157 + type: 'http', 158 + }, 159 + ], 160 + url: '/pet/findByStatus', 161 + ...options, 162 + }); 163 + } 155 164 156 - /** 157 - * Finds Pets by tags. 158 - * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. 159 - */ 160 - export const findPetsByTags = <ThrowOnError extends boolean = false>( 161 - options: Options<FindPetsByTagsData, ThrowOnError>, 162 - ) => 163 - (options.client ?? _heyApiClient).get< 164 - FindPetsByTagsResponses, 165 - FindPetsByTagsErrors, 166 - ThrowOnError 167 - >({ 168 - security: [ 169 - { 170 - scheme: 'bearer', 171 - type: 'http', 172 - }, 173 - ], 174 - url: '/pet/findByTags', 175 - ...options, 176 - }); 165 + /** 166 + * Finds Pets by tags. 167 + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. 168 + */ 169 + public static findPetsByTags<ThrowOnError extends boolean = false>( 170 + options: Options<FindPetsByTagsData, ThrowOnError>, 171 + ) { 172 + return (options.client ?? _heyApiClient).get< 173 + FindPetsByTagsResponses, 174 + FindPetsByTagsErrors, 175 + ThrowOnError 176 + >({ 177 + security: [ 178 + { 179 + scheme: 'bearer', 180 + type: 'http', 181 + }, 182 + ], 183 + url: '/pet/findByTags', 184 + ...options, 185 + }); 186 + } 177 187 178 - /** 179 - * Deletes a pet. 180 - * Delete a pet. 181 - */ 182 - export const deletePet = <ThrowOnError extends boolean = false>( 183 - options: Options<DeletePetData, ThrowOnError>, 184 - ) => 185 - (options.client ?? _heyApiClient).delete< 186 - DeletePetResponses, 187 - DeletePetErrors, 188 - ThrowOnError 189 - >({ 190 - security: [ 191 - { 192 - scheme: 'bearer', 193 - type: 'http', 194 - }, 195 - ], 196 - url: '/pet/{petId}', 197 - ...options, 198 - }); 188 + /** 189 + * Deletes a pet. 190 + * Delete a pet. 191 + */ 192 + public static deletePet<ThrowOnError extends boolean = false>( 193 + options: Options<DeletePetData, ThrowOnError>, 194 + ) { 195 + return (options.client ?? _heyApiClient).delete< 196 + DeletePetResponses, 197 + DeletePetErrors, 198 + ThrowOnError 199 + >({ 200 + security: [ 201 + { 202 + scheme: 'bearer', 203 + type: 'http', 204 + }, 205 + ], 206 + url: '/pet/{petId}', 207 + ...options, 208 + }); 209 + } 199 210 200 - /** 201 - * Find pet by ID. 202 - * Returns a single pet. 203 - */ 204 - export const getPetById = <ThrowOnError extends boolean = false>( 205 - options: Options<GetPetByIdData, ThrowOnError>, 206 - ) => 207 - (options.client ?? _heyApiClient).get< 208 - GetPetByIdResponses, 209 - GetPetByIdErrors, 210 - ThrowOnError 211 - >({ 212 - security: [ 213 - { 214 - name: 'api_key', 215 - type: 'apiKey', 216 - }, 217 - { 218 - scheme: 'bearer', 219 - type: 'http', 220 - }, 221 - ], 222 - url: '/pet/{petId}', 223 - ...options, 224 - }); 211 + /** 212 + * Find pet by ID. 213 + * Returns a single pet. 214 + */ 215 + public static getPetById<ThrowOnError extends boolean = false>( 216 + options: Options<GetPetByIdData, ThrowOnError>, 217 + ) { 218 + return (options.client ?? _heyApiClient).get< 219 + GetPetByIdResponses, 220 + GetPetByIdErrors, 221 + ThrowOnError 222 + >({ 223 + security: [ 224 + { 225 + name: 'api_key', 226 + type: 'apiKey', 227 + }, 228 + { 229 + scheme: 'bearer', 230 + type: 'http', 231 + }, 232 + ], 233 + url: '/pet/{petId}', 234 + ...options, 235 + }); 236 + } 225 237 226 - /** 227 - * Updates a pet in the store with form data. 228 - * Updates a pet resource based on the form data. 229 - */ 230 - export const updatePetWithForm = <ThrowOnError extends boolean = false>( 231 - options: Options<UpdatePetWithFormData, ThrowOnError>, 232 - ) => 233 - (options.client ?? _heyApiClient).post< 234 - UpdatePetWithFormResponses, 235 - UpdatePetWithFormErrors, 236 - ThrowOnError 237 - >({ 238 - security: [ 239 - { 240 - scheme: 'bearer', 241 - type: 'http', 242 - }, 243 - ], 244 - url: '/pet/{petId}', 245 - ...options, 246 - }); 238 + /** 239 + * Updates a pet in the store with form data. 240 + * Updates a pet resource based on the form data. 241 + */ 242 + public static updatePetWithForm<ThrowOnError extends boolean = false>( 243 + options: Options<UpdatePetWithFormData, ThrowOnError>, 244 + ) { 245 + return (options.client ?? _heyApiClient).post< 246 + UpdatePetWithFormResponses, 247 + UpdatePetWithFormErrors, 248 + ThrowOnError 249 + >({ 250 + security: [ 251 + { 252 + scheme: 'bearer', 253 + type: 'http', 254 + }, 255 + ], 256 + url: '/pet/{petId}', 257 + ...options, 258 + }); 259 + } 247 260 248 - /** 249 - * Uploads an image. 250 - * Upload image of the pet. 251 - */ 252 - export const uploadFile = <ThrowOnError extends boolean = false>( 253 - options: Options<UploadFileData, ThrowOnError>, 254 - ) => 255 - (options.client ?? _heyApiClient).post< 256 - UploadFileResponses, 257 - UploadFileErrors, 258 - ThrowOnError 259 - >({ 260 - bodySerializer: null, 261 - security: [ 262 - { 263 - scheme: 'bearer', 264 - type: 'http', 261 + /** 262 + * Uploads an image. 263 + * Upload image of the pet. 264 + */ 265 + public static uploadFile<ThrowOnError extends boolean = false>( 266 + options: Options<UploadFileData, ThrowOnError>, 267 + ) { 268 + return (options.client ?? _heyApiClient).post< 269 + UploadFileResponses, 270 + UploadFileErrors, 271 + ThrowOnError 272 + >({ 273 + bodySerializer: null, 274 + security: [ 275 + { 276 + scheme: 'bearer', 277 + type: 'http', 278 + }, 279 + ], 280 + url: '/pet/{petId}/uploadImage', 281 + ...options, 282 + headers: { 283 + 'Content-Type': 'application/octet-stream', 284 + ...options.headers, 265 285 }, 266 - ], 267 - url: '/pet/{petId}/uploadImage', 268 - ...options, 269 - headers: { 270 - 'Content-Type': 'application/octet-stream', 271 - ...options.headers, 272 - }, 273 - }); 286 + }); 287 + } 288 + } 274 289 275 - /** 276 - * Returns pet inventories by status. 277 - * Returns a map of status codes to quantities. 278 - */ 279 - export const getInventory = <ThrowOnError extends boolean = false>( 280 - options?: Options<GetInventoryData, ThrowOnError>, 281 - ) => 282 - (options?.client ?? _heyApiClient).get< 283 - GetInventoryResponses, 284 - GetInventoryErrors, 285 - ThrowOnError 286 - >({ 287 - security: [ 288 - { 289 - name: 'api_key', 290 - type: 'apiKey', 290 + @Injectable({ 291 + providedIn: 'root', 292 + }) 293 + export class Store { 294 + /** 295 + * Returns pet inventories by status. 296 + * Returns a map of status codes to quantities. 297 + */ 298 + public static getInventory<ThrowOnError extends boolean = false>( 299 + options?: Options<GetInventoryData, ThrowOnError>, 300 + ) { 301 + return (options?.client ?? _heyApiClient).get< 302 + GetInventoryResponses, 303 + GetInventoryErrors, 304 + ThrowOnError 305 + >({ 306 + security: [ 307 + { 308 + name: 'api_key', 309 + type: 'apiKey', 310 + }, 311 + ], 312 + url: '/store/inventory', 313 + ...options, 314 + }); 315 + } 316 + 317 + /** 318 + * Place an order for a pet. 319 + * Place a new order in the store. 320 + */ 321 + public static placeOrder<ThrowOnError extends boolean = false>( 322 + options?: Options<PlaceOrderData, ThrowOnError>, 323 + ) { 324 + return (options?.client ?? _heyApiClient).post< 325 + PlaceOrderResponses, 326 + PlaceOrderErrors, 327 + ThrowOnError 328 + >({ 329 + url: '/store/order', 330 + ...options, 331 + headers: { 332 + 'Content-Type': 'application/json', 333 + ...options?.headers, 291 334 }, 292 - ], 293 - url: '/store/inventory', 294 - ...options, 295 - }); 335 + }); 336 + } 296 337 297 - /** 298 - * Place an order for a pet. 299 - * Place a new order in the store. 300 - */ 301 - export const placeOrder = <ThrowOnError extends boolean = false>( 302 - options?: Options<PlaceOrderData, ThrowOnError>, 303 - ) => 304 - (options?.client ?? _heyApiClient).post< 305 - PlaceOrderResponses, 306 - PlaceOrderErrors, 307 - ThrowOnError 308 - >({ 309 - url: '/store/order', 310 - ...options, 311 - headers: { 312 - 'Content-Type': 'application/json', 313 - ...options?.headers, 314 - }, 315 - }); 338 + /** 339 + * Delete purchase order by identifier. 340 + * For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors. 341 + */ 342 + public static deleteOrder<ThrowOnError extends boolean = false>( 343 + options: Options<DeleteOrderData, ThrowOnError>, 344 + ) { 345 + return (options.client ?? _heyApiClient).delete< 346 + DeleteOrderResponses, 347 + DeleteOrderErrors, 348 + ThrowOnError 349 + >({ 350 + url: '/store/order/{orderId}', 351 + ...options, 352 + }); 353 + } 316 354 317 - /** 318 - * Delete purchase order by identifier. 319 - * For valid response try integer IDs with value < 1000. Anything above 1000 or non-integers will generate API errors. 320 - */ 321 - export const deleteOrder = <ThrowOnError extends boolean = false>( 322 - options: Options<DeleteOrderData, ThrowOnError>, 323 - ) => 324 - (options.client ?? _heyApiClient).delete< 325 - DeleteOrderResponses, 326 - DeleteOrderErrors, 327 - ThrowOnError 328 - >({ 329 - url: '/store/order/{orderId}', 330 - ...options, 331 - }); 355 + /** 356 + * Find purchase order by ID. 357 + * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions. 358 + */ 359 + public static getOrderById<ThrowOnError extends boolean = false>( 360 + options: Options<GetOrderByIdData, ThrowOnError>, 361 + ) { 362 + return (options.client ?? _heyApiClient).get< 363 + GetOrderByIdResponses, 364 + GetOrderByIdErrors, 365 + ThrowOnError 366 + >({ 367 + url: '/store/order/{orderId}', 368 + ...options, 369 + }); 370 + } 371 + } 332 372 333 - /** 334 - * Find purchase order by ID. 335 - * For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions. 336 - */ 337 - export const getOrderById = <ThrowOnError extends boolean = false>( 338 - options: Options<GetOrderByIdData, ThrowOnError>, 339 - ) => 340 - (options.client ?? _heyApiClient).get< 341 - GetOrderByIdResponses, 342 - GetOrderByIdErrors, 343 - ThrowOnError 344 - >({ 345 - url: '/store/order/{orderId}', 346 - ...options, 347 - }); 373 + @Injectable({ 374 + providedIn: 'root', 375 + }) 376 + export class User { 377 + /** 378 + * Create user. 379 + * This can only be done by the logged in user. 380 + */ 381 + public static createUser<ThrowOnError extends boolean = false>( 382 + options?: Options<CreateUserData, ThrowOnError>, 383 + ) { 384 + return (options?.client ?? _heyApiClient).post< 385 + CreateUserResponses, 386 + CreateUserErrors, 387 + ThrowOnError 388 + >({ 389 + url: '/user', 390 + ...options, 391 + headers: { 392 + 'Content-Type': 'application/json', 393 + ...options?.headers, 394 + }, 395 + }); 396 + } 348 397 349 - /** 350 - * Create user. 351 - * This can only be done by the logged in user. 352 - */ 353 - export const createUser = <ThrowOnError extends boolean = false>( 354 - options?: Options<CreateUserData, ThrowOnError>, 355 - ) => 356 - (options?.client ?? _heyApiClient).post< 357 - CreateUserResponses, 358 - CreateUserErrors, 359 - ThrowOnError 360 - >({ 361 - url: '/user', 362 - ...options, 363 - headers: { 364 - 'Content-Type': 'application/json', 365 - ...options?.headers, 366 - }, 367 - }); 398 + /** 399 + * Creates list of users with given input array. 400 + * Creates list of users with given input array. 401 + */ 402 + public static createUsersWithListInput<ThrowOnError extends boolean = false>( 403 + options?: Options<CreateUsersWithListInputData, ThrowOnError>, 404 + ) { 405 + return (options?.client ?? _heyApiClient).post< 406 + CreateUsersWithListInputResponses, 407 + CreateUsersWithListInputErrors, 408 + ThrowOnError 409 + >({ 410 + url: '/user/createWithList', 411 + ...options, 412 + headers: { 413 + 'Content-Type': 'application/json', 414 + ...options?.headers, 415 + }, 416 + }); 417 + } 368 418 369 - /** 370 - * Creates list of users with given input array. 371 - * Creates list of users with given input array. 372 - */ 373 - export const createUsersWithListInput = <ThrowOnError extends boolean = false>( 374 - options?: Options<CreateUsersWithListInputData, ThrowOnError>, 375 - ) => 376 - (options?.client ?? _heyApiClient).post< 377 - CreateUsersWithListInputResponses, 378 - CreateUsersWithListInputErrors, 379 - ThrowOnError 380 - >({ 381 - url: '/user/createWithList', 382 - ...options, 383 - headers: { 384 - 'Content-Type': 'application/json', 385 - ...options?.headers, 386 - }, 387 - }); 419 + /** 420 + * Logs user into the system. 421 + * Log into the system. 422 + */ 423 + public static loginUser<ThrowOnError extends boolean = false>( 424 + options?: Options<LoginUserData, ThrowOnError>, 425 + ) { 426 + return (options?.client ?? _heyApiClient).get< 427 + LoginUserResponses, 428 + LoginUserErrors, 429 + ThrowOnError 430 + >({ 431 + url: '/user/login', 432 + ...options, 433 + }); 434 + } 388 435 389 - /** 390 - * Logs user into the system. 391 - * Log into the system. 392 - */ 393 - export const loginUser = <ThrowOnError extends boolean = false>( 394 - options?: Options<LoginUserData, ThrowOnError>, 395 - ) => 396 - (options?.client ?? _heyApiClient).get< 397 - LoginUserResponses, 398 - LoginUserErrors, 399 - ThrowOnError 400 - >({ 401 - url: '/user/login', 402 - ...options, 403 - }); 436 + /** 437 + * Logs out current logged in user session. 438 + * Log user out of the system. 439 + */ 440 + public static logoutUser<ThrowOnError extends boolean = false>( 441 + options?: Options<LogoutUserData, ThrowOnError>, 442 + ) { 443 + return (options?.client ?? _heyApiClient).get< 444 + LogoutUserResponses, 445 + LogoutUserErrors, 446 + ThrowOnError 447 + >({ 448 + url: '/user/logout', 449 + ...options, 450 + }); 451 + } 404 452 405 - /** 406 - * Logs out current logged in user session. 407 - * Log user out of the system. 408 - */ 409 - export const logoutUser = <ThrowOnError extends boolean = false>( 410 - options?: Options<LogoutUserData, ThrowOnError>, 411 - ) => 412 - (options?.client ?? _heyApiClient).get< 413 - LogoutUserResponses, 414 - LogoutUserErrors, 415 - ThrowOnError 416 - >({ 417 - url: '/user/logout', 418 - ...options, 419 - }); 453 + /** 454 + * Delete user resource. 455 + * This can only be done by the logged in user. 456 + */ 457 + public static deleteUser<ThrowOnError extends boolean = false>( 458 + options: Options<DeleteUserData, ThrowOnError>, 459 + ) { 460 + return (options.client ?? _heyApiClient).delete< 461 + DeleteUserResponses, 462 + DeleteUserErrors, 463 + ThrowOnError 464 + >({ 465 + url: '/user/{username}', 466 + ...options, 467 + }); 468 + } 420 469 421 - /** 422 - * Delete user resource. 423 - * This can only be done by the logged in user. 424 - */ 425 - export const deleteUser = <ThrowOnError extends boolean = false>( 426 - options: Options<DeleteUserData, ThrowOnError>, 427 - ) => 428 - (options.client ?? _heyApiClient).delete< 429 - DeleteUserResponses, 430 - DeleteUserErrors, 431 - ThrowOnError 432 - >({ 433 - url: '/user/{username}', 434 - ...options, 435 - }); 436 - 437 - /** 438 - * Get user by user name. 439 - * Get user detail based on username. 440 - */ 441 - export const getUserByName = <ThrowOnError extends boolean = false>( 442 - options: Options<GetUserByNameData, ThrowOnError>, 443 - ) => 444 - (options.client ?? _heyApiClient).get< 445 - GetUserByNameResponses, 446 - GetUserByNameErrors, 447 - ThrowOnError 448 - >({ 449 - url: '/user/{username}', 450 - ...options, 451 - }); 470 + /** 471 + * Get user by user name. 472 + * Get user detail based on username. 473 + */ 474 + public static getUserByName<ThrowOnError extends boolean = false>( 475 + options: Options<GetUserByNameData, ThrowOnError>, 476 + ) { 477 + return (options.client ?? _heyApiClient).get< 478 + GetUserByNameResponses, 479 + GetUserByNameErrors, 480 + ThrowOnError 481 + >({ 482 + url: '/user/{username}', 483 + ...options, 484 + }); 485 + } 452 486 453 - /** 454 - * Update user resource. 455 - * This can only be done by the logged in user. 456 - */ 457 - export const updateUser = <ThrowOnError extends boolean = false>( 458 - options: Options<UpdateUserData, ThrowOnError>, 459 - ) => 460 - (options.client ?? _heyApiClient).put< 461 - UpdateUserResponses, 462 - UpdateUserErrors, 463 - ThrowOnError 464 - >({ 465 - url: '/user/{username}', 466 - ...options, 467 - headers: { 468 - 'Content-Type': 'application/json', 469 - ...options.headers, 470 - }, 471 - }); 487 + /** 488 + * Update user resource. 489 + * This can only be done by the logged in user. 490 + */ 491 + public static updateUser<ThrowOnError extends boolean = false>( 492 + options: Options<UpdateUserData, ThrowOnError>, 493 + ) { 494 + return (options.client ?? _heyApiClient).put< 495 + UpdateUserResponses, 496 + UpdateUserErrors, 497 + ThrowOnError 498 + >({ 499 + url: '/user/{username}', 500 + ...options, 501 + headers: { 502 + 'Content-Type': 'application/json', 503 + ...options.headers, 504 + }, 505 + }); 506 + } 507 + }
+22
packages/openapi-ts/src/plugins/@hey-api/angular-resource/config.ts
··· 1 + import { definePluginConfig } from '../../shared/utils/config'; 2 + import { angularResourcePluginHandler } from './plugin'; 3 + import type { HeyApiAngularResourcePlugin } from './types'; 4 + 5 + export const defaultConfig: HeyApiAngularResourcePlugin['Config'] = { 6 + config: { 7 + asClass: false, 8 + }, 9 + dependencies: [ 10 + '@hey-api/client-angular', 11 + '@hey-api/sdk', 12 + '@hey-api/typescript', 13 + ], 14 + handler: angularResourcePluginHandler, 15 + name: '@hey-api/angular-resource', 16 + output: '@hey-api/angular-resource', 17 + }; 18 + 19 + /** 20 + * Type helper for `@hey-api/angular-resource` plugin, returns {@link Plugin.Config} object 21 + */ 22 + export const defineConfig = definePluginConfig(defaultConfig);
+2
packages/openapi-ts/src/plugins/@hey-api/angular-resource/index.ts
··· 1 + export { defaultConfig, defineConfig } from './config'; 2 + export type { HeyApiAngularResourcePlugin } from './types';
+33
packages/openapi-ts/src/plugins/@hey-api/angular-resource/types.d.ts
··· 1 + import type { DefinePlugin, Plugin } from '../../types'; 2 + 3 + export type UserConfig = Plugin.Name<'@hey-api/angular-resource'> & { 4 + /** 5 + * Whether to generate the resource as a class. 6 + * @default false 7 + */ 8 + asClass?: boolean; 9 + 10 + /** 11 + * Name of the generated file. 12 + * 13 + * @default 'httpResource' 14 + */ 15 + output?: string; 16 + }; 17 + 18 + export type Config = Plugin.Name<'@hey-api/angular-resource'> & { 19 + /** 20 + * Whether to generate the resource as a class. 21 + * @default false 22 + */ 23 + asClass: boolean; 24 + 25 + /** 26 + * Name of the generated file. 27 + * 28 + * @default 'httpResource' 29 + */ 30 + output?: string; 31 + }; 32 + 33 + export type HeyApiAngularResourcePlugin = DefinePlugin<UserConfig, Config>;
+2 -3
packages/openapi-ts/src/plugins/@hey-api/client-angular/config.ts
··· 1 1 import { definePluginConfig } from '../../shared/utils/config'; 2 2 import { clientDefaultConfig, clientDefaultMeta } from '../client-core/config'; 3 - import { angularClientPluginHandler } from './plugin'; 3 + import { clientPluginHandler } from '../client-core/plugin'; 4 4 import type { HeyApiClientAngularPlugin } from './types'; 5 5 6 6 export const defaultConfig: HeyApiClientAngularPlugin['Config'] = { 7 7 ...clientDefaultMeta, 8 8 config: { 9 9 ...clientDefaultConfig, 10 - httpResource: false, 11 10 throwOnError: false, 12 11 }, 13 - handler: angularClientPluginHandler, 12 + handler: clientPluginHandler as HeyApiClientAngularPlugin['Handler'], 14 13 name: '@hey-api/client-angular', 15 14 }; 16 15
+141 -41
packages/openapi-ts/src/plugins/@hey-api/client-angular/plugin.ts packages/openapi-ts/src/plugins/@hey-api/angular-resource/plugin.ts
··· 4 4 createOperationComment, 5 5 isOperationOptionsRequired, 6 6 } from '../../shared/utils/operation'; 7 - import { clientPluginHandler } from '../client-core/plugin'; 7 + import { sdkId } from '../sdk/constants'; 8 8 import { operationClasses } from '../sdk/operation'; 9 9 import { serviceFunctionIdentifier } from '../sdk/plugin-legacy'; 10 10 import { typesId } from '../typescript/ref'; 11 - import type { HeyApiClientAngularPlugin } from './types'; 11 + import type { HeyApiAngularResourcePlugin } from './types'; 12 12 13 - export const angularClientPluginHandler: HeyApiClientAngularPlugin['Handler'] = 14 - (args) => { 15 - // First, run the standard client plugin handler to create/copy the client 16 - clientPluginHandler(args); 13 + export const angularResourcePluginHandler: HeyApiAngularResourcePlugin['Handler'] = 14 + ({ plugin }) => { 15 + // Check if SDK plugin exists 16 + const sdkPlugin = plugin.getPlugin('@hey-api/sdk'); 17 17 18 - const { plugin } = args; 19 - 20 - // Check if SDK plugin exists and if we should generate class-based services 21 - const sdkPlugin = plugin.getPlugin('@hey-api/sdk'); 22 18 if (!sdkPlugin) { 23 - return; 19 + throw new Error( 20 + '@hey-api/sdk plugin is required for @hey-api/angular-resource plugin', 21 + ); 24 22 } 25 23 26 - // Now create our Angular-specific httpResource file 24 + // Create the httpResource file 27 25 const file = plugin.createFile({ 28 - id: 'httpResource', 29 - path: plugin.output + '.resource', 26 + id: plugin.name, 27 + path: plugin.output, 30 28 }); 31 29 32 - // Import Angular core decorators and rxjs 30 + // Import Angular core decorators 33 31 if (sdkPlugin.config.asClass) { 34 32 file.import({ 35 33 module: '@angular/core', ··· 42 40 name: 'resource', 43 41 }); 44 42 45 - // Import types from the main types file if needed 46 - // const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; 47 - // const fileTypeScript = plugin.context.file({ id: typesId })!;; 43 + file.import({ 44 + module: file.relativePathToFile({ 45 + context: plugin.context, 46 + id: sdkId, 47 + }), 48 + name: 'Options', 49 + }); 48 50 49 51 if (sdkPlugin.config.asClass) { 50 52 generateAngularClassServices({ file, plugin, sdkPlugin }); ··· 67 69 sdkPlugin, 68 70 }: { 69 71 file: any; 70 - plugin: HeyApiClientAngularPlugin['Instance']; 72 + plugin: HeyApiAngularResourcePlugin['Instance']; 71 73 sdkPlugin: any; 72 74 }) => { 73 75 const serviceClasses = new Map<string, AngularServiceClassEntry>(); ··· 124 126 methodName: entry.methodName, 125 127 operation, 126 128 plugin, 129 + sdkPlugin, 127 130 }); 128 131 129 132 if (!currentClass.nodes.length) { ··· 195 198 const generateAngularFunctionServices = ({ 196 199 file, 197 200 plugin, 198 - // sdkPlugin, 201 + sdkPlugin, 199 202 }: { 200 203 file: any; 201 - plugin: HeyApiClientAngularPlugin['Instance']; 204 + plugin: HeyApiAngularResourcePlugin['Instance']; 202 205 sdkPlugin: any; 203 206 }) => { 204 207 plugin.forEach('operation', ({ operation }) => { ··· 220 223 isRequiredOptions, 221 224 operation, 222 225 plugin, 226 + sdkPlugin, 223 227 }); 224 228 225 229 file.add(node); 226 230 }); 227 231 }; 228 232 229 - const generateResourceCallExpression = () => 230 - tsc.callExpression({ 233 + const generateResourceCallExpression = ({ 234 + file, 235 + operation, 236 + plugin, 237 + sdkPlugin, 238 + }: { 239 + file: any; 240 + operation: any; 241 + plugin: any; 242 + sdkPlugin: any; 243 + }) => { 244 + // Import the SDK function/method instead of recreating the logic 245 + let sdkFunctionCall; 246 + 247 + if (sdkPlugin.config.asClass) { 248 + // For class-based SDK, use the class methods 249 + const classes = operationClasses({ 250 + context: plugin.context, 251 + operation, 252 + plugin: sdkPlugin, 253 + }); 254 + 255 + // Get the first class entry to determine the method path 256 + const firstEntry = Array.from(classes.values())[0]; 257 + if (firstEntry) { 258 + // Import the root class from SDK 259 + const rootClassName = firstEntry.path[0]; 260 + const sdkImport = file.import({ 261 + module: file.relativePathToFile({ 262 + context: plugin.context, 263 + id: sdkId, 264 + }), 265 + name: rootClassName, 266 + }); 267 + 268 + // Build the method access path 269 + let methodAccess: any = tsc.identifier({ text: sdkImport.name }); 270 + 271 + // Navigate through the class hierarchy 272 + for (let i = 1; i < firstEntry.path.length; i++) { 273 + const className = firstEntry.path[i]; 274 + if (className) { 275 + methodAccess = tsc.propertyAccessExpression({ 276 + expression: methodAccess, 277 + name: stringCase({ 278 + case: 'camelCase', 279 + value: className, 280 + }), 281 + }); 282 + } 283 + } 284 + 285 + // Add the final method name 286 + methodAccess = tsc.propertyAccessExpression({ 287 + expression: methodAccess, 288 + name: firstEntry.methodName, 289 + }); 290 + 291 + sdkFunctionCall = tsc.callExpression({ 292 + functionName: methodAccess, 293 + parameters: [tsc.identifier({ text: 'params' })], 294 + }); 295 + } 296 + } else { 297 + // For function-based SDK, import and call the function directly 298 + const functionName = serviceFunctionIdentifier({ 299 + config: plugin.context.config, 300 + handleIllegal: true, 301 + id: operation.id, 302 + operation, 303 + }); 304 + 305 + const sdkImport = file.import({ 306 + module: file.relativePathToFile({ 307 + context: plugin.context, 308 + id: sdkId, 309 + }), 310 + name: functionName, 311 + }); 312 + 313 + sdkFunctionCall = tsc.callExpression({ 314 + functionName: sdkImport.name, 315 + parameters: [tsc.identifier({ text: 'options' })], 316 + }); 317 + } 318 + 319 + return tsc.callExpression({ 231 320 functionName: 'resource', 232 321 parameters: [ 233 322 tsc.objectExpression({ ··· 235 324 { 236 325 key: 'loader', 237 326 value: tsc.arrowFunction({ 238 - parameters: [], 327 + async: true, 328 + parameters: [ 329 + { 330 + destructure: [{ name: 'params' }], 331 + type: undefined, 332 + }, 333 + ], 239 334 statements: [ 240 - tsc.expressionToStatement({ 241 - expression: tsc.callExpression({ 242 - functionName: 'throw', 243 - parameters: [ 244 - tsc.newExpression({ 245 - argumentsArray: [ 246 - tsc.stringLiteral({ text: 'Not implemented' }), 247 - ], 248 - expression: tsc.identifier({ text: 'Error' }), 249 - }), 250 - ], 251 - }), 335 + tsc.returnStatement({ 336 + expression: sdkFunctionCall, 252 337 }), 253 338 ], 254 339 }), ··· 268 353 }), 269 354 ], 270 355 }); 356 + }; 271 357 272 358 const generateAngularResourceMethod = ({ 273 359 file, ··· 275 361 methodName, 276 362 operation, 277 363 plugin, 364 + sdkPlugin, 278 365 }: { 279 366 file: any; 280 367 isRequiredOptions: boolean; 281 368 methodName: string; 282 369 operation: any; 283 370 plugin: any; 371 + sdkPlugin: any; 284 372 }) => { 285 373 // Import operation data type 286 374 const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; ··· 296 384 return tsc.methodDeclaration({ 297 385 accessLevel: 'public', 298 386 comment: createOperationComment({ operation }), 299 - isStatic: true, 387 + // isStatic: true, 300 388 name: methodName, 301 389 parameters: [ 302 390 { 303 391 isRequired: isRequiredOptions, 304 392 name: 'options', 305 - type: dataType.name ? `Omit<${dataType.name}, 'url'>` : 'unknown', 393 + type: `Options<${dataType.name || 'unknown'}, ThrowOnError>`, 306 394 }, 307 395 ], 308 396 returnType: undefined, 309 397 statements: [ 310 398 tsc.returnStatement({ 311 - expression: generateResourceCallExpression(), 399 + expression: generateResourceCallExpression({ 400 + file, 401 + operation, 402 + plugin, 403 + sdkPlugin, 404 + }), 312 405 }), 313 406 ], 314 407 types: [ ··· 327 420 isRequiredOptions, 328 421 operation, 329 422 plugin, 423 + sdkPlugin, 330 424 }: { 331 425 file: any; 332 426 functionName: string; 333 427 isRequiredOptions: boolean; 334 428 operation: any; 335 429 plugin: any; 430 + sdkPlugin: any; 336 431 }) => { 337 432 const pluginTypeScript = plugin.getPlugin('@hey-api/typescript')!; 338 433 const fileTypeScript = plugin.context.file({ id: typesId })!; ··· 352 447 { 353 448 isRequired: isRequiredOptions, 354 449 name: 'options', 355 - type: dataType.name ? `Omit<${dataType.name}, 'url'>` : 'unknown', 450 + type: `Options<${dataType.name || 'unknown'}, ThrowOnError>`, 356 451 }, 357 452 ], 358 453 statements: [ 359 454 tsc.returnStatement({ 360 - expression: generateResourceCallExpression(), 455 + expression: generateResourceCallExpression({ 456 + file, 457 + operation, 458 + plugin, 459 + sdkPlugin, 460 + }), 361 461 }), 362 462 ], 363 463 types: [
-5
packages/openapi-ts/src/plugins/@hey-api/client-angular/types.d.ts
··· 4 4 export type UserConfig = Plugin.Name<'@hey-api/client-angular'> & 5 5 Client.Config & { 6 6 /** 7 - * TODO: TBD 8 - */ 9 - httpResource?: boolean; 10 - 11 - /** 12 7 * Throw an error instead of returning it in the response? 13 8 * 14 9 * @default false
+4
packages/openapi-ts/src/plugins/config.ts
··· 1 + import type { HeyApiAngularResourcePlugin } from './@hey-api/angular-resource'; 2 + import { defaultConfig as heyApiAngularResource } from './@hey-api/angular-resource'; 1 3 import type { HeyApiClientAngularPlugin } from './@hey-api/client-angular'; 2 4 import { defaultConfig as heyApiClientAngular } from './@hey-api/client-angular'; 3 5 import type { HeyApiClientAxiosPlugin } from './@hey-api/client-axios'; ··· 45 47 import { defaultConfig as zod } from './zod'; 46 48 47 49 export interface PluginConfigMap { 50 + '@hey-api/angular-resource': HeyApiAngularResourcePlugin['Types']; 48 51 '@hey-api/client-angular': HeyApiClientAngularPlugin['Types']; 49 52 '@hey-api/client-axios': HeyApiClientAxiosPlugin['Types']; 50 53 '@hey-api/client-fetch': HeyApiClientFetchPlugin['Types']; ··· 72 75 export const defaultPluginConfigs: { 73 76 [K in PluginNames]: Plugin.Config<PluginConfigMap[K]>; 74 77 } = { 78 + '@hey-api/angular-resource': heyApiAngularResource, 75 79 '@hey-api/client-angular': heyApiClientAngular, 76 80 '@hey-api/client-axios': heyApiClientAxios, 77 81 '@hey-api/client-fetch': heyApiClientFetch,
+1
packages/openapi-ts/src/plugins/types.d.ts
··· 23 23 | PluginClientNames 24 24 | '@hey-api/schemas' 25 25 | '@hey-api/sdk' 26 + | '@hey-api/angular-resource' 26 27 | '@hey-api/transformers' 27 28 | '@hey-api/typescript' 28 29 | '@tanstack/angular-query-experimental'