OpenAPITools / OpenAPITools/openapi-generator
[BUG][jaxrs-spec] disallowAdditionalPropertiesIfNotPresent leads to compilation errors
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Using the generator option:
disallowAdditionalPropertiesIfNotPresent=false
... with the jaxrs-spec generator leads to invalid POJOs being generated.
Seems to be a regression introduced by #22366 (found during openapi-generator-maven-plugin from 7.17 to 7.21).
This part of the change assumes that this.put / this.get methods are present - which is NOT the case when the mentioned generator option is set while "additionalProperties" is not defined on the model - hence the POJO doesn't extend Map<> --> compiler error.
openapi-generator version
7.20, 7.21
OpenAPI declaration file content or url
reproducer repo: https://github.com/Philipp-Borchert-ISH/jaxrs-spec-repro
plain old petstore.yaml https://github.com/Philipp-Borchert-ISH/jaxrs-spec-repro/blob/main/src/main/resources/petstore.yaml
Generation Details
Steps to reproduce
- run
mvn compileor./mvnw compile - observe compilation errors due to missing "extends Map<>" on several POJOs
Suggest a fix
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
Reproduce the failure with the jaxrs-spec generator using the referenced petstore.yaml and the option disallowAdditionalPropertiesIfNotPresent=false, then run mvn compile in the linked reproducer. Inspect the generated POJOs and the change from #22366; done means models without additionalProperties compile without calling Map methods they do not provide.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100