question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG][openapi-generator-maven-plugin] importmapping not respected since 5.4.0

See original GitHub issue

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue? Yes, inside attached ZIP
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists? -> No, but tested with 5.4.0
  • Have you searched for related issues/PRs?
  • What’s the actual output vs expected output? Expected: StreamingResponseBody, Actual: Stream
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

The “importMappings” seem to have no effect with version 5.4.0. With version 5.3.1 the below configuration resulted in a “StreamingResponseBody” in the generated class. With version 5.4.0 a “Stream” class is imported but that one does not exist.

openapi-generator version

Issue occurs with openapi-generator-maven-plugin 5.4.0 and did not occur with the previous version 5.3.1.

OpenAPI declaration file content or url

If you post the code inline, please wrap it with

openapi: 3.0.3
info:
  title: Demo app
  version: 1.0.0
servers:
  - url: /api/v1
paths:
  /demo:
    get:
      summary: Demo
      operationId: demo
      responses:
        '200':
          description: Demo response
          content:
            text/csv:
              schema:
                type: string
                format: binary
Generation Details

Plugin configuration:

      <plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <!-- With version 5.3.1 of the plugin, the generated "DemoApi.java" contains default org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody as expected -->
        <!-- With version 5.4.0 of the plugin, the generated "DemoApi.java" contains "Stream", but the org.example.bug.demo.api.Stream is not created -->
        <version>5.4.0</version>
        <executions>
          <execution>
            <id>bug-demo</id>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${project.basedir}/src/main/resources/spec.yaml</inputSpec>
              <generatorName>spring</generatorName>
              <apiPackage>org.example.bug.demo.api</apiPackage>
              <modelPackage>org.example.bug.demo.api</modelPackage>
              <configOptions>
                <delegatePattern>true</delegatePattern>
              </configOptions>
              <importMappings>
                stream=org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody
              </importMappings>
              <typeMappings>string+binary=stream</typeMappings>
            </configuration>
          </execution>
        </executions>
      </plugin>
Steps to reproduce

Run mvn clean install on the attached demo project.

Related issues/PRs

No similar issues.

Suggest a fix

Not sure what causes the problems, but I assume it has to do with this change: https://github.com/OpenAPITools/openapi-generator/pull/11217

bug Demo application

bug-demo.zip

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:6
  • Comments:26 (11 by maintainers)

github_iconTop GitHub Comments

6reactions
sigandcommented, Feb 16, 2022

Same, but for the gradle plugin

4reactions
clemjtcommented, Feb 21, 2022

Same here

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found