File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed
modules/swagger-parser-v2-converter/src
main/java/io/swagger/v3/parser/converter
test/java/io/swagger/parser/test Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -550,6 +550,7 @@ public Operation convert(io.swagger.models.Operation v2Operation) {
550
550
}
551
551
operation .setDeprecated (v2Operation .isDeprecated ());
552
552
operation .setOperationId (v2Operation .getOperationId ());
553
+ operation .setExtensions (convert (v2Operation .getVendorExtensions ()));
553
554
554
555
operation .setTags (v2Operation .getTags ());
555
556
@@ -561,6 +562,7 @@ public Operation convert(io.swagger.models.Operation v2Operation) {
561
562
formParams .add (param );
562
563
} else if ("body" .equals (param .getIn ())) {
563
564
operation .setRequestBody (convertParameterToRequestBody (param , v2Operation .getConsumes ()));
565
+ operation .addExtension ("x-codegen-request-body-name" , param .getName ());
564
566
} else {
565
567
Parameter convert = convert (param );
566
568
String $ref = convert .get$ref ();
@@ -607,8 +609,6 @@ public Operation convert(io.swagger.models.Operation v2Operation) {
607
609
operation .setSecurity (convertSecurityRequirementsMap (v2Operation .getSecurity ()));
608
610
}
609
611
610
- operation .setExtensions (convert (v2Operation .getVendorExtensions ()));
611
-
612
612
return operation ;
613
613
}
614
614
Original file line number Diff line number Diff line change @@ -669,8 +669,15 @@ public void testIssue758() throws Exception {
669
669
public void testIssue762 () throws Exception {
670
670
final OpenAPI oas = getConvertedOpenAPIFromJsonFile (ISSUE_762_JSON );
671
671
assertNotNull (oas );
672
- }
673
-
672
+ }
673
+
674
+ @ Test (description = "OpenAPI v2 Converter: Ensure body name is preserved in x-codegen-request-body-name extension" )
675
+ public void testPreserveBodyParameterName () throws Exception {
676
+ final OpenAPI oas = getConvertedOpenAPIFromJsonFile (ISSUE_762_JSON );
677
+ assertNotNull (oas );
678
+ assertEquals (oas .getPaths ().get ("/" ).getPut ().getExtensions ().get ("x-codegen-request-body-name" ), "pet" );
679
+ }
680
+
674
681
@ Test (description = "requestBody not correctly populated when Parameters is a list of $refs (OAS 2 to 3 conversion)" )
675
682
public void testIssue765 () throws Exception {
676
683
final OpenAPI oas = getConvertedOpenAPIFromJsonFile (ISSUE_765_YAML );
You can’t perform that action at this time.
0 commit comments