|
8 | 8 | import io.swagger.v3.oas.models.info.Info; |
9 | 9 | import io.swagger.v3.oas.models.media.ArraySchema; |
10 | 10 | import io.swagger.v3.oas.models.media.ComposedSchema; |
| 11 | +import io.swagger.v3.oas.models.media.IntegerSchema; |
11 | 12 | import io.swagger.v3.oas.models.media.Schema; |
12 | 13 | import io.swagger.v3.oas.models.parameters.Parameter; |
13 | 14 | import io.swagger.v3.oas.models.parameters.RequestBody; |
@@ -88,6 +89,7 @@ public class V2ConverterTest { |
88 | 89 | private static final String ISSUE_765_YAML = "issue-765.yaml"; |
89 | 90 | private static final String ISSUE_768_JSON = "issue-786.json"; |
90 | 91 | private static final String ISSUE_820_YAML = "issue-820.yaml"; |
| 92 | + private static final String ISSUE_1032_YAML = "issue-1032.yaml"; |
91 | 93 |
|
92 | 94 | private static final String API_BATCH_PATH = "/api/batch/"; |
93 | 95 | private static final String PETS_PATH = "/pets"; |
@@ -153,6 +155,9 @@ public class V2ConverterTest { |
153 | 155 | private static final String ARRAY_VALUES = "[{\"id\":-1,\"name\":\"Marvin the Paranoid Android\"}," + |
154 | 156 | "{\"id\":1000000,\"name\":\"Zaphod Beeblebrox\",\"friends\":[15]}]"; |
155 | 157 | private static final String SCHEMAS_A_REF = "#/components/schemas/A"; |
| 158 | + private static final String DATA_PATH = "/data"; |
| 159 | + private static final String INTEGER_TYPE = "integer"; |
| 160 | + private static final String INT64_FORMAT = "int64"; |
156 | 161 |
|
157 | 162 | private static final int MAX_LENGTH = 60; |
158 | 163 | private static final int REQUIRED_SIZE = 2; |
@@ -762,6 +767,18 @@ public void testIssue820() throws Exception { |
762 | 767 | assertEquals(baz.getNullable(), Boolean.FALSE); |
763 | 768 | } |
764 | 769 |
|
| 770 | + @Test(description = "OpenAPI v2 converter - proper IntegerSchema parsing") |
| 771 | + public void testTopLevelExtensions() throws Exception { |
| 772 | + final OpenAPI oas = getConvertedOpenAPIFromJsonFile(ISSUE_1032_YAML); |
| 773 | + assertNotNull(oas); |
| 774 | + Parameter unixTimestampQueryParameter = oas.getPaths().get(DATA_PATH).getGet().getParameters().get(0); |
| 775 | + assertNotNull(unixTimestampQueryParameter); |
| 776 | + assertTrue(unixTimestampQueryParameter.getSchema() instanceof IntegerSchema); |
| 777 | + IntegerSchema integerSchema = (IntegerSchema) unixTimestampQueryParameter.getSchema(); |
| 778 | + assertEquals(INTEGER_TYPE, integerSchema.getType()); |
| 779 | + assertEquals(INT64_FORMAT, integerSchema.getFormat()); |
| 780 | + } |
| 781 | + |
765 | 782 | private OpenAPI getConvertedOpenAPIFromJsonFile(String file) throws IOException, URISyntaxException { |
766 | 783 | SwaggerConverter converter = new SwaggerConverter(); |
767 | 784 | String swaggerAsString = new String(Files.readAllBytes(Paths.get(getClass().getClassLoader().getResource(file).toURI()))); |
|
0 commit comments