88import io .swagger .v3 .oas .models .info .Info ;
99import io .swagger .v3 .oas .models .media .ArraySchema ;
1010import io .swagger .v3 .oas .models .media .ComposedSchema ;
11+ import io .swagger .v3 .oas .models .media .IntegerSchema ;
1112import io .swagger .v3 .oas .models .media .Schema ;
1213import io .swagger .v3 .oas .models .parameters .Parameter ;
1314import io .swagger .v3 .oas .models .parameters .RequestBody ;
@@ -88,6 +89,7 @@ public class V2ConverterTest {
8889 private static final String ISSUE_765_YAML = "issue-765.yaml" ;
8990 private static final String ISSUE_768_JSON = "issue-786.json" ;
9091 private static final String ISSUE_820_YAML = "issue-820.yaml" ;
92+ private static final String ISSUE_1032_YAML = "issue-1032.yaml" ;
9193
9294 private static final String API_BATCH_PATH = "/api/batch/" ;
9395 private static final String PETS_PATH = "/pets" ;
@@ -153,6 +155,9 @@ public class V2ConverterTest {
153155 private static final String ARRAY_VALUES = "[{\" id\" :-1,\" name\" :\" Marvin the Paranoid Android\" }," +
154156 "{\" id\" :1000000,\" name\" :\" Zaphod Beeblebrox\" ,\" friends\" :[15]}]" ;
155157 private static final String SCHEMAS_A_REF = "#/components/schemas/A" ;
158+ private static final String UNIX_TIMESTAMP_QUERY_PARAM = "unixTimestampQuery" ;
159+ private static final String INTEGER_TYPE = "integer" ;
160+ private static final String INT64_FORMAT = "int64" ;
156161
157162 private static final int MAX_LENGTH = 60 ;
158163 private static final int REQUIRED_SIZE = 2 ;
@@ -164,7 +169,7 @@ public class V2ConverterTest {
164169 private static final int MIN_LENGTH = 3 ;
165170 private static final int NUMBER_VALUE_TWENTY = 20 ;
166171 private static final double MULTIPLE_OF_VALUE = 0.01D ;
167- private static final long DEFAULT_VALUE = 11L ;
172+ private static final int DEFAULT_VALUE = 11 ;
168173 private static final int EXAMPLE_8_NUMBER = 8 ;
169174 private static final int EXAMPLE_42_NUMBER = 42 ;
170175
@@ -762,6 +767,19 @@ public void testIssue820() throws Exception {
762767 assertEquals (baz .getNullable (), Boolean .FALSE );
763768 }
764769
770+ @ Test (description = "OpenAPI v2 converter - proper IntegerSchema parsing" )
771+ public void testIssue1032 () throws Exception {
772+ final OpenAPI oas = getConvertedOpenAPIFromJsonFile (ISSUE_1032_YAML );
773+ assertNotNull (oas );
774+ Parameter unixTimestampQueryParameter = oas .getComponents ().getParameters ().get (UNIX_TIMESTAMP_QUERY_PARAM );
775+ assertNotNull (unixTimestampQueryParameter );
776+ Schema s = unixTimestampQueryParameter .getSchema ();
777+ assertTrue ((s instanceof IntegerSchema ), "actual type: " + s );
778+ IntegerSchema integerSchema = (IntegerSchema ) s ;
779+ assertEquals (INTEGER_TYPE , integerSchema .getType ());
780+ assertEquals (INT64_FORMAT , integerSchema .getFormat ());
781+ }
782+
765783 private OpenAPI getConvertedOpenAPIFromJsonFile (String file ) throws IOException , URISyntaxException {
766784 SwaggerConverter converter = new SwaggerConverter ();
767785 String swaggerAsString = new String (Files .readAllBytes (Paths .get (getClass ().getClassLoader ().getResource (file ).toURI ())));
@@ -771,4 +789,4 @@ private OpenAPI getConvertedOpenAPIFromJsonFile(String file) throws IOException,
771789 assertNotNull (result );
772790 return result .getOpenAPI ();
773791 }
774- }
792+ }
0 commit comments