-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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] [JAVA][MICROPROFILE] Error during client generation due to wrong import addition #6028
Comments
For issue 2. Getting rid of jaxb imports causes issues in microprofile rest client since it uses XmlEnum for Enum datatypes. The microprofile template is a common template for generating both xml and json model types. microprofile-rest client template supports two content-types application/json & application/xml. |
Hi Ravisankar-Challa , sorry it's not completely clear your reply. If i have also applicaiton/xml i will set the xml configuration to true when i generate; actually, even if i have absolutely no necessity of these import, because i have only application/json, i must include them. Or better, is not clear why, in file the list import javax.xml.bind.annotation.XmlElement; has not been included in the {{#withXml}}{{/withXml}} block, so that they will be included in the class only when the with xml is active, and they are really necessary. |
@FuoriDiTesta |
@Ravisankar-Challa thanks for the PR, which only changes 2 lines: https://github.com/OpenAPITools/openapi-generator/pull/6062/files.
Do you actually mean it requires fewer changes? |
@wing328 There are 3 issues reported in this ticket. |
Is there some way to suppress the cxf import? I've tried every way I can find to stuff disableMultipart into the generator, but none seem to remove that import. |
I am using openapi-generator-maven-plugin, managed to remove the import by defining the following in the plugin configuration:
below the plugin configuration in my
|
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:
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:
JodaTime:
in modules\openapi-generator\src\main\java\org\openapitools\codegen\languages\JavaClientCodegen.java:
} 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
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}}
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
The text was updated successfully, but these errors were encountered: