Skip to content

Commit 47d90b6

Browse files
committed
ci: regenerated with OpenAPI Doc 0.3.0, Speakeay CLI 1.11.0
1 parent 20d2e67 commit 47d90b6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+2064
-1698
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@ import {
2626

2727
import { AxiosError } from "axios";
2828
import { Speakeasy } from "@speakeasy-api/speakeasy-client-sdk-typescript";
29-
3029
const sdk = new Speakeasy({
3130
security: {
3231
apiKey: "YOUR_API_KEY_HERE",
33-
}
32+
},
3433
});
3534

3635
const req: GetApisRequest = {

RELEASES.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,4 +190,12 @@ Based on:
190190
- OpenAPI Doc 0.3.0 https://docs.speakeasyapi.dev/openapi.yaml
191191
- Speakeasy CLI 1.9.2 https://github.com/speakeasy-api/speakeasy
192192
### Releases
193-
- [NPM v1.9.1] https://www.npmjs.com/package/@speakeasy-api/speakeasy-client-sdk-typescript/v/1.9.1 - .
193+
- [NPM v1.9.1] https://www.npmjs.com/package/@speakeasy-api/speakeasy-client-sdk-typescript/v/1.9.1 - .
194+
195+
## 2023-03-15 00:11:13
196+
### Changes
197+
Based on:
198+
- OpenAPI Doc 0.3.0 https://docs.speakeasyapi.dev/openapi.yaml
199+
- Speakeasy CLI 1.11.0 https://github.com/speakeasy-api/speakeasy
200+
### Releases
201+
- [NPM v1.10.0] https://www.npmjs.com/package/@speakeasy-api/speakeasy-client-sdk-typescript/v/1.10.0 - .

USAGE.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@ import {
77

88
import { AxiosError } from "axios";
99
import { Speakeasy } from "@speakeasy-api/speakeasy-client-sdk-typescript";
10-
1110
const sdk = new Speakeasy({
1211
security: {
1312
apiKey: "YOUR_API_KEY_HERE",
14-
}
13+
},
1514
});
1615

1716
const req: GetApisRequest = {

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.9.2
5+
speakeasyVersion: 1.11.0
66
generation:
77
telemetryEnabled: true
88
sdkClassName: speakeasy
99
sdkFlattening: true
1010
typescript:
11-
version: 1.9.1
11+
version: 1.10.0
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.9.1",
3+
"version": "1.10.0",
44
"author": "Speakeasy",
55
"scripts": {
66
"prepare": "tsc --build"

src/internal/utils/queryparams.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,24 @@
1-
import { ParamDecorator } from "./utils";
21
import {
32
convertIfDateObjectToISOString,
43
encodeAndConvertPrimitiveVal,
54
parseParamDecorator,
5+
populateFromGlobals,
66
} from "./utils";
77

8+
import { ParamDecorator } from "./utils";
9+
810
export const qpMetadataKey = "queryParam";
911
const queryStringPrefix = "?";
1012

11-
export function serializeQueryParams(queryParams: any): string {
13+
export function serializeQueryParams(queryParams: any, globals?: any): string {
1214
let queryStringParts: string[] = [];
1315
if (!queryParams) return queryStringParts.join("&");
1416

15-
const fieldNames: string[] = Object.getOwnPropertyNames(queryParams);
17+
const fieldNames: string[] =
18+
"__props__" in queryParams
19+
? queryParams["__props__"].map((prop: any) => prop.key)
20+
: Object.getOwnPropertyNames(queryParams);
21+
1622
fieldNames.forEach((fname) => {
1723
const qpAnn: string = Reflect.getMetadata(
1824
qpMetadataKey,
@@ -31,38 +37,35 @@ export function serializeQueryParams(queryParams: any): string {
3137

3238
if (!qpDecorator) return;
3339

40+
let value = queryParams[fname];
41+
value = populateFromGlobals(value, fname, "queryParam", globals);
42+
3443
if (qpDecorator.Serialization === "json")
35-
queryStringParts.push(jsonSerializer({ [fname]: queryParams[fname] }));
44+
queryStringParts.push(jsonSerializer({ [fname]: value }));
3645
else {
3746
switch (qpDecorator.Style) {
3847
case "deepObject":
3948
queryStringParts.push(
40-
deepObjectSerializer(
41-
{ [fname]: queryParams[fname] },
42-
qpDecorator.DateTimeFormat
43-
)
49+
deepObjectSerializer({ [fname]: value }, qpDecorator.DateTimeFormat)
4450
);
4551
return;
4652
case "form":
4753
if (!qpDecorator.Explode)
4854
queryStringParts.push(
49-
formSerializer(
50-
{ [fname]: queryParams[fname] },
51-
qpDecorator.DateTimeFormat
52-
)
55+
formSerializer({ [fname]: value }, qpDecorator.DateTimeFormat)
5356
);
5457
else
5558
queryStringParts.push(
5659
formSerializerExplode(
57-
{ [fname]: queryParams[fname] },
60+
{ [fname]: value },
5861
qpDecorator.DateTimeFormat
5962
)
6063
);
6164
return;
6265
default:
6366
queryStringParts.push(
6467
formSerializerExplode(
65-
{ [fname]: queryParams[fname] },
68+
{ [fname]: value },
6669
qpDecorator.DateTimeFormat
6770
)
6871
);
@@ -182,7 +185,6 @@ function formSerializerExplode(
182185
query.push(
183186
Object.getOwnPropertyNames(value)
184187
.map((paramKey: string) => {
185-
186188
const qpAnn: string = Reflect.getMetadata(
187189
qpMetadataKey,
188190
value,
@@ -238,7 +240,6 @@ function deepObjectSerializer(
238240
query.push(
239241
Object.getOwnPropertyNames(value)
240242
.map((paramKey: string) => {
241-
242243
const qpAnn: string = Reflect.getMetadata(
243244
qpMetadataKey,
244245
value,

src/internal/utils/utils.ts

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import "reflect-metadata";
22

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

6-
interface propInfo {
7+
export interface PropInfo {
78
key: string | symbol;
89
type: any;
910
elemType: any;
@@ -61,7 +62,7 @@ function handleObject(value: any, elemType: any, elemDepth: number): any {
6162

6263
export class SpeakeasyBase {
6364
constructor(payload?: Record<string | symbol, unknown>) {
64-
const props: propInfo[] = (this as any)["__props__"];
65+
const props: PropInfo[] = (this as any)["__props__"];
6566
if (props) {
6667
for (const prop of props) {
6768
if (payload && payload.hasOwnProperty(prop.key)) {
@@ -132,7 +133,7 @@ export function SpeakeasyMetadata<
132133
}
133134
}
134135

135-
let props: propInfo[];
136+
let props: PropInfo[];
136137
if (target.hasOwnProperty("__props__")) {
137138
props = (target as any)["__props__"];
138139
} else {
@@ -142,7 +143,7 @@ export function SpeakeasyMetadata<
142143
const prop = {
143144
key: propertyKey,
144145
type: Reflect.getMetadata("design:type", target, propertyKey),
145-
} as propInfo;
146+
} as PropInfo;
146147

147148
if (params?.elemType) {
148149
prop.elemType = params.elemType;
@@ -168,11 +169,16 @@ export function templateUrl(
168169
export function generateURL(
169170
serverURL: string,
170171
path: string,
171-
pathParams: any
172+
pathParams: any,
173+
globals?: any
172174
): string {
173175
const url: string = serverURL.replace(/\/$/, "") + path;
174176
const parsedParameters: Record<string, string> = {};
175-
const fieldNames: string[] = Object.getOwnPropertyNames(pathParams);
177+
178+
const fieldNames: string[] =
179+
"__props__" in pathParams
180+
? pathParams["__props__"].map((prop: any) => prop.key)
181+
: Object.getOwnPropertyNames(pathParams);
176182
fieldNames.forEach((fname) => {
177183
const ppAnn: string = Reflect.getMetadata(ppMetadataKey, pathParams, fname);
178184
if (ppAnn == null) return;
@@ -183,11 +189,15 @@ export function generateURL(
183189
false
184190
);
185191
if (ppDecorator == null) return;
192+
193+
let value = pathParams[fname];
194+
value = populateFromGlobals(value, fname, "pathParam", globals);
195+
186196
switch (ppDecorator.Style) {
187197
case "simple":
188198
const simpleParams: Map<string, string> = getSimplePathParams(
189199
ppDecorator.ParamName,
190-
pathParams[fname],
200+
value,
191201
ppDecorator.Explode,
192202
ppDecorator.DateTimeFormat
193203
);
@@ -306,29 +316,37 @@ export function encodeAndConvertPrimitiveVal(
306316
export function deserializeJSONResponse<T>(
307317
value: T,
308318
klass?: any,
309-
elemDepth: number = 0): any {
310-
319+
elemDepth: number = 0
320+
): any {
311321
if (value !== Object(value)) {
312322
return value;
313323
}
314324

315325
if (elemDepth === 0 && klass != null) {
316-
return plainToInstance(klass, value, { excludeExtraneousValues: true }) as typeof klass;
326+
return plainToInstance(klass, value, {
327+
excludeExtraneousValues: true,
328+
}) as typeof klass;
317329
}
318330

319331
if (Array.isArray(value)) {
320-
return value.map((v) => deserializeJSONResponse(v, klass, elemDepth-1));
332+
return value.map((v) => deserializeJSONResponse(v, klass, elemDepth - 1));
321333
}
322334

323-
if (typeof value === 'object' && value != null) {
335+
if (typeof value === "object" && value != null) {
324336
let copiedRecord: Record<string, any> = {};
325337
for (const key in value) {
326-
copiedRecord[key] = deserializeJSONResponse(value[key], klass, elemDepth-1);
338+
copiedRecord[key] = deserializeJSONResponse(
339+
value[key],
340+
klass,
341+
elemDepth - 1
342+
);
327343
}
328344
return copiedRecord;
329345
}
330346

331-
return plainToInstance(klass, value, { excludeExtraneousValues: true }) as typeof klass;
347+
return plainToInstance(klass, value, {
348+
excludeExtraneousValues: true,
349+
}) as typeof klass;
332350
}
333351

334352
export function getResFieldDepth(res: any): number {
@@ -353,3 +371,21 @@ export function getResFieldDepth(res: any): number {
353371

354372
return resFieldDepth;
355373
}
374+
375+
export function populateFromGlobals(
376+
value: any,
377+
fieldName: string,
378+
paramType: string,
379+
globals: any
380+
): any {
381+
if (globals && value === undefined) {
382+
if ("parameters" in globals && paramType in globals.parameters) {
383+
let globalValue = globals.parameters[paramType][fieldName];
384+
if (globalValue !== undefined) {
385+
value = globalValue;
386+
}
387+
}
388+
}
389+
390+
return value;
391+
}

0 commit comments

Comments
 (0)