OpenAPITools / OpenAPITools/openapi-generator
[BUG] [JAVA] Slow client
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I am experiencing, that the generated java client is extremely slow. When creating a http request to the endpoint running locally using the generated client, it takes around 40ms. If a create a request using java.net.http.HttpClient, it takes around 1ms.
openapi-generator version
7.15.0
OpenAPI declaration file content or url
{
"openapi": "3.0.3",
"info": {
"title": "server",
"description": "<h1>server</h1>",
"version": "4.39.0"
},
"servers": [
{
"url": "/"
}
],
"tags": [
{
"name": "ChainController",
"description": "Controller for the chain."
}
],
"paths": {
"/chain/transactions": {
"put": {
"tags": [
"ChainController"
],
"description": "Put a transaction on the chain.",
"operationId": "putTransaction",
"parameters": [],
"requestBody": {
"description": "the transaction to put on the chain",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/SerializedTransaction"
}
}
},
"required": true
},
"responses": {
"204": {
"description": "an object containing the information about the added transaction",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TransactionPointer"
}
}
}
},
"400": {
"description": "a response containing an error message, address of the sender and an error type",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PutTransactionErrorInformation"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Base64": {
"title": "Base64",
"type": "string",
"format": "byte",
"description": "Data in a base64 encoded string"
},
"Hash": {
"title": "Hash",
"type": "string",
"description": "Is the result of a hashing process, a list of bytes passed through a stream.",
"example": "01234567890abcdef01234567890abcdef01234567890abcdef01234567890abcdef"
},
"SerializedTransaction": {
"title": "SerializedTransaction",
"required": [
"payload"
],
"type": "object",
"properties": {
"payload": {
"$ref": "#/components/schemas/Base64"
}
},
"description": "Serialized transaction transfer record."
},
"TransactionPointer": {
"title": "TransactionPointer",
"required": [
"identifier",
"destinationShardId"
],
"type": "object",
"properties": {
"identifier": {
"$ref": "#/components/schemas/Hash"
},
"destinationShardId": {
"type": "string",
"description": ""
}
},
"description": "Transaction pointer transfer record."
},
"PutTransactionErrorInformation": {
"title": "PutTransactionErrorInformation",
"required": [
"errorMessage",
"putTransactionErrorType"
],
"type": "object",
"properties": {
"errorMessage": {
"type": "string",
"description": "Message explaining why the transaction was not put on the chain"
},
"sender": {
"type": "string",
"description": "Blockchain address of the recovered sender for the transaction"
},
"putTransactionErrorType": {
"$ref": "#/components/schemas/PutTransactionErrorType"
}
},
"description": "Contains information about the error that resulted in the transaction not being put on the chain"
},
"PutTransactionErrorType": {
"type": "string",
"enum": [
"INVALID_SIGNATURE",
"INVALID_TIME",
"INSUFFICIENT_GAS",
"ROUTING_ERROR",
"ACCOUNT_NOT_FOUND",
"UNEXPECTED_NONCE",
"BYTES_NOT_DESERIALIZABLE"
],
"description": "The type of error that resulted in the transaction not being put on the chain"
}
}
}
}
Generation Details
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<executions>
<execution>
<id>java</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/../server/src/main/resources/openapi.json</inputSpec>
<generatorName>java</generatorName>
<templateDirectory>${project.basedir}/templates</templateDirectory>
<invokerPackage>com.partisiablockchain.api.transactionclient.utils</invokerPackage>
<apiPackage>com.partisiablockchain.api.transactionclient.api</apiPackage>
<generateApiTests>false</generateApiTests>
<generateApiDocumentation>false</generateApiDocumentation>
<modelPackage>com.partisiablockchain.api.transactionclient.model</modelPackage>
<generateModelTests>false</generateModelTests>
<generateModelDocumentation>false</generateModelDocumentation>
<configOptions>
<library>jersey3</library>
<serializationLibrary>jackson</serializationLibrary>
<useJakartaEe>true</useJakartaEe>
<openApiNullable>false</openApiNullable>
<supportUrlQuery>false</supportUrlQuery>
<useBeanValidation>false</useBeanValidation>
</configOptions>
<ignoreFileOverride>${project.basedir}/../server/.openapi-generator-ignore</ignoreFileOverride>
<importMappings>
Response=jakarta.ws.rs.core.Response,
</importMappings>
</configuration>
</executions>
</plugin>
Steps to reproduce
- Generate the config
- Call the endpoint
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by generating the Java client with the shown Maven plugin configuration, including the jersey3 library, then exercise the /chain/transactions endpoint. Inspect the generated client and the configured templates while comparing its timing with java.net.http.HttpClient. Done means the slowdown is reproducible, its source is identified, and the generated request path no longer shows the reported gap.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100