Skip to content

Commit 2d5c036

Browse files
committed
ci: regenerated with OpenAPI Doc 0.3.0, Speakeay CLI 1.12.0
1 parent 47d90b6 commit 2d5c036

Some content is hidden

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

50 files changed

+272
-394
lines changed

README.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,29 +31,27 @@ const sdk = new Speakeasy({
3131
apiKey: "YOUR_API_KEY_HERE",
3232
},
3333
});
34-
34+
3535
const req: GetApisRequest = {
36-
queryParams: {
37-
metadata: {
38-
"deserunt": [
39-
"nulla",
40-
"id",
41-
"vero",
42-
],
43-
"perspiciatis": [
44-
"nihil",
45-
"fuga",
46-
"facilis",
47-
"eum",
48-
],
49-
"iusto": [
50-
"saepe",
51-
"inventore",
52-
],
53-
},
54-
op: {
55-
and: false,
56-
},
36+
metadata: {
37+
"deserunt": [
38+
"nulla",
39+
"id",
40+
"vero",
41+
],
42+
"perspiciatis": [
43+
"nihil",
44+
"fuga",
45+
"facilis",
46+
"eum",
47+
],
48+
"iusto": [
49+
"saepe",
50+
"inventore",
51+
],
52+
},
53+
op: {
54+
and: false,
5755
},
5856
};
5957

RELEASES.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,4 +198,12 @@ Based on:
198198
- OpenAPI Doc 0.3.0 https://docs.speakeasyapi.dev/openapi.yaml
199199
- Speakeasy CLI 1.11.0 https://github.com/speakeasy-api/speakeasy
200200
### Releases
201-
- [NPM v1.10.0] https://www.npmjs.com/package/@speakeasy-api/speakeasy-client-sdk-typescript/v/1.10.0 - .
201+
- [NPM v1.10.0] https://www.npmjs.com/package/@speakeasy-api/speakeasy-client-sdk-typescript/v/1.10.0 - .
202+
203+
## 2023-03-16 00:12:49
204+
### Changes
205+
Based on:
206+
- OpenAPI Doc 0.3.0 https://docs.speakeasyapi.dev/openapi.yaml
207+
- Speakeasy CLI 1.12.0 https://github.com/speakeasy-api/speakeasy
208+
### Releases
209+
- [NPM v1.11.0] https://www.npmjs.com/package/@speakeasy-api/speakeasy-client-sdk-typescript/v/1.11.0 - .

USAGE.md

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,27 @@ const sdk = new Speakeasy({
1212
apiKey: "YOUR_API_KEY_HERE",
1313
},
1414
});
15-
15+
1616
const req: GetApisRequest = {
17-
queryParams: {
18-
metadata: {
19-
"deserunt": [
20-
"nulla",
21-
"id",
22-
"vero",
23-
],
24-
"perspiciatis": [
25-
"nihil",
26-
"fuga",
27-
"facilis",
28-
"eum",
29-
],
30-
"iusto": [
31-
"saepe",
32-
"inventore",
33-
],
34-
},
35-
op: {
36-
and: false,
37-
},
17+
metadata: {
18+
"deserunt": [
19+
"nulla",
20+
"id",
21+
"vero",
22+
],
23+
"perspiciatis": [
24+
"nihil",
25+
"fuga",
26+
"facilis",
27+
"eum",
28+
],
29+
"iusto": [
30+
"saepe",
31+
"inventore",
32+
],
33+
},
34+
op: {
35+
and: false,
3836
},
3937
};
4038

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

src/internal/utils/headers.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
ParamDecorator,
99
convertIfDateObjectToISOString,
1010
} from "./utils";
11+
import {requestMetadataKey} from "./requestbody";
1112

1213
export const headerMetadataKey = "header";
1314

