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

Fixing empty Definitions #552

Merged
merged 4 commits into from
Oct 17, 2017
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 @@ -831,8 +831,6 @@ else if(!SCHEMA_KEYS.contains(key)) {
result.extra(location, key, node.get(key));
}
}
if("{ }".equals(Json.pretty(impl)))
return null;
model = impl;
}
JsonNode exampleNode = node.get("example");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,55 @@
import static org.junit.Assert.*;

public class SwaggerDeserializerTest {


@Test
public void testEmptyDefinitions() throws Exception {
String yaml = "swagger: \"2.0\"\n" +
"info:\n" +
" version: \"1.0\"\n" +
" title: \"dd\"\n" +
"host: \"abc:5555\"\n" +
"basePath: \"/mypath\"\n" +
"schemes:\n" +
"- \"http\"\n" +
"consumes:\n" +
"- \"application/json\"\n" +
"produces:\n" +
"- \"application/json\"\n" +
"paths:\n" +
" /resource1/Id:\n" +
" post:\n" +
" description: \"\"\n" +
" operationId: \"postOp\"\n" +
" parameters:\n" +
" - in: \"body\"\n" +
" name: \"input3\"\n" +
" description: \"\"\n" +
" required: true\n" +
" schema:\n" +
" $ref: \"#/definitions/mydefinition\"\n" +
" responses:\n" +
" 200:\n" +
" description: \"Successful\"\n" +
" 401:\n" +
" description: \"Access Denied\"\n" +
"definitions:\n" +
" mydefinition: {}";

SwaggerParser parser = new SwaggerParser();

SwaggerDeserializationResult result = parser.readWithInfo(yaml);
List<String> messageList = result.getMessages();
Set<String> messages = new HashSet<String>(messageList);
Swagger swagger = result.getSwagger();
assertNotNull(swagger);
assertNotNull(swagger.getDefinitions().get("mydefinition"));


}


@Test
public void testSecurityDeserialization() throws Exception {
String json = "{\n" +
Expand Down