@hey-api/openapi-ts 0.53.0 → 0.53.2

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,102 +5,29 @@ interface Dictionary<T = unknown> {
5
5
  [key: string]: T;
6
6
  }
7
7
 
8
- /**
9
- * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#external-documentation-object
10
- */
11
- interface OpenApiExternalDocs$1 {
12
- description?: string;
13
- url: string;
14
- }
15
-
16
- interface WithEnumExtension {
17
- 'x-enum-descriptions'?: ReadonlyArray<string>;
18
- 'x-enum-varnames'?: ReadonlyArray<string>;
19
- 'x-enumNames'?: ReadonlyArray<string>;
20
- }
21
-
22
- interface WithNullableExtension {
23
- 'x-nullable'?: boolean;
24
- }
25
-
26
- /**
27
- * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#reference-object
28
- */
29
- interface OpenApiReference$1 {
30
- $ref?: string;
31
- }
32
-
33
- /**
34
- * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#xml-object
35
- */
36
- interface OpenApiXml$1 {
37
- attribute?: boolean;
38
- name?: string;
39
- namespace?: string;
40
- prefix?: string;
41
- wrapped?: boolean;
42
- }
43
-
44
- /**
45
- * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#schema-object
46
- */
47
- interface OpenApiSchema$1 extends OpenApiReference$1, WithEnumExtension, WithNullableExtension {
48
- additionalProperties?: boolean | OpenApiSchema$1;
49
- allOf?: OpenApiSchema$1[];
50
- default?: unknown;
51
- description?: string;
52
- discriminator?: string;
53
- enum?: (string | number)[];
54
- example?: unknown;
55
- exclusiveMaximum?: boolean;
56
- exclusiveMinimum?: boolean;
57
- externalDocs?: OpenApiExternalDocs$1;
58
- format?: 'int32' | 'int64' | 'float' | 'double' | 'string' | 'boolean' | 'byte' | 'binary' | 'date' | 'date-time' | 'password';
59
- items?: OpenApiSchema$1;
60
- maxItems?: number;
61
- maxLength?: number;
62
- maxProperties?: number;
63
- maximum?: number;
64
- minItems?: number;
65
- minLength?: number;
66
- minProperties?: number;
67
- minimum?: number;
68
- multipleOf?: number;
69
- pattern?: string;
70
- properties?: Dictionary<OpenApiSchema$1>;
71
- readOnly?: boolean;
72
- required?: string[];
73
- title?: string;
74
- type?: string;
75
- uniqueItems?: boolean;
76
- xml?: OpenApiXml$1;
77
- }
78
-
79
- /**
80
- * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#external-documentation-object
81
- */
82
- interface OpenApiExternalDocs {
83
- description?: string;
84
- url: string;
85
- }
86
-
87
8
  /**
88
9
  * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#reference-object
89
10
  */
