Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,12 @@ public Model definition(ObjectNode node, String location, ParseResult result) {
am.items(items);
}

Integer maxItems = getInteger("maxItems", node, false, location, result);
am.setMaxItems(maxItems);

Integer minItems = getInteger("minItems", node, false, location, result);
am.setMinItems(minItems);

// extra keys
Set<String> keys = getKeys(node);
for(String key : keys) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,35 @@ public void testIssue243() {
assertNotNull(result.getSwagger());
}

@Test
public void testIssue594() {
String yaml =
"swagger: '2.0'\n" +
"paths:\n" +
" /test:\n" +
" post:\n" +
" parameters:\n" +
" - name: body\n" +
" in: body\n" +
" description: Hello world\n" +
" schema:\n" +
" type: array\n" +
" minItems: 1\n" +
" maxItems: 1\n" +
" items: \n" +
" $ref: \"#/definitions/Pet\"\n" +
" responses:\n" +
" 200:\n" +
" description: 'OK'\n";
SwaggerDeserializationResult result = new SwaggerParser().readWithInfo(yaml);
assertNotNull(result.getSwagger());
ArrayModel schema = (ArrayModel)((BodyParameter)result.getSwagger().getPaths().get("/test").getPost().getParameters().get(0)).getSchema();
assertEquals(((RefProperty)schema.getItems()).get$ref(),"#/definitions/Pet");
assertNotNull(schema.getMaxItems());
assertNotNull(schema.getMinItems());

}

@Test
public void testIssue450() {
String desc = "An array of Pets";
Expand Down