-
Notifications
You must be signed in to change notification settings - Fork 536
[1369] Unit test for AdditionalProperties keyword when converting from v2 to v3 #1370
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
base: master
Are you sure you want to change the base?
Changes from all commits
79daf87
ae09e90
6a108c5
8d2e659
39a10ef
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,6 +96,7 @@ public class V2ConverterTest { | |
private static final String ISSUE_1113_YAML = "issue-1113.yaml"; | ||
private static final String ISSUE_1164_YAML = "issue-1164.yaml"; | ||
private static final String ISSUE_1261_YAML = "issue-1261.yaml"; | ||
private static final String ISSUE_1369_YAML = "issue-1369.yaml"; | ||
|
||
private static final String API_BATCH_PATH = "/api/batch/"; | ||
private static final String PETS_PATH = "/pets"; | ||
|
@@ -852,6 +853,29 @@ public void testissue1261() throws Exception { | |
|
||
} | ||
|
||
@Test(description = "OpenAPI v2 converter - verifies the additionalProperties") | ||
public void testissue1369() throws Exception { | ||
OpenAPI oas = getConvertedOpenAPIFromJsonFile(ISSUE_1369_YAML); | ||
assertNotNull(oas); | ||
Schema schema = (Schema) oas.getComponents().getSchemas().get("Foo1"); | ||
assertNotNull(schema); | ||
assertNull(schema.getAdditionalProperties()); | ||
|
||
schema = (Schema) oas.getComponents().getSchemas().get("Foo2"); | ||
assertNotNull(schema); | ||
assertNotNull(schema.getAdditionalProperties()); | ||
assertEquals(schema.getAdditionalProperties(), Boolean.TRUE); | ||
|
||
schema = (Schema) oas.getComponents().getSchemas().get("Foo3"); | ||
assertNotNull(schema); | ||
assertNotNull(schema.getAdditionalProperties()); | ||
assertEquals(schema.getAdditionalProperties(), Boolean.FALSE); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getAdditionalProperties() value should be null at this step in processing for a false spec input There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My mistake, this should be Boolean.FALSE per checking results when parsing a v3 spec. |
||
|
||
schema = (Schema) oas.getComponents().getSchemas().get("Foo4"); | ||
assertNotNull(schema); | ||
assertNotNull(schema.getAdditionalProperties()); | ||
} | ||
|
||
@Test() | ||
public void testInlineDefinitionProperty() throws Exception { | ||
SwaggerConverter converter = new SwaggerConverter(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
swagger: '2.0' | ||
info: | ||
title: additionalProperties test | ||
version: '1.0.0' | ||
paths: {} | ||
|
||
definitions: | ||
Foo1: | ||
type: object | ||
properties: | ||
bar: | ||
type: string | ||
Foo2: | ||
type: object | ||
properties: | ||
foo: | ||
type: string | ||
additionalProperties: false | ||
Foo3: | ||
type: object | ||
properties: | ||
foo: | ||
type: string | ||
additionalProperties: true | ||
Foo4: | ||
type: object | ||
properties: | ||
bar: | ||
type: string | ||
additionalProperties: | ||
type: string |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getAdditionalProperties() value should be a schema at this step in processing for a true spec input
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My mistake, this should be Boolean.TRUE per checking results when parsing a v3 spec.
This is good