OpenAPITools / OpenAPITools/openapi-generator

[BUG][jaxrs-spec] disallowAdditionalPropertiesIfNotPresent leads to compilation errors

Open
#23,573 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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

see https://github.com/Philipp-Borchert-ISH/jaxrs-spec-repro/blob/8e8761881dbd8ed264e5839466e6be424c73c6fd/pom.xml#L102-L121

Steps to reproduce
  1. run mvn compile or ./mvnw compile
  2. observe compilation errors due to missing "extends Map<>" on several POJOs
Suggest a fix

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.