@@ -522,7 +522,7 @@ export function getRequestBodyObject(
522
522
oas
523
523
) as RequestBodyObject
524
524
} else {
525
- requestBodyObject = ( requestBodyObject as any ) as RequestBodyObject
525
+ requestBodyObject = requestBodyObject as RequestBodyObject
526
526
}
527
527
528
528
if ( typeof requestBodyObject . content === 'object' ) {
@@ -534,6 +534,13 @@ export function getRequestBodyObject(
534
534
payloadContentType : 'application/json' ,
535
535
requestBodyObject
536
536
}
537
+ } else if (
538
+ Object . keys ( content ) . includes ( 'application/x-www-form-urlencoded' )
539
+ ) {
540
+ return {
541
+ payloadContentType : 'application/x-www-form-urlencoded' ,
542
+ requestBodyObject
543
+ }
537
544
} else {
538
545
// Pick first (random) content type
539
546
const randomContentType = Object . keys ( content ) [ 0 ]
@@ -587,11 +594,16 @@ export function getRequestSchemaAndNames(
587
594
: false
588
595
589
596
/**
590
- * Edge case: if request body content-type is not application/json, do not
591
- * parse. Instead, treat the request body as a black box (allowing it to be
592
- * defined as a string) and sending it with the appropriate content-type
597
+ * Edge case: if request body content-type is not application/json or
598
+ * application/x-www-form-urlencoded, do not parse it.
599
+ *
600
+ * Instead, treat the request body as a black box and send it as a string
601
+ * with the proper content-type header
593
602
*/
594
- if ( payloadContentType !== 'application/json' ) {
603
+ if (
604
+ payloadContentType !== 'application/json' &&
605
+ payloadContentType !== 'application/x-www-form-urlencoded'
606
+ ) {
595
607
const saneContentTypeName = uncapitalize (
596
608
payloadContentType . split ( '/' ) . reduce ( ( name , term ) => {
597
609
return name + capitalize ( term )
@@ -602,7 +614,7 @@ export function getRequestSchemaAndNames(
602
614
fromPath : saneContentTypeName
603
615
}
604
616
605
- let description = payloadContentType + ' request placeholder object'
617
+ let description = `String represents payload of content type ' ${ payloadContentType } '`
606
618
607
619
if (
608
620
'description' in payloadSchema &&
@@ -651,7 +663,7 @@ export function getResponseObject(
651
663
oas
652
664
) as ResponseObject
653
665
} else {
654
- responseObject = ( responseObject as any ) as ResponseObject
666
+ responseObject = responseObject as ResponseObject
655
667
}
656
668
657
669
if (
@@ -719,13 +731,12 @@ export function getResponseSchemaAndNames(
719
731
}
720
732
721
733
/**
722
- * Edge case: if request body content-type is not application/json, do not
723
- * parse. Instead, treat the request body as a black box (allowing it to be
724
- * defined as a string) and sending it with the appropriate content-type
734
+ * Edge case: if response body content-type is not application/json, do not
735
+ * parse.
725
736
*/
726
737
if ( responseContentType !== 'application/json' ) {
727
738
let description =
728
- 'Placeholder object to access non-application/json ' + ' response bodies'
739
+ 'Placeholder to access non-application/json response bodies'
729
740
730
741
if (
731
742
'description' in responseSchema &&
@@ -748,10 +759,11 @@ export function getResponseSchemaAndNames(
748
759
}
749
760
} else {
750
761
/**
751
- * GraphQL requires that objects must have some properties. To allow some
752
- * operations (such as those with a 204 HTTP code) to be included in the
753
- * GraphQL interface, we added the fillEmptyResponses option, which will
754
- * simply create a placeholder object with a placeholder property.
762
+ * GraphQL requires that objects must have some properties.
763
+ *
764
+ * To allow some operations (such as those with a 204 HTTP code) to be
765
+ * included in the GraphQL interface, we added the fillEmptyResponses
766
+ * option, which will simply create a placeholder to allow access.
755
767
*/
756
768
if ( options . fillEmptyResponses ) {
757
769
return {
@@ -761,7 +773,7 @@ export function getResponseSchemaAndNames(
761
773
responseContentType : 'application/json' ,
762
774
responseSchema : {
763
775
description :
764
- 'Placeholder object to support operations with no response schema' ,
776
+ 'Placeholder to support operations with no response schema' ,
765
777
type : 'string'
766
778
}
767
779
}
@@ -841,7 +853,7 @@ export function getEndpointLinks(
841
853
}
842
854
843
855
// Here, we can be certain we have a ResponseObject:
844
- response = ( response as any ) as ResponseObject
856
+ response = response as ResponseObject
845
857
846
858
if ( typeof response . links === 'object' ) {
847
859
const epLinks : LinksObject = response . links
@@ -852,7 +864,7 @@ export function getEndpointLinks(
852
864
if ( typeof ( link as ReferenceObject ) . $ref === 'string' ) {
853
865
link = resolveRef ( link [ '$ref' ] , oas )
854
866
} else {
855
- link = ( link as any ) as LinkObject
867
+ link = link as LinkObject
856
868
}
857
869
links [ linkKey ] = link
858
870
}
@@ -892,7 +904,7 @@ export function getParameters(
892
904
return resolveRef ( p [ '$ref' ] , oas ) as ParameterObject
893
905
} else {
894
906
// Here we know we have a parameter object:
895
- return ( p as any ) as ParameterObject
907
+ return p as ParameterObject
896
908
}
897
909
} )
898
910
parameters = parameters . concat ( pathItemParameters )
@@ -909,7 +921,7 @@ export function getParameters(
909
921
return resolveRef ( p [ '$ref' ] , oas ) as ParameterObject
910
922
} else {
911
923
// Here we know we have a parameter object:
912
- return ( p as any ) as ParameterObject
924
+ return p as ParameterObject
913
925
}
914
926
} )
915
927
parameters = parameters . concat ( opParameters )
@@ -983,7 +995,7 @@ export function getSecuritySchemes(
983
995
) as SecuritySchemeObject
984
996
} else {
985
997
// We already have a SecuritySchemeObject:
986
- securitySchemes [ schemeKey ] = ( obj as any ) as SecuritySchemeObject
998
+ securitySchemes [ schemeKey ] = obj as SecuritySchemeObject
987
999
}
988
1000
}
989
1001
}
0 commit comments