Skip to content

[java][jersey2] Fix processing of additional, undeclared properties#6647

Merged
wing328 merged 4 commits intoOpenAPITools:masterfrom
CiscoM31:jersey2-additional-properties
Jun 18, 2020
Merged

[java][jersey2] Fix processing of additional, undeclared properties#6647
wing328 merged 4 commits intoOpenAPITools:masterfrom
CiscoM31:jersey2-additional-properties

Conversation

@sebastien-rosset
Copy link
Contributor

@sebastien-rosset sebastien-rosset commented Jun 12, 2020

This is a fix for #6646.

  1. Add more unit tests (in JSONComposedSchemaTest.java) to exercise various use cases for additionalProperties, such as:
    1. within composed schema
    2. non composed schemas
    3. additionalProperties with boolean value
    4. additionalProperties with schema
  2. Fix processing of additionalProperties

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project beforehand.
  • Run the shell script ./bin/generate-samples.shto update all Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/config/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@sebastien-rosset
Copy link
Contributor Author

@bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @bkabrda (2020/01)

serverPort: "8082"
dateLibrary: java8
useOneOfDiscriminatorLookup: true
disallowAdditionalPropertiesIfNotPresent: false
Copy link
Contributor Author

@sebastien-rosset sebastien-rosset Jun 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Historically, the behavior has been to disallow additional properties by default, but that's not compliant with the OAS spec. By default, when additionalProperties is not present, additionalProperties MUST be allowed.

@wing328 , I think at some point we should set disallowAdditionalPropertiesIfNotPresent to false by default, maybe starting with jersey2?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should let the user choose at this point instead of forcing the behavior per generator/library.

We'll introduce this option to the community as part of the v5.0.0 official release and consider changing the default value later if more users are familiar with the change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, sure. This is how it is currently implemented (i.e. non-compliant). I have set disallowAdditionalPropertiesIfNotPresent to false for the example only.

@sebastien-rosset sebastien-rosset changed the title [java][jersey2] Add unit tests for additional properties [java][jersey2] Fix processing of additional, undeclared properties Jun 12, 2020
@sebastien-rosset sebastien-rosset marked this pull request as ready for review June 12, 2020 23:12
@wing328 wing328 merged commit 5811b05 into OpenAPITools:master Jun 18, 2020
@wing328 wing328 added this to the 5.0.0 milestone Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants