OpenAPITools / OpenAPITools/openapi-generator
[BUG][typescript][axios] Getting java.lang.OutOfMemoryError when generating apis
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 (example)?
- 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 made some minor changes to the schema of my OpenAPI specification and since that I've been getting out of memory error when generating the client code. Here's the error I'm getting:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.base/java.util.Arrays.copyOfRange(Arrays.java:3821)
at java.base/java.lang.StringLatin1.newString(StringLatin1.java:764)
at java.base/java.lang.StringBuilder.toString(StringBuilder.java:447)
at com.fasterxml.jackson.core.util.TextBuffer.contentsAsString(TextBuffer.java:426)
at com.fasterxml.jackson.core.io.SegmentedStringWriter.getAndClear(SegmentedStringWriter.java:83)
at com.fasterxml.jackson.databind.ObjectWriter.writeValueAsString(ObjectWriter.java:1011)
at io.swagger.v3.core.util.Json.pretty(Json.java:24)
at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:2296)
at org.openapitools.codegen.DefaultCodegen.handleMethodResponse(DefaultCodegen.java:3623)
at org.openapitools.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:3747)
at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1113)
at org.openapitools.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:1038)
at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:561)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:878)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:440)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
Using verbose mode, I see output for a number of my operations then it eventually throws the error above.
I also tried using the CLI jar and specified a high -Xms which made no difference.
openapi-generator version
5.1.0 (Mac) and 5.1.1 (CLI jar)
OpenAPI declaration file content or url
Swagger generated OpenAPI spec:
https://gist.githubusercontent.com/sirmyron/4d6c961f5d5418e122aa14658ed64634/raw/4b37b1ff6b9fe76696e3a325ccdd0c2ce0fb9b14/api.json
Generation Details
I've tried the following commands, using both flat file and url pointing to the swagger specification:
openapi-generator generate -g typescript-axios -i http://localhost:8060/core/v3/api-docs -o /app/src/core/api/core --skip-validate-spec --additional-properties=enumPropertyNaming=UPPERCASE,enumNameSuffix=,legacyDiscriminatorBehavior=false,withSeparateModelsAndApi=true,apiPackage=endpoints,modelPackage=models,supportsES6=true
java -jar -Xms4096M ./openapi-generator-cli.jar generate -i http://localhost:8060/core/v3/api-docs -g typescript-axios --skip-validate-spec --additional-properties enumPropertyNaming=UPPERCASE,enumNameSuffix=,legacyDiscriminatorBehavior=false,withSeparateModelsAndApi=true,apiPackage=endpoints,modelPackage=models,supportsES6=true -o /app/src/core/api/core
Steps to reproduce
You can try executing any one of the commands above using the open api json file above.
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
Reproduce with the supplied OpenAPI JSON and the generation command, then inspect Json.pretty and DefaultCodegen.fromModel around the reported stack trace. Follow the call path through handleMethodResponse, DefaultGenerator.processOperation, and generateApis. Done means the supplied specification generates the typescript-axios client without a Java heap-space error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100