OpenAPITools / OpenAPITools/openapi-generator
[BUG][typescript-node] Large spec client results in java.lang.OutOfMemoryError
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
When trying to generate a typescript-node client from a large size v2 spec (10,000 lines of JSON), the generator crashes with java.lang.OutOfMemoryError and this output and stack trace:
[main] WARN o.o.c.ignore.CodegenIgnoreProcessor - Output directory does not exist, or is inaccessible. No file (.openapi-generator-ignore) will be evaluated.
[main] INFO o.o.codegen.DefaultGenerator - OpenAPI Generator: typescript-node (client)
[main] INFO o.o.codegen.DefaultGenerator - Generator 'typescript-node' is considered stable.
[main] INFO o.o.c.l.AbstractTypeScriptClientCodegen - Hint: Environment variable 'TS_POST_PROCESS_FILE' (optional) not defined. E.g. to format the source code, please try 'export TS_POST_PROCESS_FILE="/usr/local/bin/prettier --write"' (Linux/Mac)
[main] INFO o.o.c.l.AbstractTypeScriptClientCodegen - Note: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).
[main] WARN o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/identity]
[main] WARN o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/identity]
[main] INFO o.o.codegen.DefaultGenerator - Model LayoutReference not generated since it's a free-form object
[main] INFO o.o.codegen.DefaultGenerator - Model literal not generated since it's a free-form object
[main] INFO o.o.codegen.DefaultGenerator - Model Evaluator not generated since it's a free-form object
[main] INFO o.o.codegen.DefaultGenerator - Model CriteriaOperator not generated since it's a free-form object
[main] INFO o.o.codegen.DefaultGenerator - Model Sort not generated since it's a free-form object
[main] INFO o.o.codegen.DefaultGenerator - Model LinkParams not generated since it's a free-form object
[main] INFO o.o.codegen.DefaultGenerator - Model Clause not generated since it's a free-form object
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOf(Arrays.java:3181)
at java.util.ArrayList.grow(ArrayList.java:265)
at java.util.ArrayList.ensureExplicitCapacity(ArrayList.java:239)
at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:231)
at java.util.ArrayList.add(ArrayList.java:462)
at org.openapitools.codegen.DefaultCodegen.updateAllModels(DefaultCodegen.java:305)
at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:477)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:923)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:416)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:61)
Similar error with swagger-codegen.
openapi-generator version
Standalone: 4.2.2
OpenAPI declaration file content or url
https://vdc-download.vmware.com/vmwb-repository/dcr-public/4e9128db-55e6-443b-acd8-38a1e6de78c2/3820b3fb-9c77-463b-8aa5-e8f2471924e0/api-vra-identity.json from vRealize Automation Identity Service API 7.5 tab Documentation.
Command line used for generation
java -jar openapi-generator-cli-4.2.2.jar generate --input-spec api-vra-identity.json --generator-name typescript-node
Steps to reproduce
Just run above command.
Related issues/PRs
The error is identical to #4398, but the stack trace is not.
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 with DefaultCodegen.updateAllModels and DefaultGenerator.generateModels, where the reported stack trace fails. Reproduce the issue using openapi-generator-cli 4.2.2, the linked vRealize Identity Service specification, and the typescript-node command. Done means generation no longer terminates with Java heap-space exhaustion for this specification.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100