Skip to content

Commit

Permalink
Merge pull request #262 from joeljons/resolve-without-definitions
Browse files Browse the repository at this point in the history
Handle resolving specs without any definitions
  • Loading branch information
gracekarina authored Jun 21, 2018
2 parents 5a86d5e + a7a3e27 commit 0b6ea8d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/main/java/io/swagger/inflector/utils/ResolverUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public Map<String, Model> getResolvedModels() {
public void resolveFully(Swagger swagger) {
if (swagger.getDefinitions() != null) {
schemas = swagger.getDefinitions();
if (schemas == null) {
schemas = new HashMap<>();
}
}
if (schemas == null) {
schemas = new HashMap<>();
}

for (String name : schemas.keySet()) {
Expand Down
22 changes: 22 additions & 0 deletions src/test/java/io/swagger/test/utils/ResolverUtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,26 @@ public void testSelfReferenceResolution() {
fail("Recursive loop found");
}
}


@Test
public void testResolvingWithoutDefinitions() {
String yaml =
"swagger: '2.0'\n" +
"info:\n" +
" version: '1.0'\n" +
" title: No definition example\n" +
"\n" +
"paths:\n" +
" /:\n" +
" get:\n" +
" produces:\n" +
" - application/json\n" +
" responses:\n" +
" 200:\n" +
" description: completed successfully\n";

Swagger swagger = new SwaggerParser().parse(yaml);
new ResolverUtil().resolveFully(swagger);
}
}

0 comments on commit 0b6ea8d

Please sign in to comment.