Skip to content

Commit 941569d

Browse files
committed
ci: regenerated with OpenAPI Doc 0.3.0, Speakeay CLI 1.8.7
1 parent 5d02cc5 commit 941569d

File tree

13 files changed

+444
-197
lines changed

13 files changed

+444
-197
lines changed

RELEASES.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,12 @@ Based on:
166166
- OpenAPI Doc 0.3.0 https://docs.speakeasyapi.dev/openapi.yaml
167167
- Speakeasy CLI 1.8.6 https://github.com/speakeasy-api/speakeasy
168168
### Releases
169-
- [NPM v1.8.5] https://www.npmjs.com/package/@speakeasy-api/speakeasy-client-sdk-typescript/v/1.8.5 - .
169+
- [NPM v1.8.5] https://www.npmjs.com/package/@speakeasy-api/speakeasy-client-sdk-typescript/v/1.8.5 - .
170+
171+
## 2023-03-09 00:11:44
172+
### Changes
173+
Based on:
174+
- OpenAPI Doc 0.3.0 https://docs.speakeasyapi.dev/openapi.yaml
175+
- Speakeasy CLI 1.8.7 https://github.com/speakeasy-api/speakeasy
176+
### Releases
177+
- [NPM v1.8.6] https://www.npmjs.com/package/@speakeasy-api/speakeasy-client-sdk-typescript/v/1.8.6 - .