90
- interface OpenApiReference {
11
+ interface OpenApiReference$1 {
91
12
  $ref?: string;
92
13
  }
93
14
 
94
15
  /**
95
16
  * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#example-object
96
17
  */
97
- interface OpenApiExample extends OpenApiReference {
18
+ interface OpenApiExample extends OpenApiReference$1 {
98
19
  description?: string;
99
20
  externalValue?: string;
100
21
  summary?: string;
101
22
  value?: unknown;
102
23
  }
103
24
 
25
+ interface WithEnumExtension {
26
+ 'x-enum-descriptions'?: ReadonlyArray<string>;
27
+ 'x-enum-varnames'?: ReadonlyArray<string>;
28
+ 'x-enumNames'?: ReadonlyArray<string>;
29
+ }
30
+
104
31
  /**
105
32
  * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#discriminator-object
106
33
  */
@@ -109,10 +36,18 @@ interface OpenApiDiscriminator {
109
36
  propertyName: string;
110
37
  }
111
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
+
112
47
  /**
113
48
  * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#xml-object
114
49
  */
115
- interface OpenApiXml {
50
+ interface OpenApiXml$1 {
116
51
  attribute?: boolean;
117
52
  name?: string;
118
53
  namespace?: string;
@@ -123,10 +58,10 @@ interface OpenApiXml {
123
58
  /**
124
59
  * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schema-object
125
60
  */
126
- interface OpenApiSchema extends OpenApiReference, WithEnumExtension {
127
- additionalProperties?: boolean | OpenApiSchema;
128
- allOf?: OpenApiSchema[];
129
- anyOf?: OpenApiSchema[];
61
+ interface OpenApiSchema$1 extends OpenApiReference$1, WithEnumExtension {
62
+ additionalProperties?: boolean | OpenApiSchema$1;
63
+ allOf?: OpenApiSchema$1[];
64
+ anyOf?: OpenApiSchema$1[];
130
65
  const?: string | number | boolean | null;
131
66
  default?: unknown;
132
67
  deprecated?: boolean;
@@ -136,9 +71,9 @@ interface OpenApiSchema extends OpenApiReference, WithEnumExtension {
136
71
  example?: unknown;
137
72
  exclusiveMaximum?: boolean;
138
73
  exclusiveMinimum?: boolean;
139
- externalDocs?: OpenApiExternalDocs;
74
+ externalDocs?: OpenApiExternalDocs$1;
140
75
  format?: 'binary' | 'boolean' | 'byte' | 'date-time' | 'date' | 'double' | 'float' | 'int32' | 'int64' | 'password' | 'string';
141
- items?: OpenApiSchema;
76
+ items?: OpenApiSchema$1;
142
77
  maxItems?: number;
143
78
  maxLength?: number;
144
79
  maxProperties?: number;
@@ -148,19 +83,19 @@ interface OpenApiSchema extends OpenApiReference, WithEnumExtension {
148
83
  minProperties?: number;
149
84
  minimum?: number;
150
85
  multipleOf?: number;
151
- not?: OpenApiSchema[];
86
+ not?: OpenApiSchema$1[];
152
87
  nullable?: boolean;
153
- oneOf?: OpenApiSchema[];
88
+ oneOf?: OpenApiSchema$1[];
154
89
  pattern?: string;
155
- prefixItems?: OpenApiSchema[];
156
- properties?: Dictionary<OpenApiSchema>;
90
+ prefixItems?: OpenApiSchema$1[];
91
+ properties?: Dictionary<OpenApiSchema$1>;
157
92
  readOnly?: boolean;
158
93
  required?: string[];
159
94
  title?: string;
160
95
  type?: string | string[];
161
96
  uniqueItems?: boolean;
162
97
  writeOnly?: boolean;
163
- xml?: OpenApiXml;
98
+ xml?: OpenApiXml$1;
164
99
  }
165
100
 
166
101
  /**
@@ -177,12 +112,12 @@ type MediaType = 'application/json';
177
112
  interface MediaTypeObject {
178
113
  example?: unknown;
179
114
  examples?: Dictionary<OpenApiExample>;
180
- schema: OpenApiSchema;
115
+ schema: OpenApiSchema$1;
181
116
  }
182
117
  /**
183
118
  * {@link} https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-object
184
119
  */
185
- interface OpenApiParameter extends OpenApiReference {
120
+ interface OpenApiParameter extends OpenApiReference$1 {
186
121
  allowEmptyValue?: boolean;
187
122
  allowReserved?: boolean;
188
123
  content?: Record<MediaType, MediaTypeObject>;
@@ -195,7 +130,7 @@ interface OpenApiParameter extends OpenApiReference {
195
130
  name: string;
196
131
  nullable?: boolean;
197
132
  required?: boolean;
198
- schema?: OpenApiSchema;
133
+ schema?: OpenApiSchema$1;
199
134
  style?: string;
200
135
  }
201
136
 
@@ -225,7 +160,7 @@ interface OperationResponse extends Model {
225
160
  responseTypes: Array<'error' | 'success'>;
226
161
  }
227
162
  type Method = 'CONNECT' | 'DELETE' | 'GET' | 'HEAD' | 'OPTIONS' | 'PATCH' | 'POST' | 'PUT' | 'TRACE';
228
- interface Operation extends OperationParameters {
163
+ interface Operation$1 extends OperationParameters {
229
164
  deprecated: boolean;
230
165
  description: string | null;
231
166
  /**
@@ -241,12 +176,8 @@ interface Operation extends OperationParameters {
241
176
  * Sorted by status code.
242
177
  */
243
178
  responses: OperationResponse[];
244
- /**
245
- * Service name, might be without postfix. This will be used to name the
246
- * exported class.
247
- */
248
- service: string;
249
179
  summary: string | null;
180
+ tags: string[] | null;
250
181
  }
251
182
  interface Schema {
252
183
  default?: unknown;
@@ -304,20 +235,10 @@ interface Model extends Schema {
304
235
  template: string | null;
305
236
  type: string;
306
237
  }
307
- interface Service extends Pick<Model, '$refs' | 'imports' | 'name'> {
308
- operations: Operation[];
309
- }
310
-
311
- interface Client$1 {
238
+ interface Client$2 {
312
239
  models: Model[];
313
- /**
314
- * Map of unique operation IDs where operation IDs are keys. The values
315
- * are endpoints in the `${method} ${path}` format. This is used to detect
316
- * duplicate operation IDs in the specification.
317
- */
318
- operationIds: Map<string, string>;
240
+ operations: Operation$1[];
319
241
  server: string;
320
- services: Service[];
321
242
  /**
322
243
  * Map of generated types where type names are keys. This is used to track
323
244
  * uniquely generated types as we may want to deduplicate if there are
@@ -328,6 +249,81 @@ interface Client$1 {
328
249
  version: string;
329
250
  }
330
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
+
331
327
  interface ImportExportItemObject {
332
328
  alias?: string;
333
329
  asType?: boolean;
@@ -360,8 +356,8 @@ declare class TypeScriptFile {
360
356
  */
361
357
  removeNode(): void;
362
358
  private _setName;
363
- toString(seperator?: string): string;
364
- write(seperator?: string): void;
359
+ toString(separator?: string): string;
360
+ write(separator?: string): void;
365
361
  }
366
362
 
367
363
  type ExtractFromArray<T, Discriminator> = T extends Discriminator ? Required<T> : never;
@@ -384,7 +380,43 @@ interface PluginDefinition {
384
380
  output?: string;
385
381
  }
386
382
 
387
- 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 {
388
420
  /**
389
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.
390
422
  * @default true
@@ -412,7 +444,7 @@ interface PluginTanStackReactQuery extends PluginDefinition {
412
444
  queryOptions?: boolean;
413
445
  }
414
446
 
415
- interface PluginTanStackSolidQuery extends PluginDefinition {
447
+ interface PluginConfig$2 extends PluginDefinition {
416
448
  /**
417
449
  * Generate `createInfiniteQuery()` helpers? These will be generated from GET and POST requests where a pagination parameter is detected.
418
450
  * @default true
@@ -440,7 +472,7 @@ interface PluginTanStackSolidQuery extends PluginDefinition {
440
472
  queryOptions?: boolean;
441
473
  }
442
474
 
443
- interface PluginTanStackSvelteQuery extends PluginDefinition {
475
+ interface PluginConfig$1 extends PluginDefinition {
444
476
  /**
445
477
  * Generate `createInfiniteQuery()` helpers? These will be generated from GET and POST requests where a pagination parameter is detected.
446
478
  * @default true
@@ -468,7 +500,7 @@ interface PluginTanStackSvelteQuery extends PluginDefinition {
468
500
  queryOptions?: boolean;
469
501
  }
470
502
 
471
- interface PluginTanStackVueQuery extends PluginDefinition {
503
+ interface PluginConfig extends PluginDefinition {
472
504
  /**
473
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.
474
506
  * @default true
@@ -496,9 +528,10 @@ interface PluginTanStackVueQuery extends PluginDefinition {
496
528
  queryOptions?: boolean;
497
529
  }
498
530
 
499
- type Plugins = PluginTanStackReactQuery | PluginTanStackSolidQuery | PluginTanStackSvelteQuery | PluginTanStackVueQuery;
531
+ type Plugins = PluginConfig$6 | PluginConfig$5 | PluginConfig$4 | PluginConfig$3 | PluginConfig$2 | PluginConfig$1 | PluginConfig;
500
532
 
501
- type Client = '@hey-api/client-axios' | '@hey-api/client-fetch' | 'legacy/angular' | 'legacy/axios' | 'legacy/fetch' | 'legacy/node' | 'legacy/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];
502
535
  interface ClientConfig {
503
536
  /**
504
537
  * Manually set base in OpenAPI config instead of inferring from server value
@@ -601,7 +634,7 @@ interface ClientConfig {
601
634
  * valid JavaScript/TypeScript identifier, e.g. if your schema name is
602
635
  * "Foo-Bar", `name` value would be "FooBar".
603
636
  */
604
- name?: (name: string, schema: OpenApiSchema$1 | OpenApiSchema) => string;
637
+ name?: (name: string, schema: OpenApiSchema | OpenApiSchema$1) => string;
605
638
  /**
606
639
  * Choose schema type to generate. Select 'form' if you don't want
607
640
  * descriptions to reduce bundle size and you plan to use schemas
@@ -730,10 +763,10 @@ type Config = Omit<Required<ClientConfig>, 'base' | 'client' | 'name' | 'output'
730
763
  * service layer, etc.
731
764
  * @param userConfig {@link UserConfig} passed to the `createClient()` method
732
765
  */
733
- declare function createClient(userConfig: UserConfig): Promise<Client$1[]>;
766
+ declare function createClient(userConfig: UserConfig): Promise<ReadonlyArray<Client$1>>;
734
767
  /**
735
768
  * Type helper for openapi-ts.config.ts, returns {@link UserConfig} object
736
769
  */
737
- declare function defineConfig(config: UserConfig): UserConfig;
770
+ declare const defineConfig: (config: UserConfig) => UserConfig;
738
771
 
739
- export { type UserConfig, createClient, defineConfig };
772
+ export { type Operation, type Plugins, type UserConfig, createClient, defineConfig };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hey-api/openapi-ts",
3
- "version": "0.53.0",
3
+ "version": "0.53.2",
4
4
  "type": "module",
5
5
  "description": "Turn your OpenAPI specification into a beautiful TypeScript client",
6
6
  "homepage": "https://heyapi.vercel.app/",
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@apidevtools/json-schema-ref-parser": "11.7.0",
47
- "c12": "1.11.1",
47
+ "c12": "1.11.2",
48
48
  "commander": "12.1.0",
49
49
  "handlebars": "4.7.8"
50
50
  },
@@ -65,16 +65,16 @@
65
65
  "@angular/router": "17.3.9",
66
66
  "@rollup/plugin-json": "6.1.0",
67
67
  "@rollup/plugin-node-resolve": "15.2.3",
68
- "@tanstack/react-query": "5.53.2",
68
+ "@tanstack/react-query": "5.56.2",
69
69
  "@tanstack/solid-query": "5.51.21",
70
- "@tanstack/svelte-query": "5.53.2",
71
- "@tanstack/vue-query": "5.53.2",
70
+ "@tanstack/svelte-query": "5.56.2",
71
+ "@tanstack/vue-query": "5.56.2",
72
72
  "@types/cross-spawn": "6.0.6",
73
73
  "@types/express": "4.17.21",
74
74
  "axios": "1.7.7",
75
75
  "cross-spawn": "7.0.3",
76
76
  "eslint": "9.6.0",
77
- "express": "4.19.2",
77
+ "express": "4.21.0",
78
78
  "glob": "10.4.3",
79
79
  "node-fetch": "3.3.2",
80
80
  "prettier": "3.3.2",
@@ -83,8 +83,8 @@
83
83
  "ts-node": "10.9.2",
84
84
  "tslib": "2.6.3",
85
85
  "typescript": "5.5.3",
86
- "@hey-api/client-axios": "0.2.3",
87
- "@hey-api/client-fetch": "0.2.4"
86
+ "@hey-api/client-fetch": "0.3.1",
87
+ "@hey-api/client-axios": "0.2.4"
88
88
  },
89
89
  "scripts": {
90
90
  "build-bundle": "rollup --config rollup.config.ts --configPlugin typescript",