@hey-api/openapi-ts 0.80.16 → 0.80.17

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
@@ -318,8 +318,10 @@ The following plugins are planned but not in development yet. You can help us pr
318
318
  - [Adonis](https://heyapi.dev/openapi-ts/plugins/adonis)
319
319
  - [Ajv](https://heyapi.dev/openapi-ts/plugins/ajv)
320
320
  - [Arktype](https://heyapi.dev/openapi-ts/plugins/arktype)
321
+ - [Chance](https://heyapi.dev/openapi-ts/plugins/chance)
321
322
  - [Express](https://heyapi.dev/openapi-ts/plugins/express)
322
323
  - [Faker](https://heyapi.dev/openapi-ts/plugins/faker)
324
+ - [Falso](https://heyapi.dev/openapi-ts/plugins/falso)
323
325
  - [Hono](https://heyapi.dev/openapi-ts/plugins/hono)
324
326
  - [Joi](https://heyapi.dev/openapi-ts/plugins/joi)
325
327
  - [Koa](https://heyapi.dev/openapi-ts/plugins/koa)
@@ -65,7 +65,6 @@ export const createClient = (config: Config = {}): Client => {
65
65
  ...options,
66
66
  headers: mergeHeaders(_config.headers, options.headers),
67
67
  httpClient: options.httpClient ?? _config.httpClient,
68
- method: 'GET',
69
68
  serializedBody: options.body as any,
70
69
  };
71
70
 
@@ -92,7 +91,7 @@ export const createClient = (config: Config = {}): Client => {
92
91
  const url = buildUrl(opts as any);
93
92
 
94
93
  const req = new HttpRequest<unknown>(
95
- opts.method,
94
+ opts.method ?? 'GET',
96
95
  url,
97
96
  opts.serializedBody || null,
98
97
  {
@@ -126,26 +125,28 @@ export const createClient = (config: Config = {}): Client => {
126
125
  }
127
126
  }
128
127
 
129
- let response;
130
- const result = {
128
+ const result: {
129
+ request: HttpRequest<unknown>;
130
+ response: any;
131
+ } = {
131
132
  request: req,
132
- response,
133
+ response: null,
133
134
  };
134
135
 
135
136
  try {
136
- response = await firstValueFrom(
137
+ result.response = (await firstValueFrom(
137
138
  opts
138
139
  .httpClient!.request(req)
139
140
  .pipe(filter((event) => event.type === HttpEventType.Response)),
140
- );
141
+ )) as HttpResponse<unknown>;
141
142
 
142
143
  for (const fn of interceptors.response._fns) {
143
144
  if (fn) {
144
- response = await fn(response, req, opts as any);
145
+ result.response = await fn(result.response, req, opts as any);
145
146
  }
146
147
  }
147
148
 
148
- let bodyResponse: any = response.body;
149
+ let bodyResponse = result.response.body;
149
150
 
150
151
  if (opts.responseValidator) {
151
152
  await opts.responseValidator(bodyResponse);
@@ -160,7 +161,7 @@ export const createClient = (config: Config = {}): Client => {
160
161
  : { data: bodyResponse, ...result };
161
162
  } catch (error) {
162
163
  if (error instanceof HttpErrorResponse) {
163
- response = error;
164
+ result.response = error;
164
165
  }
165
166
 
166
167
  let finalError = error instanceof HttpErrorResponse ? error.error : error;
@@ -169,7 +170,7 @@ export const createClient = (config: Config = {}): Client => {
169
170
  if (fn) {
170
171
  finalError = (await fn(
171
172
  finalError,
172
- response as HttpResponse<unknown>,
173
+ result.response as any,
173
174
  req,
174
175
  opts as any,
175
176
  )) as string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hey-api/openapi-ts",
3
- "version": "0.80.16",
3
+ "version": "0.80.17",
4
4
  "description": "🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more.",
5
5
  "homepage": "https://heyapi.dev/",
6
6
  "repository": {