OpenAPITools / OpenAPITools/openapi-generator

[BUG] openapi-generator-maven-plugin native library with async does not generate fully httpcomponents.client5 code

Open
#22,493 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

To work with the native library and asyncNative=true I have to use the following dependencies:

  • org.apache.httpcomponents.client5:httpclient5:5.4.4
  • org.apache.httpcomponents:httpmime:4.5.14

Because generating an api class gets the imports of

  • import org.apache.http.HttpEntity
    Which comes from org.apache.httpcomponents:httpcore:4.4.16

But I expected it to come from org.apache.httpcomponents:httpcore5:5.3.4, which is part of the dependency list of the client5

The same counts for imports in the api for

import org.apache.http.NameValuePair;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;

full config in mvn project pom (the input-spec is en openapi 3.1.0 schema yaml):

            <plugin>
                <groupId>org.openapitools</groupId>
                <artifactId>openapi-generator-maven-plugin</artifactId>
                <version>7.17.0</version>
                <executions>
                    <execution>
                        <id>dinq-client</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <globalProperties>
                                <skipFormModel>false</skipFormModel>
                            </globalProperties>
                            <inputSpec>${openapi-generator.input-spec}</inputSpec>
                            <generatorName>java</generatorName>
                            <configOptions>
                                <library>native</library>
                                <packageName>dinq-maven-plugin.client</packageName>
                                <generateApis>true</generateApis>
                                <generateApiDocumentation>false</generateApiDocumentation>
                                <apiPackage>${openapi-generator.base-package}.api</apiPackage>
                                <modelPackage>${openapi-generator.base-package}.model</modelPackage>
                                <generateSupportingFiles>true</generateSupportingFiles>
                                <configHelp>false</configHelp>
                                <generateSourceCodeOnly>true</generateSourceCodeOnly>
                                <disallowAdditionalPropertiesIfNotPresent>false
                                </disallowAdditionalPropertiesIfNotPresent>
                                <generateBuilders>true</generateBuilders>
                                <useJakartaEe>true</useJakartaEe>
                                <asyncNative>true</asyncNative>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Java generator's native library handling and the asyncNative=true configuration in the Maven example. Generate a client from the reported OpenAPI 3.1.0 schema, inspect the generated API imports, and verify that the client compiles using the listed HttpClient 5 dependencies without requiring HttpClient 4 classes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.