From d934d41ec05abf260f748d453ac94ce7e135e167 Mon Sep 17 00:00:00 2001 From: ralphdoe Date: Thu, 12 Apr 2018 22:25:03 -0500 Subject: [PATCH 1/4] refs #673 - Properties Missing in Parser - adding tests in Converter --- .../swagger/parser/test/V2ConverterTest.java | 14 +++++ .../src/test/resources/issue-673.yaml | 53 +++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 modules/swagger-parser-v2-converter/src/test/resources/issue-673.yaml diff --git a/modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java b/modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java index eb8ed27942..c44a183086 100644 --- a/modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java +++ b/modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java @@ -71,7 +71,11 @@ public class V2ConverterTest { private static final String ISSUE_540_JSON = "issue-540.json"; private static final String ISSUE_647_JSON = "issue-647.yaml"; private static final String ISSUE_662_JSON = "issue-662.yaml"; +<<<<<<< Updated upstream private static final String ISSUE_676_JSON = "issue-676.json"; +======= + private static final String ISSUE_673_YAML = "issue-673.yaml"; +>>>>>>> Stashed changes private static final String API_BATCH_PATH = "/api/batch/"; private static final String PETS_PATH = "/pets"; @@ -553,6 +557,7 @@ public void testIssue662() throws Exception { assertTrue(oas.getPaths().isEmpty()); } +<<<<<<< Updated upstream @Test(description = "OpenAPI v2 converter - integer elements of enum are converted to String") public void testIssue676() throws Exception { OpenAPI oas = getConvertedOpenAPIFromJsonFile(ISSUE_676_JSON); @@ -575,6 +580,15 @@ public void testIssue676() throws Exception { assertEquals(anEnum.get(1), false); } +======= + @Test(description = "OpenAPI v2 converter - Error in BodyParameter convertion") + public void testIssue673() throws Exception { + OpenAPI oas = getConvertedOpenAPIFromJsonFile(ISSUE_673_YAML); + assertNotNull(oas); + } + + +>>>>>>> Stashed changes private OpenAPI getConvertedOpenAPIFromJsonFile(String file) throws IOException, URISyntaxException { SwaggerConverter converter = new SwaggerConverter(); String swaggerAsString = new String(Files.readAllBytes(Paths.get(getClass().getClassLoader().getResource(file).toURI()))); diff --git a/modules/swagger-parser-v2-converter/src/test/resources/issue-673.yaml b/modules/swagger-parser-v2-converter/src/test/resources/issue-673.yaml new file mode 100644 index 0000000000..5e7ad67547 --- /dev/null +++ b/modules/swagger-parser-v2-converter/src/test/resources/issue-673.yaml @@ -0,0 +1,53 @@ +swagger: '2.0' +info: + version: 1.0.0 + title: Test +paths: + "/integer": + post: + consumes: + - application/json + produces: + - application/json + parameters: + - in: body + name: body + required: true + schema: + type: integer + format: int32 + multipleOf: 3 + minimum: 5 + maximum: 7 + exclusiveMinimum: true + exclusiveMaximum: true + "/array": + post: + consumes: + - application/json + produces: + - application/json + parameters: + - in: body + name: body + required: true + schema: + type: array + items: + type: string + uniqueItems: true + "/string": + post: + consumes: + - application/json + produces: + - application/json + parameters: + - in: body + name: body + required: true + schema: + type: string + minLength: 2 + maxLength: 7 + pattern: aaa \ No newline at end of file From 03e1ee85ceadec927f9f83f7394363cbb9374125 Mon Sep 17 00:00:00 2001 From: ralphdoe Date: Thu, 12 Apr 2018 23:13:41 -0500 Subject: [PATCH 2/4] refs #673 - Properties Missing in Parser - adding tests in Converter --- .../java/io/swagger/parser/test/V2ConverterTest.java | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java b/modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java index c44a183086..6e904a03fc 100644 --- a/modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java +++ b/modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java @@ -71,11 +71,8 @@ public class V2ConverterTest { private static final String ISSUE_540_JSON = "issue-540.json"; private static final String ISSUE_647_JSON = "issue-647.yaml"; private static final String ISSUE_662_JSON = "issue-662.yaml"; -<<<<<<< Updated upstream - private static final String ISSUE_676_JSON = "issue-676.json"; -======= private static final String ISSUE_673_YAML = "issue-673.yaml"; ->>>>>>> Stashed changes + private static final String ISSUE_676_JSON = "issue-676.json"; private static final String API_BATCH_PATH = "/api/batch/"; private static final String PETS_PATH = "/pets"; @@ -557,7 +554,6 @@ public void testIssue662() throws Exception { assertTrue(oas.getPaths().isEmpty()); } -<<<<<<< Updated upstream @Test(description = "OpenAPI v2 converter - integer elements of enum are converted to String") public void testIssue676() throws Exception { OpenAPI oas = getConvertedOpenAPIFromJsonFile(ISSUE_676_JSON); @@ -580,15 +576,12 @@ public void testIssue676() throws Exception { assertEquals(anEnum.get(1), false); } -======= @Test(description = "OpenAPI v2 converter - Error in BodyParameter convertion") public void testIssue673() throws Exception { OpenAPI oas = getConvertedOpenAPIFromJsonFile(ISSUE_673_YAML); assertNotNull(oas); } - ->>>>>>> Stashed changes private OpenAPI getConvertedOpenAPIFromJsonFile(String file) throws IOException, URISyntaxException { SwaggerConverter converter = new SwaggerConverter(); String swaggerAsString = new String(Files.readAllBytes(Paths.get(getClass().getClassLoader().getResource(file).toURI()))); From 14093e74b945c457a24c98d9105ce0b9c8c00912 Mon Sep 17 00:00:00 2001 From: ralphdoe Date: Fri, 13 Apr 2018 01:05:38 -0500 Subject: [PATCH 3/4] refs #673 - Properties Missing in Parser - adding tests in Converter --- .../swagger/parser/test/V2ConverterTest.java | 18 ++++++++++++++++-- .../src/test/resources/issue-673.yaml | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java b/modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java index 6e904a03fc..219c47b516 100644 --- a/modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java +++ b/modules/swagger-parser-v2-converter/src/test/java/io/swagger/parser/test/V2ConverterTest.java @@ -383,7 +383,7 @@ public void testIssue23() throws Exception { OpenAPI oas = getConvertedOpenAPIFromJsonFile(ISSUE_23_JSON); assertTrue(oas.getComponents().getSchemas().get(MAP_OBJECTS_MODEL).getAdditionalProperties() instanceof Schema); Schema additionalProperties = (Schema) oas.getComponents().getSchemas().get(MAP_OBJECTS_MODEL).getAdditionalProperties(); - assertEquals(OBJECT_REF,additionalProperties.get$ref()); + assertEquals(OBJECT_REF, additionalProperties.get$ref()); } @Test(description = "Covert path item $refs") @@ -578,8 +578,22 @@ public void testIssue676() throws Exception { @Test(description = "OpenAPI v2 converter - Error in BodyParameter convertion") public void testIssue673() throws Exception { - OpenAPI oas = getConvertedOpenAPIFromJsonFile(ISSUE_673_YAML); + final OpenAPI oas = getConvertedOpenAPIFromJsonFile(ISSUE_673_YAML); assertNotNull(oas); + Schema schema = oas.getPaths().get("/integer").getPost().getRequestBody().getContent().get("application/json").getSchema(); + assertNotNull(schema); + assertTrue(schema.getUniqueItems()); + assertTrue(schema.getExclusiveMaximum()); + assertTrue(schema.getExclusiveMinimum()); + assertEquals(3, schema.getMultipleOf().toBigInteger().intValue()); + assertEquals(new BigDecimal(5), schema.getMinimum()); + assertEquals(new BigDecimal(7), schema.getMaximum()); + + schema = oas.getPaths().get("/string").getPost().getRequestBody().getContent().get("application/json").getSchema(); + assertEquals(2, schema.getMinLength().intValue()); + assertEquals(7, schema.getMaxLength().intValue()); + assertEquals("aaa", schema.getPattern()); + } private OpenAPI getConvertedOpenAPIFromJsonFile(String file) throws IOException, URISyntaxException { diff --git a/modules/swagger-parser-v2-converter/src/test/resources/issue-673.yaml b/modules/swagger-parser-v2-converter/src/test/resources/issue-673.yaml index 5e7ad67547..6111e85552 100644 --- a/modules/swagger-parser-v2-converter/src/test/resources/issue-673.yaml +++ b/modules/swagger-parser-v2-converter/src/test/resources/issue-673.yaml @@ -21,6 +21,7 @@ paths: maximum: 7 exclusiveMinimum: true exclusiveMaximum: true + uniqueItems: true "/array": post: consumes: From 02c094024ce5a81fd8f526759c3f16ce2efcedfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20L=C3=B3pez?= Date: Tue, 8 May 2018 14:24:33 -0500 Subject: [PATCH 4/4] ref #673 POM Updated --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3a9c7be2d6..f92bf616a4 100644 --- a/pom.xml +++ b/pom.xml @@ -250,7 +250,7 @@ - 1.0.35 + 1.0.36-SNAPSHOT 2.4 1.6.3 2.0.1