-
-
Notifications
You must be signed in to change notification settings - Fork 570
Description
Description
It seems that if an operation has 2 content type headers, the generated code is ignoring the content type header
for example,
/v2/profile:
patch:
operationId: ABCD
parameters: []
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/User'
requestBody:
required: true
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/A'
application/json:
schema:
$ref: '#/components/schemas/B'
the generated code are the following:
export const apiPatchV2Profile = (
apiPatchV2ProfileBodies:
| ASchema
| BSchema,
options?: SecondParameter<typeof customInstance>,
) => {
return customInstance<UserSchema>(
{ url: `/v2/profile`, method: 'PATCH', data: apiPatchV2ProfileBodies },
options,
);
};
as you can see, the content-type: multipart/form-data is not accounted for.
Configuration (orval.config)
output: {
mode: 'split',
prettier: true,
client: 'react-query',
target: outputTarget,
override: {
mutator: {
path: './src/shared/api/customInstance.ts',
name: 'customInstance',
},
formData: {
path: './src/shared/api/customFormDataFn.ts',
name: 'customFormDataFn',
},
useTypeOverInterfaces: true,
},
},Environment
Run the command above and paste the output here.
System:
OS: macOS 15.4.1
CPU: (8) arm64 Apple M2
Memory: 151.75 MB / 24.00 GB
Shell: 5.9 - /bin/zsh
npmPackages:
@tanstack/react-query: ^5.90.17 => 5.90.17
axios: ^1.13.2 => 1.13.2
orval: 7.5.0 => 7.5.0
react: 18.3.1 => 18.3.1
zod: ^3.25.76 => 3.25.76
Expected behavior
Maybe there should be 2 functions for this?
apiPatchV2ProfileWithApplicationJson and apiPatchV2ProfileWithMultipartFormData
Actual behavior
only apiPatchV2Profile is generated while the one that is multipart form data is missing
OpenAPI document (minimal, if applicable)
paths: {
/v2/profile:
patch:
operationId: ABCD
parameters: []
responses:
'200':
description: The request has succeeded.
content:
application/json:
schema:
$ref: '#/components/schemas/User'
requestBody:
required: true
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/A'
application/json:
schema:
$ref: '#/components/schemas/B'
}Additional context
No response