fork of hey-api/openapi-ts because I need some additional things

Update OpenAPI 2.0 specs and snapshots per feedback

- Removed body parameter from CallWithParameters operation (keeping only formData)
- Removed formData parameter from CallWithWeirdParameterNames (keeping only body)
- Fixed body parameter schema structure in CallWithWeirdParameterNames
- Updated fix to only default to application/json for true body parameters, not formData
- Updated all test snapshots to match new behavior

Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>

Changed files
+187 -82
packages
openapi-ts
src
openApi
2.0.x
parser
openapi-ts-tests
main
test
__snapshots__
2.0.x
external
plugins
@angular
common
@hey-api
sdk
@pinia
colada
@tanstack
angular-query-experimental
react-query
solid-query
svelte-query
vue-query
fastify
valibot
default
test
specs
+23 -6
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/external/types.gen.ts
··· 176 176 export type GetExternalModelResponse = GetExternalModelResponses[keyof GetExternalModelResponses]; 177 177 178 178 export type PostExternalModelData = { 179 - body?: never; 179 + /** 180 + * Request body using external model 181 + */ 182 + body: ExternalSharedExternalSharedModel; 180 183 path?: never; 181 184 query?: never; 182 185 url: '/external-model'; ··· 217 220 export type GetExternalUuidResponse = GetExternalUuidResponses[keyof GetExternalUuidResponses]; 218 221 219 222 export type PutExternalUuidData = { 220 - body?: never; 223 + /** 224 + * Request body using external UUID 225 + */ 226 + body?: ExternalSharedExternalSharedModelWithUuid; 221 227 path?: never; 222 228 query?: never; 223 229 url: '/external-uuid'; ··· 252 258 export type GetExternalNestedResponse = GetExternalNestedResponses[keyof GetExternalNestedResponses]; 253 259 254 260 export type PostExternalNestedData = { 255 - body?: never; 261 + /** 262 + * Request body using external nested object 263 + */ 264 + body?: ExternalSharedExternalNested; 256 265 path?: never; 257 266 query?: never; 258 267 url: '/external-nested'; ··· 292 301 export type GetExternalMixedResponse = GetExternalMixedResponses[keyof GetExternalMixedResponses]; 293 302 294 303 export type PostExternalMixedData = { 295 - body?: never; 304 + /** 305 + * Request body with mixed external properties 306 + */ 307 + body?: { 308 + id?: ExternalSharedId; 309 + name?: ExternalSharedName; 310 + uuid?: ExternalSharedExternalSharedModelWithUuid; 311 + deep?: ExternalSharedDeep; 312 + }; 296 313 path?: never; 297 314 query?: never; 298 315 url: '/external-mixed'; ··· 324 341 export type GetExternalArrayResponse = GetExternalArrayResponses[keyof GetExternalArrayResponses]; 325 342 326 343 export type PostExternalArrayData = { 327 - body?: never; 344 + body: Array<ExternalSharedExternalSharedModel>; 328 345 path?: never; 329 346 query?: never; 330 347 url: '/external-array'; ··· 354 371 }; 355 372 356 373 export type PostExternalUnionData = { 357 - body?: never; 374 + body: unknown; 358 375 path?: never; 359 376 query?: never; 360 377 url: '/external-union';
+5 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/sdk.gen.ts
··· 105 105 export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 106 106 return (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 107 107 url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 108 - ...options 108 + ...options, 109 + headers: { 110 + 'Content-Type': 'application/json', 111 + ...options.headers 112 + } 109 113 }); 110 114 }; 111 115
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default-class/types.gen.ts
··· 600 600 }; 601 601 602 602 export type CallWithWeirdParameterNamesData = { 603 - body?: never; 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 604 607 headers: { 605 608 /** 606 609 * This is the parameter that goes into the request header
+5 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/sdk.gen.ts
··· 105 105 export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 106 106 return (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 107 107 url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 108 - ...options 108 + ...options, 109 + headers: { 110 + 'Content-Type': 'application/json', 111 + ...options.headers 112 + } 109 113 }); 110 114 }; 111 115
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@angular/common/default/types.gen.ts
··· 600 600 }; 601 601 602 602 export type CallWithWeirdParameterNamesData = { 603 - body?: never; 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 604 607 headers: { 605 608 /** 606 609 * This is the parameter that goes into the request header
+5 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/sdk.gen.ts
··· 105 105 export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 106 106 return (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 107 107 url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 108 - ...options 108 + ...options, 109 + headers: { 110 + 'Content-Type': 'application/json', 111 + ...options.headers 112 + } 109 113 }); 110 114 }; 111 115
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/default/types.gen.ts
··· 600 600 }; 601 601 602 602 export type CallWithWeirdParameterNamesData = { 603 - body?: never; 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 604 607 headers: { 605 608 /** 606 609 * This is the parameter that goes into the request header
+5 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/sdk.gen.ts
··· 105 105 export const callWithWeirdParameterNames = <ThrowOnError extends boolean = true>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 106 106 return (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 107 107 url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 108 - ...options 108 + ...options, 109 + headers: { 110 + 'Content-Type': 'application/json', 111 + ...options.headers 112 + } 109 113 }); 110 114 }; 111 115
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@hey-api/sdk/throwOnError/types.gen.ts
··· 600 600 }; 601 601 602 602 export type CallWithWeirdParameterNamesData = { 603 - body?: never; 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 604 607 headers: { 605 608 /** 606 609 * This is the parameter that goes into the request header
+5 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/sdk.gen.ts
··· 105 105 export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 106 106 return (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 107 107 url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 108 - ...options 108 + ...options, 109 + headers: { 110 + 'Content-Type': 'application/json', 111 + ...options.headers 112 + } 109 113 }); 110 114 }; 111 115
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@pinia/colada/fetch/types.gen.ts
··· 600 600 }; 601 601 602 602 export type CallWithWeirdParameterNamesData = { 603 - body?: never; 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 604 607 headers: { 605 608 /** 606 609 * This is the parameter that goes into the request header
+5 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/sdk.gen.ts
··· 105 105 export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 106 106 return (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 107 107 url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 108 - ...options 108 + ...options, 109 + headers: { 110 + 'Content-Type': 'application/json', 111 + ...options.headers 112 + } 109 113 }); 110 114 }; 111 115
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/axios/types.gen.ts
··· 600 600 }; 601 601 602 602 export type CallWithWeirdParameterNamesData = { 603 - body?: never; 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 604 607 headers: { 605 608 /** 606 609 * This is the parameter that goes into the request header
+5 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/sdk.gen.ts
··· 105 105 export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 106 106 return (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 107 107 url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 108 - ...options 108 + ...options, 109 + headers: { 110 + 'Content-Type': 'application/json', 111 + ...options.headers 112 + } 109 113 }); 110 114 }; 111 115
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/angular-query-experimental/fetch/types.gen.ts
··· 600 600 }; 601 601 602 602 export type CallWithWeirdParameterNamesData = { 603 - body?: never; 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 604 607 headers: { 605 608 /** 606 609 * This is the parameter that goes into the request header
+5 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/sdk.gen.ts
··· 105 105 export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 106 106 return (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 107 107 url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 108 - ...options 108 + ...options, 109 + headers: { 110 + 'Content-Type': 'application/json', 111 + ...options.headers 112 + } 109 113 }); 110 114 }; 111 115
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/axios/types.gen.ts
··· 600 600 }; 601 601 602 602 export type CallWithWeirdParameterNamesData = { 603 - body?: never; 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 604 607 headers: { 605 608 /** 606 609 * This is the parameter that goes into the request header
+5 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/sdk.gen.ts
··· 105 105 export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 106 106 return (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 107 107 url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 108 - ...options 108 + ...options, 109 + headers: { 110 + 'Content-Type': 'application/json', 111 + ...options.headers 112 + } 109 113 }); 110 114 }; 111 115
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/react-query/fetch/types.gen.ts
··· 600 600 }; 601 601 602 602 export type CallWithWeirdParameterNamesData = { 603 - body?: never; 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 604 607 headers: { 605 608 /** 606 609 * This is the parameter that goes into the request header
+5 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/sdk.gen.ts
··· 105 105 export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 106 106 return (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 107 107 url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 108 - ...options 108 + ...options, 109 + headers: { 110 + 'Content-Type': 'application/json', 111 + ...options.headers 112 + } 109 113 }); 110 114 }; 111 115
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/axios/types.gen.ts
··· 600 600 }; 601 601 602 602 export type CallWithWeirdParameterNamesData = { 603 - body?: never; 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 604 607 headers: { 605 608 /** 606 609 * This is the parameter that goes into the request header
+5 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/sdk.gen.ts
··· 105 105 export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 106 106 return (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 107 107 url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 108 - ...options 108 + ...options, 109 + headers: { 110 + 'Content-Type': 'application/json', 111 + ...options.headers 112 + } 109 113 }); 110 114 }; 111 115
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/solid-query/fetch/types.gen.ts
··· 600 600 }; 601 601 602 602 export type CallWithWeirdParameterNamesData = { 603 - body?: never; 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 604 607 headers: { 605 608 /** 606 609 * This is the parameter that goes into the request header
+5 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/sdk.gen.ts
··· 105 105 export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 106 106 return (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 107 107 url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 108 - ...options 108 + ...options, 109 + headers: { 110 + 'Content-Type': 'application/json', 111 + ...options.headers 112 + } 109 113 }); 110 114 }; 111 115
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/axios/types.gen.ts
··· 600 600 }; 601 601 602 602 export type CallWithWeirdParameterNamesData = { 603 - body?: never; 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 604 607 headers: { 605 608 /** 606 609 * This is the parameter that goes into the request header
+5 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/sdk.gen.ts
··· 105 105 export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 106 106 return (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 107 107 url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 108 - ...options 108 + ...options, 109 + headers: { 110 + 'Content-Type': 'application/json', 111 + ...options.headers 112 + } 109 113 }); 110 114 }; 111 115
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/svelte-query/fetch/types.gen.ts
··· 600 600 }; 601 601 602 602 export type CallWithWeirdParameterNamesData = { 603 - body?: never; 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 604 607 headers: { 605 608 /** 606 609 * This is the parameter that goes into the request header
+5 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/sdk.gen.ts
··· 105 105 export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 106 106 return (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 107 107 url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 108 - ...options 108 + ...options, 109 + headers: { 110 + 'Content-Type': 'application/json', 111 + ...options.headers 112 + } 109 113 }); 110 114 }; 111 115
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/axios/types.gen.ts
··· 600 600 }; 601 601 602 602 export type CallWithWeirdParameterNamesData = { 603 - body?: never; 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 604 607 headers: { 605 608 /** 606 609 * This is the parameter that goes into the request header
+5 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/sdk.gen.ts
··· 105 105 export const callWithWeirdParameterNames = <ThrowOnError extends boolean = false>(options: Options<CallWithWeirdParameterNamesData, ThrowOnError>) => { 106 106 return (options.client ?? client).post<unknown, unknown, ThrowOnError>({ 107 107 url: '/api/v{api-version}/parameters/{parameter.path.1}/{parameter-path-2}/{PARAMETER-PATH-3}', 108 - ...options 108 + ...options, 109 + headers: { 110 + 'Content-Type': 'application/json', 111 + ...options.headers 112 + } 109 113 }); 110 114 }; 111 115
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/@tanstack/vue-query/fetch/types.gen.ts
··· 600 600 }; 601 601 602 602 export type CallWithWeirdParameterNamesData = { 603 - body?: never; 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 604 607 headers: { 605 608 /** 606 609 * This is the parameter that goes into the request header
+1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/fastify.gen.ts
··· 14 14 Querystring: CallWithParametersData['query']; 15 15 }>; 16 16 callWithWeirdParameterNames: RouteHandler<{ 17 + Body: CallWithWeirdParameterNamesData['body']; 17 18 Headers: CallWithWeirdParameterNamesData['headers']; 18 19 Params: CallWithWeirdParameterNamesData['path']; 19 20 Querystring: CallWithWeirdParameterNamesData['query'];
+4 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/fastify/default/types.gen.ts
··· 600 600 }; 601 601 602 602 export type CallWithWeirdParameterNamesData = { 603 - body?: never; 603 + /** 604 + * This is the parameter that is sent as request body 605 + */ 606 + body: string; 604 607 headers: { 605 608 /** 606 609 * This is the parameter that goes into the request header
+1 -1
packages/openapi-ts-tests/main/test/__snapshots__/2.0.x/plugins/valibot/default/valibot.gen.ts
··· 533 533 }); 534 534 535 535 export const vCallWithWeirdParameterNamesData = v.object({ 536 - body: v.optional(v.never()), 536 + body: v.string(), 537 537 path: v.object({ 538 538 'parameter.path.1': v.optional(v.string()), 539 539 'parameter-path-2': v.optional(v.string()),
+1 -7
packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v2/sdk.gen.ts.snap
··· 409 409 * @param data.parameterHeader This is the parameter that goes into the header 410 410 * @param data.parameterQuery This is the parameter that goes into the query params 411 411 * @param data.parameterForm This is the parameter that goes into the form data 412 - * @param data.parameterBody This is the parameter that is sent as request body 413 412 * @param data.parameterPath This is the parameter that goes into the path 414 413 * @throws ApiError 415 414 */ ··· 428 427 }, 429 428 formData: { 430 429 parameterForm: data.parameterForm 431 - }, 432 - body: data.parameterBody 430 + } 433 431 }); 434 432 } 435 433 ··· 437 435 * @param data The data for the request. 438 436 * @param data.parameterHeader This is the parameter that goes into the request header 439 437 * @param data.parameterQuery This is the parameter that goes into the request query params 440 - * @param data.parameterForm This is the parameter that goes into the request form data 441 438 * @param data.parameterBody This is the parameter that is sent as request body 442 439 * @param data.parameterPath1 This is the parameter that goes into the path 443 440 * @param data.parameterPath2 This is the parameter that goes into the path ··· 460 457 query: { 461 458 default: data._default, 462 459 'parameter-query': data.parameterQuery 463 - }, 464 - formData: { 465 - parameter_form: data.parameterForm 466 460 }, 467 461 body: data.parameterBody 468 462 });
-8
packages/openapi-ts-tests/main/test/__snapshots__/test/generated/v2/types.gen.ts.snap
··· 679 679 680 680 export type CallWithParametersData = { 681 681 /** 682 - * This is the parameter that is sent as request body 683 - */ 684 - parameterBody: string; 685 - /** 686 682 * This is the parameter that goes into the form data 687 683 */ 688 684 parameterForm: string; ··· 709 705 * This is the parameter that is sent as request body 710 706 */ 711 707 parameterBody: string; 712 - /** 713 - * This is the parameter that goes into the request form data 714 - */ 715 - parameterForm: string; 716 708 /** 717 709 * This is the parameter that goes into the request header 718 710 */
+16 -2
packages/openapi-ts/src/openApi/2.0.x/parser/operation.ts
··· 115 115 }; 116 116 const requestBodyObjectRequired: Array<string> = []; 117 117 118 + // Check if there are any body parameters (not formData) to determine default media type 119 + const hasBodyParameter = operation.requestBody?.some((param) => { 120 + const resolvedParam = 121 + '$ref' in param ? context.resolveRef<ParameterObject>(param.$ref) : param; 122 + return resolvedParam.in === 'body'; 123 + }); 124 + 118 125 for (const requestBodyParameter of operation.requestBody ?? []) { 119 126 const requestBody = 120 127 '$ref' in requestBodyParameter ··· 129 136 required: undefined, 130 137 type: requestBody.type === 'file' ? 'string' : requestBody.type, 131 138 }; 139 + 140 + // Only default to JSON if we have body parameters and no consumes specified 141 + // FormData parameters without consumes should not get a default media type 142 + let mimeTypes = operation.consumes; 143 + if (!mimeTypes && hasBodyParameter && requestBody.in === 'body') { 144 + mimeTypes = ['application/json']; 145 + } 146 + 132 147 const contents = mediaTypeObjects({ 133 - // assume JSON by default 134 - mimeTypes: operation.consumes ? operation.consumes : ['application/json'], 148 + mimeTypes, 135 149 response: { schema }, 136 150 }); 137 151 // TODO: add support for multiple content types, for now prefer JSON
+2 -11
specs/2.0.x/full.yaml
··· 113 113 in: formData 114 114 type: string 115 115 required: true 116 - - description: This is the parameter that is sent as request body 117 - name: parameterBody 118 - in: body 119 - type: string 120 - required: true 121 116 - description: This is the parameter that goes into the path 122 117 name: parameterPath 123 118 in: path ··· 164 159 in: query 165 160 type: string 166 161 required: true 167 - - description: This is the parameter that goes into the request form data 168 - name: parameter_form 169 - in: formData 170 - type: string 171 - required: true 172 162 - description: This is the parameter that is sent as request body 173 163 name: PARAMETER-BODY 174 164 in: body 175 - type: string 176 165 required: true 166 + schema: 167 + type: string 177 168 - description: api-version should be required in standalone clients 178 169 name: api-version 179 170 in: path
+4 -16
specs/v2.json
··· 130 130 "required": true 131 131 }, 132 132 { 133 - "description": "This is the parameter that is sent as request body", 134 - "name": "parameterBody", 135 - "in": "body", 136 - "type": "string", 137 - "required": true 138 - }, 139 - { 140 133 "description": "This is the parameter that goes into the path", 141 134 "name": "parameterPath", 142 135 "in": "path", ··· 201 194 "required": true 202 195 }, 203 196 { 204 - "description": "This is the parameter that goes into the request form data", 205 - "name": "parameter_form", 206 - "in": "formData", 207 - "type": "string", 208 - "required": true 209 - }, 210 - { 211 197 "description": "This is the parameter that is sent as request body", 212 198 "name": "PARAMETER-BODY", 213 199 "in": "body", 214 - "type": "string", 215 - "required": true 200 + "required": true, 201 + "schema": { 202 + "type": "string" 203 + } 216 204 }, 217 205 { 218 206 "description": "api-version should be required in standalone clients",