gen.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ configVersion: 1.0.0
22
management:
33
docChecksum: 2bba3b8f9d211b02569b3f9aff0d34b4
44
docVersion: 0.3.0
5-
speakeasyVersion: 1.8.6
5+
speakeasyVersion: 1.8.7
66
generation:
77
telemetryEnabled: true
88
sdkClassName: speakeasy
99
sdkFlattening: true
1010
typescript:
11-
version: 1.8.5
11+
version: 1.8.6
1212
author: Speakeasy
1313
packageName: '@speakeasy-api/speakeasy-client-sdk-typescript'

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@speakeasy-api/speakeasy-client-sdk-typescript",
3-
"version": "1.8.5",
3+
"version": "1.8.6",
44
"author": "Speakeasy",
55
"scripts": {
66
"prepare": "tsc --build"

src/internal/utils/utils.ts

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import "reflect-metadata";
22

33
import { getSimplePathParams, ppMetadataKey } from "./pathparams";
4+
import { plainToInstance } from "class-transformer";
45

56
interface propInfo {
67
key: string | symbol;
@@ -301,3 +302,54 @@ export function encodeAndConvertPrimitiveVal(
301302
convertIfDateObjectToISOString(value, dateTimeFormat)
302303
);
303304
}
305+
306+
export function deserializeJSONResponse<T>(
307+
value: T,
308+
klass?: any,
309+
elemDepth: number = 0): any {
310+
311+
if (value !== Object(value)) {
312+
return value;
313+
}
314+
315+
if (elemDepth === 0 && klass != null) {
316+
return plainToInstance(klass, value, { excludeExtraneousValues: true }) as typeof klass;
317+
}
318+
319+
if (Array.isArray(value)) {
320+
return value.map((v) => deserializeJSONResponse(v, klass, elemDepth-1));
321+
}
322+
323+
if (typeof value === 'object' && value != null) {
324+
let copiedRecord: Record<string, any> = {};
325+
for (const key in value) {
326+
copiedRecord[key] = deserializeJSONResponse(value[key], klass, elemDepth-1);
327+
}
328+
return copiedRecord;
329+
}
330+
331+
return plainToInstance(klass, value, { excludeExtraneousValues: true }) as typeof klass;
332+
}
333+
334+
export function getResFieldDepth(res: any): number {
335+
const props = res["__props__"];
336+
let resFieldDepth = 1;
337+
338+
if (props) {
339+
for (const prop of props) {
340+
if (res && res.hasOwnProperty(prop.key)) {
341+
if (
342+
(prop.type.name == "Array" || prop.type.name == "Object") &&
343+
isSpeakeasyBase(prop.elemType)
344+
) {
345+
if (prop.elemDepth > resFieldDepth) {
346+
resFieldDepth = prop.elemDepth;
347+
break;
348+
}
349+
}
350+
}
351+
}
352+
}
353+
354+
return resFieldDepth;
355+
}

src/sdk/apiendpoints.ts

Lines changed: 86 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,20 @@ export class ApiEndpoints {
5353
const contentType: string = httpRes?.headers?.["content-type"] ?? "";
5454

5555
if (httpRes?.status == null) throw new Error(`status code not found in response: ${httpRes}`);
56-
const res: operations.DeleteApiEndpointResponse = {statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes};
56+
const res: operations.DeleteApiEndpointResponse =
57+
new operations.DeleteApiEndpointResponse({
58+
statusCode: httpRes.status,
59+
contentType: contentType,
60+
rawResponse: httpRes
61+
});
5762
switch (true) {
5863
case httpRes?.status == 200:
5964
break;
6065
default:
6166
if (utils.matchContentType(contentType, `application/json`)) {
62-
res.error = plainToInstance(
67+
res.error = utils.deserializeJSONResponse(
68+
httpRes?.data,
6369
shared.ErrorT,
64-
httpRes?.data as shared.ErrorT,
65-
{ excludeExtraneousValues: true }
6670
);
6771
}
6872
break;
@@ -106,23 +110,26 @@ export class ApiEndpoints {
106110
const contentType: string = httpRes?.headers?.["content-type"] ?? "";
107111

108112
if (httpRes?.status == null) throw new Error(`status code not found in response: ${httpRes}`);
109-
const res: operations.FindApiEndpointResponse = {statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes};
113+
const res: operations.FindApiEndpointResponse =
114+
new operations.FindApiEndpointResponse({
115+
statusCode: httpRes.status,
116+
contentType: contentType,
117+
rawResponse: httpRes
118+
});
110119
switch (true) {
111120
case httpRes?.status == 200:
112121
if (utils.matchContentType(contentType, `application/json`)) {
113-
res.apiEndpoint = plainToInstance(
122+
res.apiEndpoint = utils.deserializeJSONResponse(
123+
httpRes?.data,
114124
shared.ApiEndpoint,
115-
httpRes?.data as shared.ApiEndpoint,
116-
{ excludeExtraneousValues: true }
117125
);
118126
}
119127
break;
120128
default:
121129
if (utils.matchContentType(contentType, `application/json`)) {
122-
res.error = plainToInstance(
130+
res.error = utils.deserializeJSONResponse(
131+
httpRes?.data,
123132
shared.ErrorT,
124-
httpRes?.data as shared.ErrorT,
125-
{ excludeExtraneousValues: true }
126133
);
127134
}
128135
break;
@@ -166,23 +173,26 @@ export class ApiEndpoints {
166173
const contentType: string = httpRes?.headers?.["content-type"] ?? "";
167174

168175
if (httpRes?.status == null) throw new Error(`status code not found in response: ${httpRes}`);
169-
const res: operations.GenerateOpenApiSpecForApiEndpointResponse = {statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes};
176+
const res: operations.GenerateOpenApiSpecForApiEndpointResponse =
177+
new operations.GenerateOpenApiSpecForApiEndpointResponse({
178+
statusCode: httpRes.status,
179+
contentType: contentType,
180+
rawResponse: httpRes
181+
});
170182
switch (true) {
171183
case httpRes?.status == 200:
172184
if (utils.matchContentType(contentType, `application/json`)) {
173-
res.generateOpenApiSpecDiff = plainToInstance(
185+
res.generateOpenApiSpecDiff = utils.deserializeJSONResponse(
186+
httpRes?.data,
174187
shared.GenerateOpenApiSpecDiff,
175-
httpRes?.data as shared.GenerateOpenApiSpecDiff,
176-
{ excludeExtraneousValues: true }
177188
);
178189
}
179190
break;
180191
default:
181192
if (utils.matchContentType(contentType, `application/json`)) {
182-
res.error = plainToInstance(
193+
res.error = utils.deserializeJSONResponse(
194+
httpRes?.data,
183195
shared.ErrorT,
184-
httpRes?.data as shared.ErrorT,
185-
{ excludeExtraneousValues: true }
186196
);
187197
}
188198
break;
@@ -225,7 +235,12 @@ export class ApiEndpoints {
225235
const contentType: string = httpRes?.headers?.["content-type"] ?? "";
226236

227237
if (httpRes?.status == null) throw new Error(`status code not found in response: ${httpRes}`);
228-
const res: operations.GeneratePostmanCollectionForApiEndpointResponse = {statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes};
238+
const res: operations.GeneratePostmanCollectionForApiEndpointResponse =
239+
new operations.GeneratePostmanCollectionForApiEndpointResponse({
240+
statusCode: httpRes.status,
241+
contentType: contentType,
242+
rawResponse: httpRes
243+
});
229244
switch (true) {
230245
case httpRes?.status == 200:
231246
if (utils.matchContentType(contentType, `application/octet-stream`)) {
@@ -237,10 +252,9 @@ export class ApiEndpoints {
237252
break;
238253
default:
239254
if (utils.matchContentType(contentType, `application/json`)) {
240-
res.error = plainToInstance(
255+
res.error = utils.deserializeJSONResponse(
256+
httpRes?.data,
241257
shared.ErrorT,
242-
httpRes?.data as shared.ErrorT,
243-
{ excludeExtraneousValues: true }
244258
);
245259
}
246260
break;
@@ -281,19 +295,29 @@ export class ApiEndpoints {
281295
const contentType: string = httpRes?.headers?.["content-type"] ?? "";
282296

283297
if (httpRes?.status == null) throw new Error(`status code not found in response: ${httpRes}`);
284-
const res: operations.GetAllApiEndpointsResponse = {statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes};
298+
const res: operations.GetAllApiEndpointsResponse =
299+
new operations.GetAllApiEndpointsResponse({
300+
statusCode: httpRes.status,
301+
contentType: contentType,
302+
rawResponse: httpRes
303+
});
285304
switch (true) {
286305
case httpRes?.status == 200:
287306
if (utils.matchContentType(contentType, `application/json`)) {
288-
res.apiEndpoints = httpRes?.data;
307+
res.apiEndpoints = [];
308+
const resFieldDepth: number = utils.getResFieldDepth(res);
309+
res.apiEndpoints = utils.deserializeJSONResponse(
310+
httpRes?.data,
311+
shared.ApiEndpoint,
312+
resFieldDepth
313+
);
289314
}
290315
break;
291316
default:
292317
if (utils.matchContentType(contentType, `application/json`)) {
293-
res.error = plainToInstance(
318+
res.error = utils.deserializeJSONResponse(
319+
httpRes?.data,
294320
shared.ErrorT,
295-
httpRes?.data as shared.ErrorT,
296-
{ excludeExtraneousValues: true }
297321
);
298322
}
299323
break;
@@ -334,19 +358,29 @@ export class ApiEndpoints {
334358
const contentType: string = httpRes?.headers?.["content-type"] ?? "";
335359

336360
if (httpRes?.status == null) throw new Error(`status code not found in response: ${httpRes}`);
337-
const res: operations.GetAllForVersionApiEndpointsResponse = {statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes};
361+
const res: operations.GetAllForVersionApiEndpointsResponse =
362+
new operations.GetAllForVersionApiEndpointsResponse({
363+
statusCode: httpRes.status,
364+
contentType: contentType,
365+
rawResponse: httpRes
366+
});
338367
switch (true) {
339368
case httpRes?.status == 200:
340369
if (utils.matchContentType(contentType, `application/json`)) {
341-
res.apiEndpoints = httpRes?.data;
370+
res.apiEndpoints = [];
371+
const resFieldDepth: number = utils.getResFieldDepth(res);
372+
res.apiEndpoints = utils.deserializeJSONResponse(
373+
httpRes?.data,
374+
shared.ApiEndpoint,
375+
resFieldDepth
376+
);
342377
}
343378
break;
344379
default:
345380
if (utils.matchContentType(contentType, `application/json`)) {
346-
res.error = plainToInstance(
381+
res.error = utils.deserializeJSONResponse(
382+
httpRes?.data,
347383
shared.ErrorT,
348-
httpRes?.data as shared.ErrorT,
349-
{ excludeExtraneousValues: true }
350384
);
351385
}
352386
break;
@@ -387,23 +421,26 @@ export class ApiEndpoints {
387421
const contentType: string = httpRes?.headers?.["content-type"] ?? "";
388422

389423
if (httpRes?.status == null) throw new Error(`status code not found in response: ${httpRes}`);
390-
const res: operations.GetApiEndpointResponse = {statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes};
424+
const res: operations.GetApiEndpointResponse =
425+
new operations.GetApiEndpointResponse({
426+
statusCode: httpRes.status,
427+
contentType: contentType,
428+
rawResponse: httpRes
429+
});
391430
switch (true) {
392431
case httpRes?.status == 200:
393432
if (utils.matchContentType(contentType, `application/json`)) {
394-
res.apiEndpoint = plainToInstance(
433+
res.apiEndpoint = utils.deserializeJSONResponse(
434+
httpRes?.data,
395435
shared.ApiEndpoint,
396-
httpRes?.data as shared.ApiEndpoint,
397-
{ excludeExtraneousValues: true }
398436
);
399437
}
400438
break;
401439
default:
402440
if (utils.matchContentType(contentType, `application/json`)) {
403-
res.error = plainToInstance(
441+
res.error = utils.deserializeJSONResponse(
442+
httpRes?.data,
404443
shared.ErrorT,
405-
httpRes?.data as shared.ErrorT,
406-
{ excludeExtraneousValues: true }
407444
);
408445
}
409446
break;
@@ -458,23 +495,26 @@ export class ApiEndpoints {
458495
const contentType: string = httpRes?.headers?.["content-type"] ?? "";
459496

460497
if (httpRes?.status == null) throw new Error(`status code not found in response: ${httpRes}`);
461-
const res: operations.UpsertApiEndpointResponse = {statusCode: httpRes.status, contentType: contentType, rawResponse: httpRes};
498+
const res: operations.UpsertApiEndpointResponse =
499+
new operations.UpsertApiEndpointResponse({
500+
statusCode: httpRes.status,
501+
contentType: contentType,
502+
rawResponse: httpRes
503+
});
462504
switch (true) {
463505
case httpRes?.status == 200:
464506
if (utils.matchContentType(contentType, `application/json`)) {
465-
res.apiEndpoint = plainToInstance(
507+
res.apiEndpoint = utils.deserializeJSONResponse(
508+
httpRes?.data,
466509
shared.ApiEndpoint,
467-
httpRes?.data as shared.ApiEndpoint,
468-
{ excludeExtraneousValues: true }
469510
);
470511
}
471512
break;
472513
default:
473514
if (utils.matchContentType(contentType, `application/json`)) {
474-
res.error = plainToInstance(
515+
res.error = utils.deserializeJSONResponse(
516+
httpRes?.data,
475517
shared.ErrorT,
476-
httpRes?.data as shared.ErrorT,
477-
{ excludeExtraneousValues: true }
478518
);
479519
}
480520
break;

0 commit comments

Comments
 (0)