Skip to content

Commit 6f70fa8

Browse files
committed
added fix, test for #339
1 parent 6425d97 commit 6f70fa8

File tree

3 files changed

+1285
-9
lines changed

3 files changed

+1285
-9
lines changed

modules/swagger-parser/src/main/java/io/swagger/parser/util/SwaggerDeserializer.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -480,10 +480,10 @@ else if ("formData".equals(value)) {
480480
map.put(DEFAULT, defaultValue);
481481
sp.setDefault(defaultValue);
482482

483-
Double dbl = getDouble("maximum", obj, false, location, result);
484-
if(dbl != null) {
485-
map.put(MAXIMUM, new BigDecimal(dbl.toString()));
486-
sp.setMaximum(new BigDecimal(dbl.toString()));
483+
String numberAsString = getString("maximum", obj, false, location, result);
484+
if(numberAsString != null) {
485+
map.put(MAXIMUM, new BigDecimal(numberAsString));
486+
sp.setMaximum(new BigDecimal(numberAsString));
487487
}
488488

489489
Boolean bl = getBoolean("exclusiveMaximum", obj, false, location, result);
@@ -492,10 +492,10 @@ else if ("formData".equals(value)) {
492492
sp.setExclusiveMaximum(bl);
493493
}
494494

495-
dbl = getDouble("minimum", obj, false, location, result);
496-
if(dbl != null) {
497-
map.put(MINIMUM, new BigDecimal(dbl.toString()));
498-
sp.setMinimum(new BigDecimal(dbl.toString()));
495+
numberAsString = getString("minimum", obj, false, location, result);
496+
if(numberAsString != null) {
497+
map.put(MINIMUM, new BigDecimal(numberAsString.toString()));
498+
sp.setMinimum(new BigDecimal(numberAsString.toString()));
499499
}
500500

501501
bl = getBoolean("exclusiveMinimum", obj, false, location, result);
@@ -527,7 +527,7 @@ else if ("formData".equals(value)) {
527527
map.put(MAX_LENGTH, iv);
528528
sp.setMaxLength(iv);
529529

530-
dbl = getDouble("multipleOf", obj, false, location, result);
530+
Double dbl = getDouble("multipleOf", obj, false, location, result);
531531
if(dbl != null) {
532532
map.put(MULTIPLE_OF, new BigDecimal(dbl.toString()));
533533
sp.setMultipleOf(dbl);

modules/swagger-parser/src/test/java/io/swagger/parser/SwaggerParserTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,4 +676,17 @@ public void testCodegenPetstore() {
676676

677677
assertEquals(formParam.getMinimum().toString(), "32.1");
678678
}
679+
680+
@Test
681+
public void testIssue339() throws Exception {
682+
SwaggerParser parser = new SwaggerParser();
683+
final Swagger swagger = parser.read("src/test/resources/issue-339.json");
684+
685+
Parameter param = swagger.getPath("/store/order/{orderId}").getGet().getParameters().get(0);
686+
assertTrue(param instanceof PathParameter);
687+
PathParameter pp = (PathParameter) param;
688+
689+
assertTrue(pp.getMinimum().toString().equals("1"));
690+
assertTrue(pp.getMaximum().toString().equals("5"));
691+
}
679692
}

0 commit comments

Comments
 (0)