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][jaxrs-cxf] Wrong imports (io.swagger.annotations) #3668

Open
5 tasks done
davidkarlsen opened this issue Aug 17, 2019 · 4 comments
Open
5 tasks done

[BUG][jaxrs-cxf] Wrong imports (io.swagger.annotations) #3668

davidkarlsen opened this issue Aug 17, 2019 · 4 comments

Comments

@davidkarlsen
Copy link

davidkarlsen commented Aug 17, 2019

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [] [Optional] Bounty to sponsor the fix (example)
Description

Generating code with <generatorName>jaxrs-cxf-extended</generatorName> or <generatorName>jaxrs-cxf</generatorName> create invalid imports: io.swagger.annotations, as the speclevel of my api is 3.0.0 it should use io.swagger.v3.oas.annotations

openapi-generator version

4.1.0

OpenAPI declaration file content or url

Cannot disclose

Command line used for generation
 <plugin>
        <groupId>org.openapitools</groupId>
        <artifactId>openapi-generator-maven-plugin</artifactId>
        <version>${openapi-generator-version}</version>
        <executions>
          <execution>
            <id>generate</id>
            <goals>
              <goal>generate</goal>
            </goals>
            <configuration>
              <inputSpec>${project.basedir}/src/main/resources/META-INF/resources/api-v1.yaml</inputSpec>
              <strictSpec>true</strictSpec>
              <generatorName>jaxrs-cxf-extended</generatorName>
              <generateSupportingFiles>false</generateSupportingFiles>
              <generateApiTests>false</generateApiTests>
              <generateModelDocumentation>false</generateModelDocumentation>
              <withXml>true</withXml>
              <!-- https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/jaxrs-cxf.md -->
              <configOptions>
                <!-- important to add this or else codegen is malfunctioning: -->
                <sourceFolder>src/gen/java/main</sourceFolder>
                <interfaceOnly>true</interfaceOnly>
                <useJackson>true</useJackson>
                <dateLibrary>java8</dateLibrary>
                <serializableModel>true</serializableModel>
                <java8>true</java8>
                <booleanGetterPrefix>is</booleanGetterPrefix>
                <useBeanValidation>true</useBeanValidation>
              </configOptions>
              <modelPackage>com.evry.fs.arch.icpautomate.api.v1.model</modelPackage>
              <apiPackage>com.evry.fs.arch.icpautomate.api.v1.api</apiPackage>
            </configuration>
          </execution>
        </executions>
      </plugin>
Steps to reproduce

Configure plugin as described, feeding it a speclevel 3 api description

Related issues/PRs
Suggest a fix

use the updated package path in the templates

@jimschubert jimschubert changed the title [BUG][maven-plugin] Wrong imports (io.swagger.annotations) [BUG][jaxrs-cxf] Wrong imports (io.swagger.annotations) Aug 18, 2019
@jimschubert
Copy link
Member

I've updated the title as this isn't a Maven plugin concern but a concern of the specific generator.

I think this is a feature request rather than a bug. There's no expectation that generated code matches the OpenAPI spec version, but it sounds like this is the assumption being made. I don't disagree, I just wanted to clarify. I think it would make sense that if you're generating a server implementation from a 3.x version spec document, that you're implying you'd like a 3.x implementation generated.

I don't think the parser exposes the spec version to us, so making this work automatically might require a little finesse. It might make sense to add support for the 3.x annotations and default to those, with a fallback option to the 2.0 annotations. I'm not familiar with this specific generator, so I'll defer to the technical committee for Java.

@mohanaraosv
Copy link

mohanaraosv commented Jan 10, 2020

So if we update the mustache templates does it work as expected relates to #5556

@dkellenb
Copy link

dkellenb commented May 11, 2020

We are generating our spring controllers based on openapi definitions (3.0.0). I would also expect, that the annotations used are from io.swagger.v3.oas. Without the change, a switch to springdoc is not possible, due to missing tags and security annotations.

@mohanaraosv
Copy link

We are generating our spring controllers based on openapi definitions (3.0.0). I would also expect, that the annotations used are from io.swagger.v3.oas. Without the change, a switch to springdoc is not possible, due to missing tags and security annotations.

But the original query was when we are using jaxrs-cxf not spring-mvc or webflux implementation.

fizzet added a commit to fizzet/openapi-generator that referenced this issue Jan 24, 2024
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

4 participants