@hey-api/openapi-ts 0.52.11 → 0.53.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,37 +5,29 @@ interface Dictionary<T = unknown> {
5
5
  [key: string]: T;
6
6
  }
7
7
 
8
- interface WithEnumExtension {
9
- 'x-enum-descriptions'?: ReadonlyArray<string>;
10
- 'x-enum-varnames'?: ReadonlyArray<string>;
11
- 'x-enumNames'?: ReadonlyArray<string>;
12
- }
13
-
14
- /**
15
- * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#external-documentation-object
16
- */
17
- interface OpenApiExternalDocs {
18
- description?: string;
19
- url: string;
20
- }
21
-
22
8
  /**
23
9
  * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#reference-object
24
10
  */
25
- interface OpenApiReference {
11
+ interface OpenApiReference$1 {
26
12
  $ref?: string;
27
13
  }
28
14
 
29
15
  /**
30
16
  * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#example-object
31
17
  */
32
- interface OpenApiExample extends OpenApiReference {
18
+ interface OpenApiExample extends OpenApiReference$1 {
33
19
  description?: string;
34
20
  externalValue?: string;
35
21
  summary?: string;
36
22
  value?: unknown;
37
23
  }
38
24
 
25
+ interface WithEnumExtension {
26
+ 'x-enum-descriptions'?: ReadonlyArray<string>;
27
+ 'x-enum-varnames'?: ReadonlyArray<string>;
28
+ 'x-enumNames'?: ReadonlyArray<string>;
29
+ }
30
+
39
31
  /**
40
32
  * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#discriminator-object
41
33
  */
@@ -44,10 +36,18 @@ interface OpenApiDiscriminator {
44
36
  propertyName: string;
45
37
  }
46
38
 
39
+ /**
40
+ * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#external-documentation-object
41
+ */
42
+ interface OpenApiExternalDocs$1 {
43
+ description?: string;
44
+ url: string;
45
+ }
46
+
47
47
  /**
48
48
  * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#xml-object
49
49
  */
50
- interface OpenApiXml {
50
+ interface OpenApiXml$1 {
51
51
  attribute?: boolean;
52
52
  name?: string;
53
53
  namespace?: string;
@@ -58,10 +58,10 @@ interface OpenApiXml {
58
58
  /**
59
59
  * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schema-object
60
60
  */
61
- interface OpenApiSchema extends OpenApiReference, WithEnumExtension {
62
- additionalProperties?: boolean | OpenApiSchema;
63
- allOf?: OpenApiSchema[];
64
- anyOf?: OpenApiSchema[];
61
+ interface OpenApiSchema$1 extends OpenApiReference$1, WithEnumExtension {
62
+ additionalProperties?: boolean | OpenApiSchema$1;
63
+ allOf?: OpenApiSchema$1[];
64
+ anyOf?: OpenApiSchema$1[];
65
65
  const?: string | number | boolean | null;
66
66
  default?: unknown;
67
67
  deprecated?: boolean;
@@ -71,9 +71,9 @@ interface OpenApiSchema extends OpenApiReference, WithEnumExtension {
71
71
  example?: unknown;
72
72
  exclusiveMaximum?: boolean;
73
73
  exclusiveMinimum?: boolean;
74
- externalDocs?: OpenApiExternalDocs;
74
+ externalDocs?: OpenApiExternalDocs$1;
75
75
  format?: 'binary' | 'boolean' | 'byte' | 'date-time' | 'date' | 'double' | 'float' | 'int32' | 'int64' | 'password' | 'string';
76
- items?: OpenApiSchema;
76
+ items?: OpenApiSchema$1;
77
77
  maxItems?: number;
78
78
  maxLength?: number;
79
79
  maxProperties?: number;
@@ -83,19 +83,19 @@ interface OpenApiSchema extends OpenApiReference, WithEnumExtension {
83
83
  minProperties?: number;
84
84
  minimum?: number;
85
85
  multipleOf?: number;
86
- not?: OpenApiSchema[];
86
+ not?: OpenApiSchema$1[];
87
87
  nullable?: boolean;
88
- oneOf?: OpenApiSchema[];
88
+ oneOf?: OpenApiSchema$1[];
89
89
  pattern?: string;
90
- prefixItems?: OpenApiSchema[];
91
- properties?: Dictionary<OpenApiSchema>;
90
+ prefixItems?: OpenApiSchema$1[];
91
+ properties?: Dictionary<OpenApiSchema$1>;
92
92
  readOnly?: boolean;
93
93
  required?: string[];
94
94
  title?: string;
95
95
  type?: string | string[];
96
96
  uniqueItems?: boolean;
97
97
  writeOnly?: boolean;
98
- xml?: OpenApiXml;
98
+ xml?: OpenApiXml$1;
99
99
  }
100
100
 
101
101
  /**
@@ -112,12 +112,12 @@ type MediaType = 'application/json';
112
112
  interface MediaTypeObject {
113
113
  example?: unknown;
114
114
  examples?: Dictionary<OpenApiExample>;
115
- schema: OpenApiSchema;
115
+ schema: OpenApiSchema$1;
116
116
  }
117
117
  /**
118
118
  * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-object
119
119
  */
120
- interface OpenApiParameter extends OpenApiReference {
120
+ interface OpenApiParameter extends OpenApiReference$1 {
121
121
  allowEmptyValue?: boolean;
122
122
  allowReserved?: boolean;
123
123
  content?: Record<MediaType, MediaTypeObject>;
@@ -130,7 +130,7 @@ interface OpenApiParameter extends OpenApiReference {
130
130
  name: string;
131
131
  nullable?: boolean;
132
132
  required?: boolean;
133
- schema?: OpenApiSchema;
133
+ schema?: OpenApiSchema$1;
134
134
  style?: string;
135
135
  }
136
136
 
@@ -160,7 +160,7 @@ interface OperationResponse extends Model {
160
160
  responseTypes: Array<'error' | 'success'>;
161
161
  }
162
162
  type Method = 'CONNECT' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | 'TRACE';
163
- interface Operation extends OperationParameters {
163
+ interface Operation$1 extends OperationParameters {
164
164
  deprecated: boolean;
165
165
  description: string | null;
166
166
  /**
@@ -176,12 +176,8 @@ interface Operation extends OperationParameters {
176
176
  * Sorted by status code.
177
177
  */
178
178
  responses: OperationResponse[];
179
- /**
180
- * Service name, might be without postfix. This will be used to name the
181
- * exported class.
182
- */
183
- service: string;
184
179
  summary: string | null;
180
+ tags: string[] | null;
185
181
  }
186
182
  interface Schema {
187
183
  default?: unknown;
@@ -239,20 +235,10 @@ interface Model extends Schema {
239
235
  template: string | null;
240
236
  type: string;
241
237
  }
242
- interface Service extends Pick<Model, '$refs' | 'imports' | 'name'> {
243
- operations: Operation[];
244
- }
245
-
246
- interface Client$1 {
238
+ interface Client$2 {
247
239
  models: Model[];
248
- /**
249
- * Map of unique operation IDs where operation IDs are keys. The values
250
- * are endpoints in the `${method} ${path}` format. This is used to detect
251
- * duplicate operation IDs in the specification.
252
- */
253
- operationIds: Map<string, string>;
240
+ operations: Operation$1[];
254
241
  server: string;
255
- services: Service[];
256
242
  /**
257
243
  * Map of generated types where type names are keys. This is used to track
258
244
  * uniquely generated types as we may want to deduplicate if there are
@@ -263,6 +249,81 @@ interface Client$1 {
263
249
  version: string;
264
250
  }
265
251
 
252
+ /**
253
+ * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#external-documentation-object
254
+ */
255
+ interface OpenApiExternalDocs {
256
+ description?: string;
257
+ url: string;
258
+ }
259
+
260
+ interface WithNullableExtension {
261
+ 'x-nullable'?: boolean;
262
+ }
263
+
264
+ /**
265
+ * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#reference-object
266
+ */
267
+ interface OpenApiReference {
268
+ $ref?: string;
269
+ }
270
+
271
+ /**
272
+ * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#xml-object
273
+ */
274
+ interface OpenApiXml {
275
+ attribute?: boolean;
276
+ name?: string;
277
+ namespace?: string;
278
+ prefix?: string;
279
+ wrapped?: boolean;
280
+ }
281
+
282
+ /**
283
+ * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#schema-object
284
+ */
285
+ interface OpenApiSchema extends OpenApiReference, WithEnumExtension, WithNullableExtension {
286
+ additionalProperties?: boolean | OpenApiSchema;
287
+ allOf?: OpenApiSchema[];
288
+ default?: unknown;
289
+ description?: string;
290
+ discriminator?: string;
291
+ enum?: (string | number)[];
292
+ example?: unknown;
293
+ exclusiveMaximum?: boolean;
294
+ exclusiveMinimum?: boolean;
295
+ externalDocs?: OpenApiExternalDocs;
296
+ format?: 'int32' | 'int64' | 'float' | 'double' | 'string' | 'boolean' | 'byte' | 'binary' | 'date' | 'date-time' | 'password';
297
+ items?: OpenApiSchema;
298
+ maxItems?: number;
299
+ maxLength?: number;
300
+ maxProperties?: number;
301
+ maximum?: number;
302
+ minItems?: number;
303
+ minLength?: number;
304
+ minProperties?: number;
305
+ minimum?: number;
306
+ multipleOf?: number;
307
+ pattern?: string;
308
+ properties?: Dictionary<OpenApiSchema>;
309
+ readOnly?: boolean;
310
+ required?: string[];
311
+ title?: string;
312
+ type?: string;
313
+ uniqueItems?: boolean;
314
+ xml?: OpenApiXml;
315
+ }
316
+
317
+ interface Operation extends Omit<Operation$1, 'tags'> {
318
+ service: string;
319
+ }
320
+ interface Service extends Pick<Model, '$refs' | 'imports' | 'name'> {
321
+ operations: Operation[];
322
+ }
323
+ interface Client$1 extends Omit<Client$2, 'operations'> {
324
+ services: Service[];
325
+ }
326
+
266
327
  interface ImportExportItemObject {
267
328
  alias?: string;
268
329
  asType?: boolean;
@@ -295,8 +356,8 @@ declare class TypeScriptFile {
295
356
  */
296
357
  removeNode(): void;
297
358
  private _setName;
298
- toString(seperator?: string): string;
299
- write(seperator?: string): void;
359
+ toString(separator?: string): string;
360
+ write(separator?: string): void;
300
361
  }
301
362
 
302
363
  type ExtractFromArray<T, Discriminator> = T extends Discriminator ? Required<T> : never;
@@ -319,7 +380,43 @@ interface PluginDefinition {
319
380
  output?: string;
320
381
  }
321
382
 
322
- interface PluginTanStackReactQuery extends PluginDefinition {
383
+ interface PluginConfig$6 extends PluginDefinition {
384
+ /**
385
+ * Generate Hey API schemas from the provided input.
386
+ */
387
+ name: '@hey-api/schemas';
388
+ /**
389
+ * Name of the generated file.
390
+ * @default 'schemas'
391
+ */
392
+ output?: string;
393
+ }
394
+
395
+ interface PluginConfig$5 extends PluginDefinition {
396
+ /**
397
+ * Generate Hey API services from the provided input.
398
+ */
399
+ name: '@hey-api/services';
400
+ /**
401
+ * Name of the generated file.
402
+ * @default 'services'
403
+ */
404
+ output?: string;
405
+ }
406
+
407
+ interface PluginConfig$4 extends PluginDefinition {
408
+ /**
409
+ * Generate Hey API types from the provided input.
410
+ */
411
+ name: '@hey-api/types';
412
+ /**
413
+ * Name of the generated file.
414
+ * @default 'types'
415
+ */
416
+ output?: string;
417
+ }
418
+
419
+ interface PluginConfig$3 extends PluginDefinition {
323
420
  /**
324
421
  * Generate {@link https://tanstack.com/query/v5/docs/framework/react/reference/infiniteQueryOptions `infiniteQueryOptions()`} helpers? These will be generated from GET and POST requests where a pagination parameter is detected.
325
422
  * @default true
@@ -347,7 +444,7 @@ interface PluginTanStackReactQuery extends PluginDefinition {
347
444
  queryOptions?: boolean;
348
445
  }
349
446
 
350
- interface PluginTanStackSolidQuery extends PluginDefinition {
447
+ interface PluginConfig$2 extends PluginDefinition {
351
448
  /**
352
449
  * Generate `createInfiniteQuery()` helpers? These will be generated from GET and POST requests where a pagination parameter is detected.
353
450
  * @default true
@@ -375,7 +472,7 @@ interface PluginTanStackSolidQuery extends PluginDefinition {
375
472
  queryOptions?: boolean;
376
473
  }
377
474
 
378
- interface PluginTanStackSvelteQuery extends PluginDefinition {
475
+ interface PluginConfig$1 extends PluginDefinition {
379
476
  /**
380
477
  * Generate `createInfiniteQuery()` helpers? These will be generated from GET and POST requests where a pagination parameter is detected.
381
478
  * @default true
@@ -403,7 +500,7 @@ interface PluginTanStackSvelteQuery extends PluginDefinition {
403
500
  queryOptions?: boolean;
404
501
  }
405
502
 
406
- interface PluginTanStackVueQuery extends PluginDefinition {
503
+ interface PluginConfig extends PluginDefinition {
407
504
  /**
408
505
  * Generate {@link https://tanstack.com/query/v5/docs/framework/vue/reference/infiniteQueryOptions `infiniteQueryOptions()`} helpers? These will be generated from GET and POST requests where a pagination parameter is detected.
409
506
  * @default true
@@ -431,9 +528,10 @@ interface PluginTanStackVueQuery extends PluginDefinition {
431
528
  queryOptions?: boolean;
432
529
  }
433
530
 
434
- type Plugins = PluginTanStackReactQuery | PluginTanStackSolidQuery | PluginTanStackSvelteQuery | PluginTanStackVueQuery;
531
+ type Plugins = PluginConfig$6 | PluginConfig$5 | PluginConfig$4 | PluginConfig$3 | PluginConfig$2 | PluginConfig$1 | PluginConfig;
435
532
 
436
- type Client = '@hey-api/client-axios' | '@hey-api/client-fetch' | 'angular' | 'axios' | 'fetch' | 'node' | 'xhr' | '';
533
+ declare const CLIENTS: readonly ["@hey-api/client-axios", "@hey-api/client-fetch", "legacy/angular", "legacy/axios", "legacy/fetch", "legacy/node", "legacy/xhr"];
534
+ type Client = (typeof CLIENTS)[number];
437
535
  interface ClientConfig {
438
536
  /**
439
537
  * Manually set base in OpenAPI config instead of inferring from server value
@@ -442,7 +540,6 @@ interface ClientConfig {
442
540
  base?: string;
443
541
  /**
444
542
  * HTTP client to generate
445
- * @default 'fetch'
446
543
  */
447
544
  client?: Client | {
448
545
  /**
@@ -457,7 +554,6 @@ interface ClientConfig {
457
554
  bundle?: boolean;
458
555
  /**
459
556
  * HTTP client to generate
460
- * @default 'fetch'
461
557
  */
462
558
  name: Client;
463
559
  };
@@ -533,6 +629,12 @@ interface ClientConfig {
533
629
  * @default true
534
630
  */
535
631
  export?: boolean;
632
+ /**
633
+ * Customise the schema name. By default, `{{name}}Schema` is used. `name` is a
634
+ * valid JavaScript/TypeScript identifier, e.g. if your schema name is
635
+ * "Foo-Bar", `name` value would be "FooBar".
636
+ */
637
+ name?: (name: string, schema: OpenApiSchema | OpenApiSchema$1) => string;
536
638
  /**
537
639
  * Choose schema type to generate. Select 'form' if you don't want
538
640
  * descriptions to reduce bundle size and you plan to use schemas
@@ -577,7 +679,7 @@ interface ClientConfig {
577
679
  */
578
680
  include?: string;
579
681
  /**
580
- * Customise the method name of methods within the service. By default, {@link Operation.name} is used.
682
+ * Customise the name of methods within the service. By default, {@link Operation.name} is used.
581
683
  */
582
684
  methodNameBuilder?: (operation: Operation) => string;
583
685
  /**
@@ -642,7 +744,8 @@ interface ClientConfig {
642
744
  */
643
745
  useOptions?: boolean;
644
746
  }
645
- type UserConfig = ClientConfig;
747
+ interface UserConfig extends ClientConfig {
748
+ }
646
749
  type Config = Omit<Required<ClientConfig>, 'base' | 'client' | 'name' | 'output' | 'plugins' | 'request' | 'schemas' | 'services' | 'types'> & Pick<ClientConfig, 'base' | 'name' | 'request'> & {
647
750
  client: Extract<Required<ClientConfig>['client'], object>;
648
751
  output: Extract<Required<ClientConfig>['output'], object>;
@@ -660,10 +763,10 @@ type Config = Omit<Required<ClientConfig>, 'base' | 'client' | 'name' | 'output'
660
763
  * service layer, etc.
661
764
  * @param userConfig {@link UserConfig} passed to the `createClient()` method
662
765
  */
663
- declare function createClient(userConfig: UserConfig): Promise<Client$1[]>;
766
+ declare function createClient(userConfig: UserConfig): Promise<ReadonlyArray<Client$1>>;
664
767
  /**
665
768
  * Type helper for openapi-ts.config.ts, returns {@link UserConfig} object
666
769
  */
667
- declare function defineConfig(config: UserConfig): UserConfig;
770
+ declare const defineConfig: (config: UserConfig) => UserConfig;
668
771
 
669
772
  export { type UserConfig, createClient, defineConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hey-api/openapi-ts",
3
- "version": "0.52.11",
3
+ "version": "0.53.1",
4
4
  "type": "module",
5
5
  "description": "Turn your OpenAPI specification into a beautiful TypeScript client",
6
6
  "homepage": "https://heyapi.vercel.app/",
@@ -36,14 +36,15 @@
36
36
  },
37
37
  "files": [
38
38
  "bin",
39
- "dist"
39
+ "dist",
40
+ "LICENSE.md"
40
41
  ],
41
42
  "engines": {
42
43
  "node": "^18.0.0 || >=20.0.0"
43
44
  },
44
45
  "dependencies": {
45
46
  "@apidevtools/json-schema-ref-parser": "11.7.0",
46
- "c12": "1.11.1",
47
+ "c12": "1.11.2",
47
48
  "commander": "12.1.0",
48
49
  "handlebars": "4.7.8"
49
50
  },
@@ -64,13 +65,13 @@
64
65
  "@angular/router": "17.3.9",
65
66
  "@rollup/plugin-json": "6.1.0",
66
67
  "@rollup/plugin-node-resolve": "15.2.3",
67
- "@tanstack/react-query": "5.52.1",
68
+ "@tanstack/react-query": "5.56.2",
68
69
  "@tanstack/solid-query": "5.51.21",
69
- "@tanstack/svelte-query": "5.52.0",
70
- "@tanstack/vue-query": "5.52.0",
70
+ "@tanstack/svelte-query": "5.56.2",
71
+ "@tanstack/vue-query": "5.56.2",
71
72
  "@types/cross-spawn": "6.0.6",
72
73
  "@types/express": "4.17.21",
73
- "axios": "1.7.5",
74
+ "axios": "1.7.7",
74
75
  "cross-spawn": "7.0.3",
75
76
  "eslint": "9.6.0",
76
77
  "express": "4.19.2",
@@ -83,7 +84,7 @@
83
84
  "tslib": "2.6.3",
84
85
  "typescript": "5.5.3",
85
86
  "@hey-api/client-axios": "0.2.3",
86
- "@hey-api/client-fetch": "0.2.4"
87
+ "@hey-api/client-fetch": "0.3.0"
87
88
  },
88
89
  "scripts": {
89
90
  "build-bundle": "rollup --config rollup.config.ts --configPlugin typescript",
package/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) Hey API
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.