Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] modelNamePrefix should not get applied to typeMappings #19043

Open
davemeier82 opened this issue Jul 1, 2024 · 0 comments
Open

[BUG] modelNamePrefix should not get applied to typeMappings #19043

davemeier82 opened this issue Jul 1, 2024 · 0 comments

Comments

@davemeier82
Copy link

Description

When you define a modelNamePrefix it also gets applied to the typeMappings target name. This causes that the importMappings not to match.

Example:

<modelNamePrefix>Abc</modelNamePrefix>
<typeMappings>string+binary=Resource</typeMappings>
<importMappings>Resource=org.springframework.core.io.Resource</importMappings>

generates an API class like:

import com.test.model.AbcResource;
...

public Mono<AbcResource> getTransaction(String transactionId) {
...

but I would expect:

import org.springframework.core.io.Resource;
...

public Mono<Resource> getTransaction(String transactionId) {
...
openapi-generator version

openapi-generator-maven-plugin 7.5.0

OpenAPI declaration file content or url

Maven plugin code

<plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <configuration>
          <generateModelDocumentation>false</generateModelDocumentation>
          <skipValidateSpec>false</skipValidateSpec>
          <strictSpec>true</strictSpec>
          <generateApiTests>false</generateApiTests>
          <generateModelDocumentation>false</generateModelDocumentation>
          <generateModelTests>false</generateModelTests>
          <modelNamePrefix>Abc</modelNamePrefix>
          <configOptions>
            <dateLibrary>java8</dateLibrary>
            <implicitHeaders>true</implicitHeaders>
            <java8>true</java8>
            <openApiNullable>false</openApiNullable>
            <swaggerAnnotations>false</swaggerAnnotations>
            <useSpringBoot3>true</useSpringBoot3>
            <useJakartaEe>true</useJakartaEe>
            <useTags>true</useTags>
          </configOptions>
        </configuration>
        <executions>
          <execution>
            <id>generate-transaction-api</id>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${project.basedir}/spec.yaml</inputSpec>
              <generatorName>java</generatorName>
              <library>webclient</library>
              <apiPackage>com.test.api</apiPackage>
              <modelPackage>com.test.model</modelPackage>
              <typeMappings>string+binary=Resource</typeMappings>
              <importMappings>Resource=org.springframework.core.io.Resource</importMappings>
            </configuration>
          </execution>
        </executions>
      </plugin>

spec.yaml:

openapi: 3.0.3
info:
  title: aaa
  version: 1.0.0

tags:
  - name: TransactionsV1
paths:
  /v1/transactions/{transactionId}:
    get:
      tags:
        - TransactionsV1
      summary: abc
      operationId: getTransaction
      parameters:
        - name: transactionId
          in: path
          required: true
          description: The transaction id.
          schema:
            type: string
      responses:
        '200':
          description: abc
          content:
            application/pdf:
              schema:
                type: string
                format: binary
Generation Details

see above

Steps to reproduce

see above

Suggest a fix

Do not apply modelNamePrefix and modelNameSuffix to typeMappings target

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant