Skip to content

Commit

Permalink
Fixes issue swagger-api#1129
Browse files Browse the repository at this point in the history
  • Loading branch information
kerrykimbrough committed Jun 18, 2019
1 parent 0b2a65e commit 413b10c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2242,6 +2242,8 @@ public Schema getSchema(ObjectNode node, String location, ParseResult result){
for (JsonNode n : enumArray) {
if (n.isNumber()) {
schema.addEnumItemObject(n.numberValue());
} else if (n.isBoolean()) {
schema.addEnumItemObject(n.booleanValue());
} else if (n.isValueNode()) {
try {
schema.addEnumItemObject( getDecodedObject( schema, n.asText(null)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,8 @@ public void testDeserializeEnum() {
" $ref: '#/components/schemas/IntegerEnum'\n" +
" ne:\n" +
" $ref: '#/components/schemas/NumberEnum'\n" +
" be:\n" +
" $ref: '#/components/schemas/BooleanEnum'\n" +
"components:\n" +
" schemas:\n" +
" StringEnum:\n" +
Expand All @@ -886,6 +888,10 @@ public void testDeserializeEnum() {
" enum:\n" +
" - First\n" +
" - Second\n" +
" BooleanEnum:\n" +
" enum:\n" +
" - true \n" +
" - false \n" +
" IntegerEnum:\n" +
" type: integer\n" +
" default: 1\n" +
Expand Down Expand Up @@ -934,6 +940,13 @@ public void testDeserializeEnum() {
assertEquals(new BigDecimal("1.6161"), numberValues.get(2));
assertEquals(new BigDecimal("3.14"), numberValues.get(3));
assertEquals(numberImpl.getDefault(), new BigDecimal("3.14"));

Schema booleanModel = resolved.getComponents().getSchemas().get("BooleanEnum");
assertEquals("boolean", booleanModel.getType());
List<Object> booleanValues = booleanModel.getEnum();
assertEquals(2, booleanValues.size());
assertEquals(Boolean.TRUE, booleanValues.get(0));
assertEquals(Boolean.FALSE, booleanValues.get(1));
}

@Test
Expand Down

0 comments on commit 413b10c

Please sign in to comment.