openapi-generator-maven-plugin and Java generics

82 Views Asked by At

I think it is a simple question: I am using openapi-generator-maven-plugin 5.1.0 to generate java code. I would like to have a property with type Foo<Bar>. We use a swagger.json file for the DTO definition and the rest of the configuration is in a pom.xml.

How can I do that?

For example, here is a snippet of the swagger.json file:

      "FooBarDto" : {
        "type" : "object",
        "properties" : {
          "fooBar" : {
            "type": "FooOfBar"
          },
...

In the pom.xml, I have defined the typeMapping and importMapping:

...
                            <typeMappings>
                                <typeMapping>FooOfBar=Foo&lt;Bar&gt;</typeMapping>
                            </typeMappings>
                            <importMappings>
                                <importMapping>Foo&lt;Bar&gt;=com.company.Foo</importMapping>
                                <importMapping>Bar=com.company.Bar</importMapping>
                             </importMappings>

...

With this, I have the property generated correctly but Bar is not imported.

What is the right way to do that?

0

There are 0 best solutions below