OpenAPITools / OpenAPITools/openapi-generator
[BUG] [JAVA] "additionalProperties" does not generate a HashMap Model, openapi: 3.0.2
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
I am using "additionalProperties" in my yaml file as below.
openapi: 3.0.2
....
components:
schemas:
Messages:
type: object
additionalProperties:
$ref: '#/components/schemas/Message'
Message:
type: object
properties:
code:
type: integer
text:
type: string
But when running mvn clean package, no class is being created for Messages. I was expecting to see a class like :
public class Messages extends HashMap<String, Object> {
......
}
in org.openapitools.client.model.Messages the same as other classes generated based on the yaml file. I tried additionalProperties: true and additionalProperties: {} but none of them worked. It seems like a bug
my pom.xml for openapi-generator and swagger versions
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.1</version>
</dependency>
....
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>4.3.1</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
...
</execution>
</executions>
</plugin>
Command line used for generation
mvn clean package
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 with the OpenAPI schema in the issue and the openapi-generator Maven plugin configuration in pom.xml, then run mvn clean package to inspect the generated Java models. Reproduce the missing Messages model and identify the generator path handling additionalProperties; done means a Messages model is generated with the expected map value type and relevant generation coverage exists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100