Skip to content

Commit e7647ec

Browse files
committed
0.3.0 mixed form data - files and fields with objects
1 parent a33a59d commit e7647ec

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@essquare/typescript-openapi-codegen",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"description": "Library that generates Typescript clients based on the OpenAPI specification.",
55
"author": "Ferdi Koomen",
66
"homepage": "https://github.com/essquare/typescript-openapi-codegen",

src/templates/core/functions/getFormData.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const getFormData = (options: ApiRequestOptions) => {
1717
} else if (isBlob(value)) {
1818
formData.append(key, value, value.type);
1919
} else {
20-
formData.append(key, JSON.stringify(value));
20+
formData.append(key, new Blob([JSON.stringify(value)], {"type":"application/json"}));
2121
}
2222
};
2323

src/templates/core/functions/prepareFormData.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const prepareFormData = (formData: any) => {
1919
const prefix = `--${boundary}\r\nContent-Disposition: form-data; name="`;
2020

2121
for (let [name, value] of formData) {
22-
if (typeof value === 'string') {
22+
if (isStringWithValue(value)) {
2323
chunks.push(prefix + escape(name) + `"\r\n\r\n${value.replace(/\r\n?/g, '\n').replace(/\n/g,'\r\n')}\r\n`);
2424
} else {
2525
chunks.push(prefix + escape(name) + `"; filename="${escape(value.name, true)}"\r\n` + `Content-Type: ${value.type || 'application/octet-stream'}\r\n\r\n`, value, '\r\n');

test/__snapshots__/index.spec.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ const getFormData = (options: ApiRequestOptions) => {
374374
} else if (isBlob(value)) {
375375
formData.append(key, value, value.type);
376376
} else {
377-
formData.append(key, JSON.stringify(value));
377+
formData.append(key, new Blob([JSON.stringify(value)], {\\"type\\":\\"application/json\\"}));
378378
}
379379
};
380380

@@ -3468,7 +3468,7 @@ const getFormData = (options: ApiRequestOptions) => {
34683468
} else if (isBlob(value)) {
34693469
formData.append(key, value, value.type);
34703470
} else {
3471-
formData.append(key, JSON.stringify(value));
3471+
formData.append(key, new Blob([JSON.stringify(value)], {\\"type\\":\\"application/json\\"}));
34723472
}
34733473
};
34743474

test/e2e/client.axios.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('client.axios', () => {
1313

1414
afterAll(async () => {
1515
await server.stop();
16-
});
16+
}, 30000);
1717

1818
it('requests token', async () => {
1919
const { ApiClient } = require('./generated/client/axios/index.js');

0 commit comments

Comments
 (0)