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 @@ -1419,4 +1419,39 @@ public void testIssue360() {
Swagger rebuilt = result.getSwagger();
assertNotNull(rebuilt);
}

@Test(description = "it should deserialize untyped additionalProperties")
public void testUntypedAdditionalProperties() {
String json = "{\n" +
" \"paths\": {\n" +
" \"/store/inventory\": {\n" +
" \"get\": {\n" +
" \"responses\": {\n" +
" \"200\": {\n" +
" \"description\": \"successful operation\",\n" +
" \"schema\": {\n" +
" \"type\": \"object\",\n" +
" \"description\": \"map of anything\",\n" +
" \"additionalProperties\": {}\n" +
" }\n" +
" }\n" +
" }\n" +
" }\n" +
" }\n" +
" }\n" +
"}";

SwaggerParser parser = new SwaggerParser();

SwaggerDeserializationResult result = parser.readWithInfo(json);
List<String> messageList = result.getMessages();
Set<String> messages = new HashSet<String>(messageList);
Swagger swagger = result.getSwagger();

Property response = swagger.getPath("/store/inventory").getGet().getResponses().get("200").getSchema();
assertTrue(response instanceof MapProperty);
Property additionalProperties = ((MapProperty) response).getAdditionalProperties();
assertTrue(additionalProperties instanceof UntypedProperty);
assertEquals(additionalProperties.getType(), null);
}
}
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,11 @@
<artifactId>swagger-core</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>${swagger-core-version}</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
Expand Down