Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle resolving specs without any definitions #262

Merged
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
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);
}
}