Skip to content

Commit

Permalink
Merge pull request #1716 from wsalembi/issue-1715
Browse files Browse the repository at this point in the history
[swagger-parser-v2-converter] vendor extensions from body params not copied to RequestBody
  • Loading branch information
gracekarina authored May 4, 2022
2 parents e31007f + 081aca1 commit 50d8cfb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,7 @@ private RequestBody convertParameterToRequestBody(io.swagger.models.parameters.P
}
}
convertExamples(((BodyParameter) param).getExamples(), content);
body.setExtensions(convert(param.getVendorExtensions()));
body.content(content);
return body;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ public class V2ConverterTest {
private static final String ISSUE_1164_YAML = "issue-1164.yaml";
private static final String ISSUE_1261_YAML = "issue-1261.yaml";

private static final String ISSUE_1715_YAML = "issue-1715.yaml";

private static final String API_BATCH_PATH = "/api/batch/";
private static final String PETS_PATH = "/pets";
private static final String PET_FIND_BY_STATUS_PATH = "/pet/findByStatus";
Expand Down Expand Up @@ -852,6 +854,16 @@ public void testissue1261() throws Exception {

}

@Test(description = "OpenAPI v2 converter - vendor extensions on body parameters copied to output RequestBody")
public void testissue1715() throws Exception {
OpenAPI oas = getConvertedOpenAPIFromJsonFile(ISSUE_1715_YAML);
assertNotNull(oas);
RequestBody requestBody = oas.getPaths().get("/foo").getPost().getRequestBody();
assertNotNull(requestBody.getExtensions());
assertEquals(1, requestBody.getExtensions().size());
assertEquals("bar", requestBody.getExtensions().get("x-foo"));
}

@Test()
public void testInlineDefinitionProperty() throws Exception {
SwaggerConverter converter = new SwaggerConverter();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
swagger: '2.0'
info:
title: Test for Issue 1715
version: 1.0.0
paths:
/foo:
post:
operationId: doFoo
parameters:
- in: body
name: body
schema:
$ref: '#/definitions/SomeObj'
required: true
x-foo: bar
responses:
'200':
description: OK
definitions:
SomeObj:
type: string
minLength: 1
maxLength: 3
pattern: ^[0-9]+$

0 comments on commit 50d8cfb

Please sign in to comment.