Skip to content

[BUG] Model Name Mapping is not functional in Java codegen.  #17189

@krisnik

Description

@krisnik

Bug Report Checklist

Hi, I have attempted to use the modelNameMapping configuration. But the generated SDK does not seem to render it.

Went through few reference PRs. #16209

The configuration was passed via pom.xml

           <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>6.3.0</version>
                <executions>
                    <execution>
                        <id>generate-java-sdk2</id>
                        <phase>install</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <skip>${sdk.codegen.skip}</skip>
                            <inputSpec>${project.build.directory}/openapi.json</inputSpec>
                            <generatorName>java</generatorName>
                            <groupId>${sdk2.java.groupId}</groupId>
                            <artifactId>${sdk2.java.artifactId}</artifactId>
                            <artifactVersion>${sdk2.java.version}</artifactVersion>
                            <packageName>${sdk2.java.packageName}</packageName>
                            <apiPackage>${sdk2.java.packageName}.api</apiPackage>
                            <modelPackage>${sdk2.java.packageName}.models</modelPackage>
                            <invokerPackage>${sdk2.java.packageName}.invoker</invokerPackage>
                            <generateModelTests>false</generateModelTests>
                            <output>${sdk2.java.outputDirectory}</output>
                            <library>webclient</library>
                            <verbose>true</verbose>
                            <importMappings>
                                <importMapping>User=com.foo.sdk.common.models.User</importMapping>
                                <importMapping>Link=com.foo.sdk.common.models.Link</importMapping>
                            </importMappings>
                            <schemaMappings>
                                <schemaMapping>EntityModelUserAccount=com.foo.sdk.models.UserAccount</schemaMapping>
                            </schemaMappings>
                            <!-- <modelNameMappings>
                                <modelNameMapping>EntityModelUserAccount=com.foo.sdk.models.UserAccount</modelNameMapping>
                            </modelNameMappings> -->
                            <configOptions>
                                <hateoas>true</hateoas>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Seems like the support is available only for select generators.

Could you please suggest how to proceed and enable support for java.

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • 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
openapi-generator version
OpenAPI declaration file content or url
Steps to reproduce
Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions