-
Notifications
You must be signed in to change notification settings - Fork 81
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
Distinguish Schema and Boolean case for AdditionalProperties in Schema #277
Distinguish Schema and Boolean case for AdditionalProperties in Schema #277
Conversation
TCK test added with 0bf0c2d |
0bf0c2d
to
c93cb49
Compare
assertEquals(s.getAdditionalPropertiesBoolean(), null, "AdditionalProperties (Boolean type) is expected to be null"); | ||
checkSameObject(s, s.additionalPropertiesBoolean(Boolean.TRUE)); | ||
assertEquals(s.getAdditionalPropertiesBoolean(), Boolean.TRUE, "AdditionalProperties (Boolean type) is expected to be true"); | ||
assertEquals(s.getAdditionalPropertiesSchema(), null, "AdditionalProperties (Schema type) is expected to be null"); |
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.
I am trying to understand why the schema property would be null
here, and not ap
. Is it because we set the boolean property, and therefore would have automatically set the schema property to null? If so we should change the javadoc of the methods to specify this behaviour, and also change the default interface impl to set the other variant to null.
Signed-off-by: Jeremie Bresson <dev@jmini.fr>
c93cb49
to
7aba41e
Compare
This OpenAPI spec snippet shows the possible values for schemas:
Test1:
additionalProperties: false
Test2:
additionalProperties: true
Test3:
additionalProperties:
type: object
description: a person object
properties:
firstName:
type: string
lastName:
type: string (+ the null case, of course) The Because in Java we do not have union type, we decided to follow KaiZen approach: having getter, setters and builder as if there was 2 members In comparison swagger model just use In my opinion the implementation needs to decide how it wants to handle this case in the setter and getter for 1/ They can decide to store it in an 2/ They can decide to have 2 members, but then they need to 3/ Or they use their own storage layer (I did not verify it, but my understanding is that Kaizen does store everything in the JSON data structure). The default implementation method only does a “delegation to the setter”. Doing anything else in those case might break this rule. The implementation needs to do it right anyway, it is not the responsibility of the builder. Does this make sense? Maybe I need to write the TCK test in an other way. I have tried to update Javadoc:
|
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.
thanks @jmini - with your latest additions to the javadoc I think it's clearer now for users.
Moved some tests to core
See Issue #257.
I think the TCK should test getter/setter/builder for additionalProperties in
ModelConstructionTest.schemaTest()
. I was surprised to see nothing there for the moment.=> I will add a commit to this PR.