Skip to content

Commit

Permalink
fix for issue #1398
Browse files Browse the repository at this point in the history
  • Loading branch information
gracekarina committed Aug 5, 2020
1 parent 4cf798f commit 61a8e36
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2189,7 +2189,11 @@ public Schema getSchema(ObjectNode node, String location, ParseResult result){

BigDecimal bigDecimal = getBigDecimal("multipleOf",node,false,location,result);
if(bigDecimal != null) {
schema.setMultipleOf(bigDecimal);
if(bigDecimal.intValue() > 0) {
schema.setMultipleOf(bigDecimal);
}else{
result.warning(location,"multipleOf value must be > 0");
}
}

bigDecimal = getBigDecimal("maximum", node, false, location, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,12 @@ public class OpenAPIV3ParserTest {
protected int serverPort = getDynamicPort();
protected WireMockServer wireMockServer;

@Test
public void testIssue1398() {
ParseOptions options = new ParseOptions();
SwaggerParseResult result = new OpenAPIV3Parser().readLocation("issue1398.yaml", null, options);
assertEquals(result.getMessages().get(0), "attribute paths.'/pet/{petId}'(get).parameters.[petId].schemas.multipleOf value must be > 0");
}

@Test
public void testIssue1367() {
Expand Down
26 changes: 26 additions & 0 deletions modules/swagger-parser-v3/src/test/resources/issue1398.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
openapi: 3.0.1
info:
title: Swagger Petstore
description: 'This is a sample server Petstore server'
version: 1.0.0
servers:
- url: http://mytestServer/{v1}
variables:
v2:
default: 'd'
paths:
'/pet/{petId}':
get:
summary: Find pet by ID
description: Returns a single pet
parameters:
- name: petId
in: path
description: ID of pet to return
required: true
schema:
type : integer
multipleOf: -10
responses:
'200':
description: successful operation

0 comments on commit 61a8e36

Please sign in to comment.