@hey-api/openapi-ts 0.98.2 → 0.99.0

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.
package/README.md CHANGED
@@ -7,17 +7,17 @@
7
7
  <p align="center">
8
8
  <a href="https://www.devtrends.dev/trends?c=v1.kZIBIg"><img src="https://api.devtrends.dev/badge/npm/%40hey-api%2Fopenapi-ts?period=month&style=flat&view=value" alt="DevTrends badge for @hey-api/openapi-ts" /></a>
9
9
  <a href="https://www.devtrends.dev/trends?c=v1.kZIBIg&v=change"><img src="https://api.devtrends.dev/badge/npm/%40hey-api%2Fopenapi-ts?period=year&style=flat&view=change" alt="DevTrends badge for @hey-api/openapi-ts" /></a>
10
- <a href="https://github.com/hey-api/openapi-ts/actions?query=branch%3Amain"><img src="https://github.com/hey-api/openapi-ts/actions/workflows/ci.yml/badge.svg?event=push&branch=main" alt="CI status" /></a>
11
- <a href="https://github.com/hey-api/openapi-ts"><img src="https://img.shields.io/github/stars/hey-api/openapi-ts?style=flat&logo=github&label=GitHub&color=54C82D" alt="GitHub stars" /></a>
12
- <a href="https://github.com/hey-api/openapi-ts/blob/main/LICENSE.md"><img src="https://img.shields.io/github/license/hey-api/openapi-ts" alt="MIT License"></a>
10
+ <a href="https://github.com/hey-api/hey-api/actions?query=branch%3Amain"><img src="https://github.com/hey-api/hey-api/actions/workflows/ci.yml/badge.svg?event=push&branch=main" alt="CI status" /></a>
11
+ <a href="https://github.com/hey-api/hey-api"><img src="https://img.shields.io/github/stars/hey-api/hey-api?style=flat&logo=github&label=GitHub&color=54C82D" alt="GitHub stars" /></a>
12
+ <a href="https://github.com/hey-api/hey-api/blob/main/LICENSE.md"><img src="https://img.shields.io/github/license/hey-api/hey-api" alt="MIT License"></a>
13
13
  </p>
14
14
 
15
15
  <p align="center">
16
16
  <a href="https://stackblitz.com/edit/hey-api-example?file=openapi-ts.config.ts,src%2Fclient%2Fschemas.gen.ts,src%2Fclient%2Fsdk.gen.ts,src%2Fclient%2Ftypes.gen.ts">Demo</a>
17
17
  <span>&nbsp;•&nbsp;</span>
18
- <a href="https://heyapi.dev">Manual</a>
18
+ <a href="https://heyapi.dev/docs/openapi/typescript/get-started">Manual</a>
19
19
  <span>&nbsp;•&nbsp;</span>
20
- <a href="https://github.com/hey-api/openapi-ts/issues">Issues</a>
20
+ <a href="https://github.com/hey-api/hey-api/issues">Issues</a>
21
21
  <span>&nbsp;•&nbsp;</span>
22
22
  <a href="https://heyapi.dev/docs/openapi/typescript/community/contributing">Contribute</a>
23
23
  </p>
