-
Notifications
You must be signed in to change notification settings - Fork 523
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
[1369] Unit test for AdditionalProperties keyword when converting from v2 to v3 #1370
base: master
Are you sure you want to change the base?
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.
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
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 comment
The 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 comment
The 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.
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:
additionalProperties
field 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