Skip to content

Fix NPE in ModelUtils.isFreeFormObject()#1625

Merged
wing328 merged 1 commit intoOpenAPITools:masterfrom
padamstx:padamstx/issue-1624
Dec 7, 2018
Merged

Fix NPE in ModelUtils.isFreeFormObject()#1625
wing328 merged 1 commit intoOpenAPITools:masterfrom
padamstx:padamstx/issue-1624

Conversation

@padamstx
Copy link
Contributor

@padamstx padamstx commented Dec 6, 2018

Fixes #1624

An object schema containing no properties that also has additionalProperties
set to an object schema with no properties will cause
ModelUtils.isFreeFormObject to throw an NPE.
This PR adds additional checking to avoid the NPE.

PR checklist

  • [X ] Read the contribution guidelines.
  • Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
  • [X ] Filed the PR against the correct branch: master, 3.4.x, 4.0.x. Default: master.
  • Copied the technical committee to review the pull request if your PR is targeting a particular programming language.

Description of the PR

The change essentially just adds an extra check to make sure the "additionalProperties" schema's properties list is not null before calling "isEmpty()" on it.

Fixes #1696

An object schema containing no properties that also has additionalProperties
set to an object schema with no properties will cause
ModelUtils.isFreeFormObject to throw an NPE.
This PR adds additional checking to avoid the NPE.
Copy link
Member

@jmini jmini left a comment

Choose a reason for hiding this comment

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

This looks good to me

@padamstx
Copy link
Contributor Author

padamstx commented Dec 7, 2018

@jmini This is my first PR in this project so not sure what the normal process is for getting it merged.
@wing328 could you please take a look? Thanks

Copy link
Member

@wing328 wing328 left a comment

Choose a reason for hiding this comment

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

LGTM

@wing328 wing328 merged commit 2d39f14 into OpenAPITools:master Dec 7, 2018
@wing328 wing328 added this to the 4.0.0 milestone Dec 7, 2018
@padamstx padamstx deleted the padamstx/issue-1624 branch December 7, 2018 15:51
@wing328
Copy link
Member

wing328 commented Jan 2, 2019

@padamstx thanks for the contribution, which has been included in the 4.0.0-beta release: https://twitter.com/oas_generator/status/1079727020374806529.

Happy New Year and looking forward to more collaboration and contributions in 2019!

A-Joshi pushed a commit to ihsmarkitoss/openapi-generator that referenced this pull request Feb 27, 2019
Fixes OpenAPITools#1696

An object schema containing no properties that also has additionalProperties
set to an object schema with no properties will cause
ModelUtils.isFreeFormObject to throw an NPE.
This PR adds additional checking to avoid the NPE.
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

Comments