swagger-api / swagger-api/swagger-codegen-generators
NPE in JavaClientCodegen when having "#/components/" prefixes
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 299
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
In JavaClientCodegen.modelInheritanceSupportInGson() there is iteration over byParent.entrySet(). Inside the iteration keys are being modified by parentModel.discriminator.getMapping().replaceAll((key, value) -> OpenAPIUtil.getSimpleRef(value)) which is against contract and are producing inconsistent results.
For example byParent.get(parentModel) can return null if parent of current parentModel was already modified in previous iteration. After that there is NPE on for (CodegenModel model : childrenModels), but root cause is modification of keys.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in JavaClientCodegen.modelInheritanceSupportInGson() and inspect the byParent.entrySet() iteration and discriminator mapping update described in the issue. Reproduce the #/components/ case, then verify that parent lookups remain valid and the iteration no longer reaches the reported NPE.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100