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 @@ -574,6 +574,7 @@ public Operation convert(io.swagger.models.Operation v2Operation) {
574
574
}
575
575
operation .setDeprecated (v2Operation .isDeprecated ());
576
576
operation .setOperationId (v2Operation .getOperationId ());
577
+ operation .setExtensions (convert (v2Operation .getVendorExtensions ()));
577
578
578
579
operation .setTags (v2Operation .getTags ());
579
580
@@ -585,6 +586,7 @@ public Operation convert(io.swagger.models.Operation v2Operation) {
585
586
formParams .add (param );
586
587
} else if ("body" .equals (param .getIn ())) {
587
588
operation .setRequestBody (convertParameterToRequestBody (param , v2Operation .getConsumes ()));
589
+ operation .addExtension ("x-codegen-request-body-name" , param .getName ());
588
590
} else {
589
591
Parameter convert = convert (param );
590
592
String $ref = convert .get$ref ();
@@ -631,8 +633,6 @@ public Operation convert(io.swagger.models.Operation v2Operation) {
631
633
operation .setSecurity (convertSecurityRequirementsMap (v2Operation .getSecurity ()));
632
634
}
633
635
634
- operation .setExtensions (convert (v2Operation .getVendorExtensions ()));
635
-
636
636
return operation ;
637
637
}
638
638
Original file line number Diff line number Diff line change @@ -678,8 +678,15 @@ public void testIssue758() throws Exception {
678
678
public void testIssue762 () throws Exception {
679
679
final OpenAPI oas = getConvertedOpenAPIFromJsonFile (ISSUE_762_JSON );
680
680
assertNotNull (oas );
681
- }
682
-
681
+ }
682
+
683
+ @ Test (description = "OpenAPI v2 Converter: Ensure body name is preserved in x-codegen-request-body-name extension" )
684
+ public void testPreserveBodyParameterName () throws Exception {
685
+ final OpenAPI oas = getConvertedOpenAPIFromJsonFile (ISSUE_762_JSON );
686
+ assertNotNull (oas );
687
+ assertEquals (oas .getPaths ().get ("/" ).getPut ().getExtensions ().get ("x-codegen-request-body-name" ), "pet" );
688
+ }
689
+
683
690
@ Test (description = "requestBody not correctly populated when Parameters is a list of $refs (OAS 2 to 3 conversion)" )
684
691
public void testIssue765 () throws Exception {
685
692
final OpenAPI oas = getConvertedOpenAPIFromJsonFile (ISSUE_765_YAML );
You can’t perform that action at this time.
0 commit comments