[BUG] [JAVA] "additionalProperties" does not generate a HashMap Model, openapi: 3.0.2
See original GitHub issueDescription
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
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (4 by maintainers)
Top Results From Across the Web
Dictionaries, Hashmaps, Associative Arrays - Swagger
The additionalProperties keyword specifies the type of values in the dictionary. Values can be primitives (strings, numbers or boolean values), arrays or ...
Read more >Documentation for the java Generator
Select the complementary documentation annotation library. none: Do not annotate Model and Api with complementary annotations. swagger1 ...
Read more >Configure Pojo with Map attribute doesnt' generate ...
The issue is that one of the attributes of my model is a HashMap and I'm trying to configure the pojo in a...
Read more >OpenAPI Specification v3.1.0 | Introduction, Definitions, & More
The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs.
Read more >Restricting to extend hashmap using additionalProp...
We are trying generate a models in swagger 2.0 with additionalProperties and allOf using org.openapitools(openapi-generator-maven-plugin) ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any updates? I tried it with openapi-generator-maven-plugin 5.4.0. and get an compile time error. When adding an item to the hashmap it tries to initialize the Map. Here’s a snippet of the generated code:
Hi, Did you solve this issue how to remove that hashMap how it is substituting.i am also stuck at this problem and I am using open api 5.1.0 version