File tree Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Expand file tree Collapse file tree 1 file changed +18
-6
lines changed Original file line number Diff line number Diff line change @@ -2,16 +2,28 @@ import { IRequestMethod } from '../swaggerInterfaces'
22
33export function getContentType ( reqProps : IRequestMethod , isV3 : boolean ) {
44 if ( isV3 ) {
5+ // Prefer Json over other content types
6+ if ( reqProps ?. requestBody ?. content [ 'application/json' ] ) {
7+ return 'application/json'
8+ }
59 if ( reqProps ?. requestBody ?. content [ 'multipart/form-data' ] ) {
610 return 'multipart/form-data'
7- } else if ( reqProps ?. requestBody ?. content [ 'application/x-www-form-urlencoded' ] ) {
11+ }
12+ if ( reqProps ?. requestBody ?. content [ 'application/x-www-form-urlencoded' ] ) {
813 return 'application/x-www-form-urlencoded'
9- } else {
14+ }
15+ return 'application/json'
16+ } else {
17+ // Prefer Json over other content types
18+ if ( reqProps ?. consumes ?. includes ( 'application/json' ) ) {
1019 return 'application/json'
1120 }
21+ if ( reqProps ?. consumes ?. includes ( 'multipart/form-data' ) ) {
22+ return 'multipart/form-data'
23+ }
24+ if ( reqProps ?. consumes ?. includes ( 'application/x-www-form-urlencoded' ) ) {
25+ return 'application/x-www-form-urlencoded'
26+ }
27+ return 'application/json'
1228 }
13-
14- return reqProps . consumes && reqProps . consumes . includes ( 'multipart/form-data' )
15- ? 'multipart/form-data'
16- : 'application/json'
1729}
You can’t perform that action at this time.
0 commit comments