@@ -18,6 +19,14 @@ export function getHeadersFromRequest(headerParams: any): any {
1819

1920
const fieldNames: string[] = Object.getOwnPropertyNames(headerParams);
2021
fieldNames.forEach((fname) => {
22+
const requestBodyAnn: string = Reflect.getMetadata(
23+
requestMetadataKey,
24+
headerParams,
25+
fname
26+
);
27+
28+
if (requestBodyAnn) return;
29+
2130
const headerAnn: string = Reflect.getMetadata(
2231
headerMetadataKey,
2332
headerParams,

src/internal/utils/queryparams.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
} from "./utils";
77

88
import { ParamDecorator } from "./utils";
9+
import {requestMetadataKey} from "./requestbody";
910

1011
export const qpMetadataKey = "queryParam";
1112
const queryStringPrefix = "?";
@@ -20,6 +21,14 @@ export function serializeQueryParams(queryParams: any, globals?: any): string {
2021
: Object.getOwnPropertyNames(queryParams);
2122

2223
fieldNames.forEach((fname) => {
24+
const requestBodyAnn: string = Reflect.getMetadata(
25+
requestMetadataKey,
26+
queryParams,
27+
fname
28+
);
29+
30+
if (requestBodyAnn) return;
31+
2332
const qpAnn: string = Reflect.getMetadata(
2433
qpMetadataKey,
2534
queryParams,
@@ -41,31 +50,31 @@ export function serializeQueryParams(queryParams: any, globals?: any): string {
4150
value = populateFromGlobals(value, fname, "queryParam", globals);
4251

4352
if (qpDecorator.Serialization === "json")
44-
queryStringParts.push(jsonSerializer({ [fname]: value }));
53+
queryStringParts.push(jsonSerializer({ [qpDecorator.ParamName]: value }));
4554
else {
4655
switch (qpDecorator.Style) {
4756
case "deepObject":
4857
queryStringParts.push(
49-
deepObjectSerializer({ [fname]: value }, qpDecorator.DateTimeFormat)
58+
deepObjectSerializer({ [qpDecorator.ParamName]: value }, qpDecorator.DateTimeFormat)
5059
);
5160
return;
5261
case "form":
5362
if (!qpDecorator.Explode)
5463
queryStringParts.push(
55-
formSerializer({ [fname]: value }, qpDecorator.DateTimeFormat)
64+
formSerializer({ [qpDecorator.ParamName]: value }, qpDecorator.DateTimeFormat)
5665
);
5766
else
5867
queryStringParts.push(
5968
formSerializerExplode(
60-
{ [fname]: value },
69+
{ [qpDecorator.ParamName]: value },
6170
qpDecorator.DateTimeFormat
6271
)
6372
);
6473
return;
6574
default:
6675
queryStringParts.push(
6776
formSerializerExplode(
68-
{ [fname]: value },
77+
{ [qpDecorator.ParamName]: value },
6978
qpDecorator.DateTimeFormat
7079
)
7180
);

src/internal/utils/requestbody.ts

Lines changed: 51 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,78 +3,69 @@ import {
33
convertIfDateObjectToISOString,
44
isBooleanRecord,
55
isNumberRecord,
6-
isStringRecord,
6+
isStringRecord, SerializationMethodToContentType,
77
} from "./utils";
88

9-
const requestMetadataKey = "request";
9+
export const requestMetadataKey = "request";
1010
const mpFormMetadataKey = "multipart_form";
1111

12-
export function serializeRequestBody(request: any): [object, any] {
13-
if (!request.hasOwnProperty(requestMetadataKey)) {
14-
throw new Error("request body not found");
12+
export function serializeRequestBody(request: any, requestFieldName: string, serializationMethod: string): [object, any] {
13+
if (request !== Object(request) || !request.hasOwnProperty(requestFieldName)) {
14+
return serializeContentType(SerializationMethodToContentType[serializationMethod], request);
1515
}
1616

17-
let requestBodyObj = request;
18-
19-
const firstLevelRequestAnn: string = Reflect.getMetadata(
17+
const requestBodyAnn: string = Reflect.getMetadata(
2018
requestMetadataKey,
2119
request,
22-
requestMetadataKey
20+
requestFieldName
2321
);
24-
if (firstLevelRequestAnn == null)
25-
requestBodyObj = request[requestMetadataKey];
26-
27-
let [requestHeaders, requestBody]: [object, any] = [{}, {}];
28-
29-
const fieldNames: string[] = Object.getOwnPropertyNames(requestBodyObj);
30-
fieldNames.forEach((fname) => {
31-
const requestAnn: string = Reflect.getMetadata(
32-
requestMetadataKey,
33-
requestBodyObj,
34-
fname
35-
);
36-
if (requestAnn == null) return;
37-
38-
const requestDecorator: RequestDecorator =
39-
parseRequestDecorator(requestAnn);
40-
41-
switch (requestDecorator.MediaType) {
42-
case "multipart/form-data":
43-
case "multipart/mixed":
44-
requestBody = encodeMultipartFormData(requestBodyObj[fname]);
45-
requestHeaders = (requestBody as FormData).getHeaders();
46-
break;
22+
if (!requestBodyAnn) {
23+
throw new Error("invalid request type");
24+
}
4725

48-
case "application/x-www-form-urlencoded":
49-
[requestHeaders, requestBody] = [
50-
{ "Content-Type": `${requestDecorator.MediaType}` },
51-
encodeFormUrlEncodeData(requestBodyObj[fname]),
52-
];
53-
break;
26+
const requestDecorator: RequestDecorator = parseRequestDecorator(requestBodyAnn);
27+
return serializeContentType(requestDecorator.MediaType, request[requestFieldName]);
28+
}
5429

55-
case "application/json":
56-
case "text/json":
57-
[requestHeaders, requestBody] = [
58-
{ "Content-Type": `${requestDecorator.MediaType}` },
59-
requestBodyObj[fname],
60-
];
61-
break;
30+
const serializeContentType = (contentType: string, reqBody: any): [object, any] => {
31+
let [requestHeaders, requestBody]: [object, any] = [{}, {}];
6232

63-
default:
64-
requestBody = requestBodyObj[fname];
65-
const requestBodyType: string = typeof requestBody;
66-
if (
67-
requestBodyType === "string" ||
68-
requestBody instanceof String ||
69-
requestBody instanceof Uint8Array
70-
)
71-
requestHeaders = { "Content-Type": `${requestDecorator.MediaType}` };
72-
else
73-
throw new Error(
74-
`invalid request body type ${requestBodyType} for mediaType ${requestDecorator.MediaType}`
75-
);
76-
}
77-
});
33+
switch (contentType) {
34+
case "multipart/form-data":
35+
case "multipart/mixed":
36+
requestBody = encodeMultipartFormData(reqBody);
37+
requestHeaders = (requestBody as FormData).getHeaders();
38+
break;
39+
40+
case "application/x-www-form-urlencoded":
41+
[requestHeaders, requestBody] = [
42+
{ "Content-Type": `${contentType}` },
43+
encodeFormUrlEncodeData(reqBody),
44+
];
45+
break;
46+
47+
case "application/json":
48+
case "text/json":
49+
[requestHeaders, requestBody] = [
50+
{ "Content-Type": `${contentType}` },
51+
reqBody,
52+
];
53+
break;
54+
55+
default:
56+
requestBody = reqBody;
57+
const requestBodyType: string = typeof requestBody;
58+
if (
59+
requestBodyType === "string" ||
60+
requestBody instanceof String ||
61+
requestBody instanceof Uint8Array
62+
)
63+
requestHeaders = { "Content-Type": `${contentType}` };
64+
else
65+
throw new Error(
66+
`invalid request body type ${requestBodyType} for mediaType ${contentType}`
67+
);
68+
}
7869
return [requestHeaders, requestBody];
7970
}
8071

0 commit comments

Comments
 (0)