Skip to content

Commit 0efc754

Browse files
js2meStynStijnLammens
authored
Release 5.1.6 (Bugfix) (#178)
* also json stringify string input (#177) Co-authored-by: stijn.lammens <[email protected]> * bump: up version to 5.1.6 * chore: refresh generated apis Co-authored-by: Stijn Lammens <[email protected]> Co-authored-by: stijn.lammens <[email protected]>
1 parent 683311a commit 0efc754

Some content is hidden

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

58 files changed

+115
-57
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# next release
22

3+
# 5.1.6
4+
5+
Fixes:
6+
- The contentFormatter for ContentType:Json does not correctly format strings (issue #176, thanks @Styn)
7+
38
# 5.1.5
49

510
Fixes:

package-lock.json

Lines changed: 1 addition & 1 deletion
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": "swagger-typescript-api",
3-
"version": "5.1.5",
3+
"version": "5.1.6",
44
"description": "Create typescript api module from swagger schema",
55
"scripts": {
66
"cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts --extract-request-params --enum-names-as-values",

templates/default/http-client.eta

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class HttpClient<SecurityDataType = unknown> {
105105
}
106106

107107
private contentFormatters: Record<ContentType, (input: any) => any> = {
108-
[ContentType.Json]: (input:any) => input !== null && typeof input === "object" ? JSON.stringify(input) : input,
108+
[ContentType.Json]: (input:any) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
109109
[ContentType.FormData]: (input: any) =>
110110
Object.keys(input || {}).reduce((data, key) => {
111111
data.append(key, input[key]);

templates/modular/http-client.eta

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export class HttpClient<SecurityDataType = unknown> {
105105
}
106106

107107
private contentFormatters: Record<ContentType, (input: any) => any> = {
108-
[ContentType.Json]: (input:any) => input !== null && typeof input === "object" ? JSON.stringify(input) : input,
108+
[ContentType.Json]: (input:any) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
109109
[ContentType.FormData]: (input: any) =>
110110
Object.keys(input || {}).reduce((data, key) => {
111111
data.append(key, input[key]);

tests/generated/v2.0/adafruit.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ export class HttpClient<SecurityDataType = unknown> {
256256
}
257257

258258
private contentFormatters: Record<ContentType, (input: any) => any> = {
259-
[ContentType.Json]: (input: any) => (input !== null && typeof input === "object" ? JSON.stringify(input) : input),
259+
[ContentType.Json]: (input: any) =>
260+
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
260261
[ContentType.FormData]: (input: any) =>
261262
Object.keys(input || {}).reduce((data, key) => {
262263
data.append(key, input[key]);

tests/generated/v2.0/another-example.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ export class HttpClient<SecurityDataType = unknown> {
232232
}
233233

234234
private contentFormatters: Record<ContentType, (input: any) => any> = {
235-
[ContentType.Json]: (input: any) => (input !== null && typeof input === "object" ? JSON.stringify(input) : input),
235+
[ContentType.Json]: (input: any) =>
236+
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
236237
[ContentType.FormData]: (input: any) =>
237238
Object.keys(input || {}).reduce((data, key) => {
238239
data.append(key, input[key]);

tests/generated/v2.0/another-schema.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,8 @@ export class HttpClient<SecurityDataType = unknown> {
124124
}
125125

126126
private contentFormatters: Record<ContentType, (input: any) => any> = {
127-
[ContentType.Json]: (input: any) => (input !== null && typeof input === "object" ? JSON.stringify(input) : input),
127+
[ContentType.Json]: (input: any) =>
128+
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
128129
[ContentType.FormData]: (input: any) =>
129130
Object.keys(input || {}).reduce((data, key) => {
130131
data.append(key, input[key]);

tests/generated/v2.0/api-with-examples.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ export class HttpClient<SecurityDataType = unknown> {
101101
}
102102

103103
private contentFormatters: Record<ContentType, (input: any) => any> = {
104-
[ContentType.Json]: (input: any) => (input !== null && typeof input === "object" ? JSON.stringify(input) : input),
104+
[ContentType.Json]: (input: any) =>
105+
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
105106
[ContentType.FormData]: (input: any) =>
106107
Object.keys(input || {}).reduce((data, key) => {
107108
data.append(key, input[key]);

tests/generated/v2.0/authentiq.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ export class HttpClient<SecurityDataType = unknown> {
153153
}
154154

155155
private contentFormatters: Record<ContentType, (input: any) => any> = {
156-
[ContentType.Json]: (input: any) => (input !== null && typeof input === "object" ? JSON.stringify(input) : input),
156+
[ContentType.Json]: (input: any) =>
157+
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
157158
[ContentType.FormData]: (input: any) =>
158159
Object.keys(input || {}).reduce((data, key) => {
159160
data.append(key, input[key]);

0 commit comments

Comments
 (0)