Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #6028
Closed
Open
Issue created Apr 23, 2020 by Administrator@rootContributor

[BUG] [JAVA][MICROPROFILE] Error during client generation due to wrong import addition

Created by: FuoriDiTesta

Description

Generating a client for language Java, library Microprofile, in a maven project, the compilation failed due to additional packages that are not included in microprofile dependencies. To be specific:

  1. Date library are always JodaTime, even if something different is specified
  2. javax.xml.bind are always imported, even if xml is set to false
  3. package org.apache.cxf.jaxrs.ext.multipart is always declared as import

Point 2 and 3 are packages that are not used in the code.

It's possible to fix these behavior, to avoid to have to add not necessary dependencies to the project?

openapi-generator version

openapi-generator 4.3.0 used

OpenAPI declaration file content or url

To try to make it work at least locally, this is what i found in the code:

  1. JodaTime: in modules\openapi-generator\src\main\java\org\openapitools\codegen\languages\JavaClientCodegen.java:

    • comment line 422 (importMapping.put("LocalDate", "org.joda.time.LocalDate");)
    • comment line 202-203 } else if (MICROPROFILE.equals(getLibrary())) { dateLibrary = "legacy"; to disable the forcing of JodaLibraries as api, and it works perfectly, for JAVA8. Not tested for other date approach
  2. XML package import always present: In modules\openapi-generator\src\main\resources\Java\libraries\microprofile\pojo.mustache i replaced import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue;

    with {{#withXml}} import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlType; import javax.xml.bind.annotation.XmlEnum; import javax.xml.bind.annotation.XmlEnumValue; {{/withXml}}

  3. For cxf multipart: In modules\openapi-generator\src\main\resources\Java\libraries\microprofile\api.mustache removed {{^disableMultipart}} import org.apache.cxf.jaxrs.ext.multipart.*; {{/disableMultipart}}

In this case, to make it works i can only remove these three lines; also this disableMultiPart is not clear from where it came from.

Command line used for generation

Maven project, mvn compile generate the error

Steps to reproduce

Execute a mvn compile on the sample projects sample.zip

Related issues/PRs

I haven't found any related issues/PRs

Suggest a fix/enhancement

fix/enhancement described previously

Assignee
Assign to
Time tracking