@@ -59,10 +59,10 @@ Partners behind the future of API tooling. [Become a sponsor](https://github.com
59
59
 
60
60
  <h3 align="center">Gold</h3>
61
61
 
62
- <table align="center" style="justify-content: center;align-items: center;display: flex;">
62
+ <table align="center">
63
63
  <tbody>
64
64
  <tr>
65
- <td align="center" width="336px">
65
+ <td align="center" width="50%">
66
66
  <p></p>
67
67
  <p>
68
68
  <a href="https://kutt.to/pkEZyc" target="_blank">
@@ -80,7 +80,7 @@ Partners behind the future of API tooling. [Become a sponsor](https://github.com
80
80
  </p>
81
81
  <p></p>
82
82
  </td>
83
- <td align="center" width="336px">
83
+ <td align="center" width="50%">
84
84
  <p></p>
85
85
  <p>
86
86
  <a href="https://kutt.to/QM9Q2N" target="_blank">
@@ -104,10 +104,10 @@ Partners behind the future of API tooling. [Become a sponsor](https://github.com
104
104
 
105
105
  <h3 align="center">Silver</h3>
106
106
 
107
- <table align="center" style="justify-content: center;align-items: center;display: flex;">
107
+ <table align="center">
108
108
  <tbody>
109
109
  <tr>
110
- <td align="center" width="172px">
110
+ <td align="center" width="33.333%">
111
111
  <a href="https://kutt.to/skQUVd" target="_blank">
112
112
  <picture height="40px">
113
113
  <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/scalar/logo-light.svg">
@@ -119,7 +119,7 @@ Partners behind the future of API tooling. [Become a sponsor](https://github.com
119
119
  scalar.com
120
120
  </a>
121
121
  </td>
122
- <td align="center" width="172px">
122
+ <td align="center" width="33.333%">
123
123
  <a href="https://kutt.to/Dr9GuW" target="_blank">
124
124
  <picture height="40px">
125
125
  <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/fastapi/logo-light.svg">
@@ -131,7 +131,7 @@ Partners behind the future of API tooling. [Become a sponsor](https://github.com
131
131
  fastapi.tiangolo.com
132
132
  </a>
133
133
  </td>
134
- <td align="center" width="172px">
134
+ <td align="center" width="33.333%">
135
135
  <a href="https://kutt.to/yZVkdV" target="_blank">
136
136
  <picture height="40px">
137
137
  <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/brands/unblocked/logo-light.svg">
@@ -149,10 +149,10 @@ Partners behind the future of API tooling. [Become a sponsor](https://github.com
149
149
 
150
150
  <h3 align="center">Bronze</h3>
151
151
 
152
- <table align="center" style="justify-content: center;align-items: center;display: flex;">
152
+ <table align="center">
153
153
  <tbody>
154
154
  <tr>
155
- <td align="center" width="136px">
155
+ <td align="center" width="33.333%">
156
156
  <a href="https://kutt.to/YpaKsX" target="_blank">
157
157
  <picture height="34px">
158
158
  <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/.gen/kinde-logo-wordmark-dark-480w.webp">
@@ -160,7 +160,7 @@ Partners behind the future of API tooling. [Become a sponsor](https://github.com
160
160
  </picture>
161
161
  </a>
162
162
  </td>
163
- <td align="center" width="136px">
163
+ <td align="center" width="33.333%">
164
164
  <a href="https://kutt.to/KkqSaw" target="_blank">
165
165
  <picture height="34px">
166
166
  <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/cella/logo-light.svg">
@@ -168,7 +168,7 @@ Partners behind the future of API tooling. [Become a sponsor](https://github.com
168
168
  </picture>
169
169
  </a>
170
170
  </td>
171
- <td align="center" width="136px">
171
+ <td align="center" width="33.333%">
172
172
  <a href="https://kutt.to/HW4GYR" target="_blank">
173
173
  <picture height="34px">
174
174
  <source media="(prefers-color-scheme: dark)" srcset="https://heyapi.dev/assets/photon/logo-light.svg">
@@ -345,7 +345,7 @@ Alternatively, you can use `openapi-ts.config.js` and configure the export state
345
345
 
346
346
  You must set the input so we can load your OpenAPI specification. It can be a path or URL, object containing a path or URL, or an object representing an OpenAPI specification. Hey API supports all valid OpenAPI versions and file formats.
347
347
 
348
- > If you use an HTTPS URL with a self-signed certificate in development, you will need to set [`NODE_TLS_REJECT_UNAUTHORIZED=0`](https://github.com/hey-api/openapi-ts/issues/276#issuecomment-2043143501) in your environment.
348
+ > If you use an HTTPS URL with a self-signed certificate in development, you will need to set [`NODE_TLS_REJECT_UNAUTHORIZED=0`](https://github.com/hey-api/hey-api/issues/276#issuecomment-2043143501) in your environment.
349
349
 
350
350
  ### Output
351
351
 
@@ -377,15 +377,15 @@ Clients are responsible for sending the actual HTTP requests. We default to Fetc
377
377
 
378
378
  ### Proposed Clients (Vote to Prioritize)
379
379
 
380
- The following clients are roadmap proposals and are not started yet. You can help us prioritize them by voting on [GitHub](https://github.com/hey-api/openapi-ts/issues?q=state%3Aopen%20label%3A%22vote%20%F0%9F%93%A9%22).
380
+ The following clients are roadmap proposals and are not started yet. You can help us prioritize them by voting on [GitHub](https://github.com/hey-api/hey-api/issues?q=state%3Aopen%20label%3A%22vote%20%F0%9F%93%A9%22).
381
381
 
382
382
  - [`@hey-api/client-effect`](https://heyapi.dev/docs/openapi/typescript/clients/effect)
383
383
 
384
- Don't see your client? [Build your own](https://heyapi.dev/docs/openapi/typescript/clients/custom) or let us know your interest by [opening an issue](https://github.com/hey-api/openapi-ts/issues).
384
+ Don't see your client? [Build your own](https://heyapi.dev/docs/openapi/typescript/clients/custom) or let us know your interest by [opening an issue](https://github.com/hey-api/hey-api/issues).
385
385
 
386
386
  ### Available Plugins
387
387
 
388
- These plugins help reduce boilerplate associated with third-party dependencies. Hey API natively supports the most popular packages. Please open an issue on [GitHub](https://github.com/hey-api/openapi-ts/issues) if you'd like us to support your favorite package.
388
+ These plugins help reduce boilerplate associated with third-party dependencies. Hey API natively supports the most popular packages. Please open an issue on [GitHub](https://github.com/hey-api/hey-api/issues) if you'd like us to support your favorite package.
389
389
 
390
390
  - [`@angular/common`](https://heyapi.dev/docs/openapi/typescript/plugins/angular)
391
391
  - [`@hey-api/schemas`](https://heyapi.dev/docs/openapi/typescript/plugins/schemas)
@@ -407,7 +407,7 @@ These plugins help reduce boilerplate associated with third-party dependencies.
407
407
 
408
408
  ### Proposed Plugins (Vote to Prioritize)
409
409
 
410
- The following plugins are roadmap proposals and are not started yet. You can help us prioritize them by voting on [GitHub](https://github.com/hey-api/openapi-ts/issues?q=state%3Aopen%20label%3A%22vote%20%F0%9F%93%A9%22).
410
+ The following plugins are roadmap proposals and are not started yet. You can help us prioritize them by voting on [GitHub](https://github.com/hey-api/hey-api/issues?q=state%3Aopen%20label%3A%22vote%20%F0%9F%93%A9%22).
411
411
 
412
412
  - [Adonis](https://heyapi.dev/docs/openapi/typescript/plugins/adonis)
413
413
  - [Ajv](https://heyapi.dev/docs/openapi/typescript/plugins/ajv)
@@ -430,7 +430,7 @@ The following plugins are roadmap proposals and are not started yet. You can hel
430
430
  - [Yup](https://heyapi.dev/docs/openapi/typescript/plugins/yup)
431
431
  - [Zustand](https://heyapi.dev/docs/openapi/typescript/plugins/zustand)
432
432
 
433
- Don't see your plugin? [Build your own](https://heyapi.dev/docs/openapi/typescript/plugins/custom) or let us know your interest by [opening an issue](https://github.com/hey-api/openapi-ts/issues).
433
+ Don't see your plugin? [Build your own](https://heyapi.dev/docs/openapi/typescript/plugins/custom) or let us know your interest by [opening an issue](https://github.com/hey-api/hey-api/issues).
434
434
 
435
435
  ## Migrating
436
436
 
@@ -440,6 +440,6 @@ You can learn more on the [Migrating](https://heyapi.dev/docs/openapi/typescript
440
440
 
441
441
  ## License
442
442
 
443
- Released under the [MIT License](https://github.com/hey-api/openapi-ts/blob/main/LICENSE.md).
443
+ Released under the [MIT License](https://github.com/hey-api/hey-api/blob/main/LICENSE.md).
444
444
 
445
445
  <!-- template-license-end -->
@@ -0,0 +1,15 @@
1
+ import { createRequire } from "node:module";
2
+ //#region \0rolldown/runtime.js
3
+ var __defProp = Object.defineProperty;
4
+ var __exportAll = (all, no_symbols) => {
5
+ let target = {};
6
+ for (var name in all) __defProp(target, name, {
7
+ get: all[name],
8
+ enumerable: true
9
+ });
10
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
11
+ return target;
12
+ };
13
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
14
+ //#endregion
15
+ export { __require as n, __exportAll as t };
@@ -86,16 +86,15 @@ function buildKeyMap(fields: FieldsConfig, map?: KeyMap): KeyMap {
86
86
  }
87
87
 
88
88
  interface Params {
89
- body: unknown;
89
+ body?: unknown;
90
90
  headers: Record<string, unknown>;
91
91
  path: Record<string, unknown>;
92
92
  query: Record<string, unknown>;
93
93
  }
94
94
 
95
- type ParamsSlotMap = Record<Slot, unknown>;
96
-
97
- function stripEmptySlots(params: ParamsSlotMap): void {
95
+ function stripEmptySlots(params: Params): void {
98
96
  for (const [slot, value] of Object.entries(params)) {
97
+ if (slot === 'body') continue;
99
98
  if (value && typeof value === 'object' && !Array.isArray(value) && !Object.keys(value).length) {
100
99
  delete params[slot as Slot];
101
100
  }
@@ -103,8 +102,7 @@ function stripEmptySlots(params: ParamsSlotMap): void {
103
102
  }
104
103
 
105
104
  export function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsConfig): Params {
106
- const params: ParamsSlotMap = {
107
- body: Object.create(null),
105
+ const params: Params = {
108
106
  headers: Object.create(null),
109
107
  path: Object.create(null),
110
108
  query: Object.create(null),
@@ -112,6 +110,15 @@ export function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsCo
112
110
 
113
111
  const map = buildKeyMap(fields);
114
112
 
113
+ function writeSlot(slot: Slot, key: string, value: unknown): void {
114
+ let record = params[slot] as Record<string, unknown> | undefined;
115
+ if (record === undefined) {
116
+ record = Object.create(null) as Record<string, unknown>;
117
+ params[slot] = record;
118
+ }
119
+ record[key] = value;
120
+ }
121
+
115
122
  let config: FieldsConfig[number] | undefined;
116
123
 
117
124
  for (const [index, arg] of args.entries()) {
@@ -128,7 +135,7 @@ export function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsCo
128
135
  const field = map.get(config.key)!;
129
136
  const name = field.map || config.key;
130
137
  if (field.in) {
131
- (params[field.in] as Record<string, unknown>)[name] = arg;
138
+ writeSlot(field.in, name, arg);
132
139
  }
133
140
  } else {
134
141
  params.body = arg;
@@ -140,7 +147,7 @@ export function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsCo
140
147
  if (field) {
141
148
  if (field.in) {
142
149
  const name = field.map || key;
143
- (params[field.in] as Record<string, unknown>)[name] = value;
150
+ writeSlot(field.in, name, value);
144
151
  } else {
145
152
  params[field.map] = value;
146
153
  }
@@ -149,11 +156,11 @@ export function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsCo
149
156
 
150
157
  if (extra) {
151
158
  const [prefix, slot] = extra;
152
- (params[slot] as Record<string, unknown>)[key.slice(prefix.length)] = value;
159
+ writeSlot(slot, key.slice(prefix.length), value);
153
160
  } else if ('allowExtra' in config && config.allowExtra) {
154
161
  for (const [slot, allowed] of Object.entries(config.allowExtra)) {
155
162
  if (allowed) {
156
- (params[slot as Slot] as Record<string, unknown>)[key] = value;
163
+ writeSlot(slot as Slot, key, value);
157
164
  break;
158
165
  }
159
166
  }
@@ -165,5 +172,5 @@ export function buildClientParams(args: ReadonlyArray<unknown>, fields: FieldsCo
165
172
 
166
173
  stripEmptySlots(params);
167
174
 
168
- return params as Params;
175
+ return params;
169
176
  }