Skip to content

Commit 2070f95

Browse files
committed
- Added missing form data header
1 parent 1e6068f commit 2070f95

File tree

4 files changed

+9
-23
lines changed

4 files changed

+9
-23
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": "openapi-typescript-codegen",
3-
"version": "0.11.3",
3+
"version": "0.11.4",
44
"description": "Library that generates Typescript clients based on the OpenAPI specification.",
55
"author": "Ferdi Koomen",
66
"homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen",

src/openApi/v3/parser/getContent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface Content {
1212
const BASIC_MEDIA_TYPES = [
1313
'application/json-patch+json',
1414
'application/json',
15+
'application/x-www-form-urlencoded',
1516
'text/json',
1617
'text/plain',
1718
'multipart/form-data',

src/openApi/v3/parser/getMediaType.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/openApi/v3/parser/getOperationRequestBody.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,13 @@ export function getOperationRequestBody(openApi: OpenApi, parameter: OpenApiRequ
3434
const content = getContent(openApi, parameter.content);
3535
if (content) {
3636
requestBody.mediaType = content.mediaType;
37-
if (requestBody.mediaType === 'multipart/form-data') {
38-
requestBody.in = 'formData';
39-
requestBody.name = 'formData';
40-
requestBody.prop = 'formData';
37+
switch (requestBody.mediaType) {
38+
case 'application/x-www-form-urlencoded':
39+
case 'multipart/form-data':
40+
requestBody.in = 'formData';
41+
requestBody.name = 'formData';
42+
requestBody.prop = 'formData';
43+
break;
4144
}
4245
if (content.schema.$ref) {
4346
const model = getType(content.schema.$ref);

0 commit comments

Comments
 (0)