[1369] Unit test for AdditionalProperties keyword when converting from v2 to v3#1370
[1369] Unit test for AdditionalProperties keyword when converting from v2 to v3#1370sebastien-rosset wants to merge 5 commits intoswagger-api:masterfrom
Conversation
|
please build |
I have now pulled the latest from master. As it stands, this PR has a unit test to show the problem. It does not have the actual fix. I initially spent some time looking at how to fix the problem, but in doing so it occurred to me the v2 code seems to have been the basis for v3 code, with some code being copied from v2 into a v3 folder, then modified to handle additional properties (but not retrofitted back to the v2 code). Code maintainers probably have opinions on how this problem should be fixed. |
|
Heads up, I just submitted this PR: #1414 |
| schema = (Schema) oas.getComponents().getSchemas().get("Foo2"); | ||
| assertNotNull(schema); | ||
| assertNotNull(schema.getAdditionalProperties()); | ||
| assertEquals(schema.getAdditionalProperties(), Boolean.TRUE); |
There was a problem hiding this comment.
getAdditionalProperties() value should be a schema at this step in processing for a true spec input
There was a problem hiding this comment.
My mistake, this should be Boolean.TRUE per checking results when parsing a v3 spec.
This is good
| schema = (Schema) oas.getComponents().getSchemas().get("Foo3"); | ||
| assertNotNull(schema); | ||
| assertNotNull(schema.getAdditionalProperties()); | ||
| assertEquals(schema.getAdditionalProperties(), Boolean.FALSE); |
There was a problem hiding this comment.
getAdditionalProperties() value should be null at this step in processing for a false spec input
There was a problem hiding this comment.
My mistake, this should be Boolean.FALSE per checking results when parsing a v3 spec.
This is good
This is a PR to add a unit test for #1369.
When the 'additionalProperties' keyword is specified in a '2.0' document as a boolean value, the value is not converted to the 3.0 document. In the converted 3.0 schema, the additionalProperties() function returns null instead of the boolean value.
I'm not sure if this should be targeted for the master branch or the 2.0-before-branch-switch branch.
At this point this PR is only the unit test that shows the conversion issue.
Code that needs to change:
additionalPropertiesfield to Object. Should allow both Boolean value and Property: https://github.com/swagger-api/swagger-core/blob/1.5/modules/swagger-models/src/main/java/io/swagger/models/ModelImpl.java#L25