mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
- Added missing form data header
This commit is contained in:
parent
1e6068fd27
commit
2070f9599f
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openapi-typescript-codegen",
|
||||
"version": "0.11.3",
|
||||
"version": "0.11.4",
|
||||
"description": "Library that generates Typescript clients based on the OpenAPI specification.",
|
||||
"author": "Ferdi Koomen",
|
||||
"homepage": "https://github.com/ferdikoomen/openapi-typescript-codegen",
|
||||
|
||||
@ -12,6 +12,7 @@ export interface Content {
|
||||
const BASIC_MEDIA_TYPES = [
|
||||
'application/json-patch+json',
|
||||
'application/json',
|
||||
'application/x-www-form-urlencoded',
|
||||
'text/json',
|
||||
'text/plain',
|
||||
'multipart/form-data',
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
import type { Dictionary } from '../../../utils/types';
|
||||
import type { OpenApi } from '../interfaces/OpenApi';
|
||||
import type { OpenApiMediaType } from '../interfaces/OpenApiMediaType';
|
||||
|
||||
const supportedMediaTypes = [
|
||||
'application/json-patch+json',
|
||||
'application/json',
|
||||
'text/json',
|
||||
'text/plain',
|
||||
'multipart/form-data',
|
||||
'multipart/mixed',
|
||||
'multipart/related',
|
||||
'multipart/batch',
|
||||
];
|
||||
|
||||
export function getMediaType(openApi: OpenApi, content: Dictionary<OpenApiMediaType>): string | null {
|
||||
return Object.keys(content).find(key => supportedMediaTypes.includes(key)) || null;
|
||||
}
|
||||
@ -34,10 +34,13 @@ export function getOperationRequestBody(openApi: OpenApi, parameter: OpenApiRequ
|
||||
const content = getContent(openApi, parameter.content);
|
||||
if (content) {
|
||||
requestBody.mediaType = content.mediaType;
|
||||
if (requestBody.mediaType === 'multipart/form-data') {
|
||||
requestBody.in = 'formData';
|
||||
requestBody.name = 'formData';
|
||||
requestBody.prop = 'formData';
|
||||
switch (requestBody.mediaType) {
|
||||
case 'application/x-www-form-urlencoded':
|
||||
case 'multipart/form-data':
|
||||
requestBody.in = 'formData';
|
||||
requestBody.name = 'formData';
|
||||
requestBody.prop = 'formData';
|
||||
break;
|
||||
}
|
||||
if (content.schema.$ref) {
|
||||
const model = getType(content.schema.$ref);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user