[BUG] [JavaScript] java.lang.OutOfMemoryError on simple OpenAPI file
Created by: advance512
Description
Using the following OpenAPI file below, the following error occurs:
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.util.Arrays.copyOfRange(Arrays.java:3664)
at java.lang.String.<init>(String.java:207)
at java.lang.StringBuilder.toString(StringBuilder.java:407)
at com.fasterxml.jackson.core.util.TextBuffer.contentsAsString(TextBuffer.java:404)
at com.fasterxml.jackson.core.io.SegmentedStringWriter.getAndClear(SegmentedStringWriter.java:83)
at com.fasterxml.jackson.databind.ObjectWriter.writeValueAsString(ObjectWriter.java:999)
at io.swagger.v3.core.util.Json.pretty(Json.java:24)
at org.openapitools.codegen.DefaultCodegen.fromModel(DefaultCodegen.java:1627)
at org.openapitools.codegen.languages.JavascriptClientCodegen.fromModel(JavascriptClientCodegen.java:842)
at org.openapitools.codegen.DefaultCodegen.fromOperation(DefaultCodegen.java:2437)
at org.openapitools.codegen.DefaultGenerator.processOperation(DefaultGenerator.java:1021)
at org.openapitools.codegen.DefaultGenerator.processPaths(DefaultGenerator.java:944)
at org.openapitools.codegen.DefaultGenerator.generateApis(DefaultGenerator.java:516)
at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:902)
at org.openapitools.codegen.cmd.Generate.run(Generate.java:368)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:60)
openapi-generator version
This happens both in openapi-generator-cli-4.0.0-20190325.151629-451.jar
and openapi-generator-cli-3.3.4.jar
.
OpenAPI declaration file content or url
swagger: '2.0'
info:
version: "1.0"
title: DEV-2369
# ===============================================================================
# Paths
# ===============================================================================
paths:
/users/responders:
get:
operationId: getUserResponderList
summary: Gets a list of Responder objects
responses:
'200':
description: A list of Responder objects
schema:
$ref: '#/definitions/ResponderList'
'500':
$ref: '#/responses/InternalServerError'
default:
$ref: '#/responses/TotallyUnexpectedResponse'
/responders:
post:
operationId: createResponder
parameters:
- name: responder
in: body
required: true
schema:
$ref: '#/definitions/ResponderCreate'
responses:
'201':
description: A Responder object
schema:
$ref: '#/definitions/Responder'
'400':
$ref: '#/responses/BadRequest'
'500':
$ref: '#/responses/InternalServerError'
default:
$ref: '#/responses/TotallyUnexpectedResponse'
# ===============================================================================
# Definitions
# ===============================================================================
definitions:
ID:
type: integer
format: int64
readOnly: true
Reviewer:
type: object
properties:
name:
type: string
maxLength: 100
SuccessfulBugFix:
type: object
properties:
reviewers:
type: array
minItems: 0
maxItems: 100
uniqueItems: true
items:
$ref: '#/definitions/Reviewer'
ResponderProfileCreate:
type: object
properties:
successfulBugFixes:
type: array
minItems: 0
maxItems: 100
uniqueItems: true
items:
$ref: '#/definitions/SuccessfulBugFix'
ResponderProfile:
type: object
properties:
successfulBugFixes:
type: array
minItems: 0
maxItems: 100
uniqueItems: true
items:
$ref: '#/definitions/SuccessfulBugFix'
Error:
type: object
required:
- message
properties:
message:
type: string
User:
type: object
properties:
id:
$ref: '#/definitions/ID'
Responder:
type: object
properties:
id:
$ref: '#/definitions/ID'
responderProfile:
$ref: '#/definitions/ResponderProfile'
# Used only for the creation of a new Responder
ResponderCreate:
type: object
properties:
responderProfile:
$ref: '#/definitions/ResponderProfileCreate'
ResponderList:
type: object
required:
- items
properties:
items:
type: array
minItems: 0
maxItems: 1000
uniqueItems: true
items:
$ref: '#/definitions/Responder'
# ===============================================================================
# Responses
# ===============================================================================
responses:
InternalServerError:
description: An unexpected error occured.
schema:
$ref: '#/definitions/Error'
BadRequest:
description: Bad request; could not perform requested operation.
EntityDoesNotExist:
description: Entity does not exist.
TotallyUnexpectedResponse:
description: A totally unexpected response
Command line used for generation
java -jar ./openapi-generator-cli-3.3.4.jar generate -i ../openapi.yaml -l javascript --additional-properties usePromises=true --additional-properties useES6=false -o ./javascript/
also:
java -jar ./openapi-generator-cli-4.0.0-20190325.151629-451.jar generate -i ../openapi.yaml -g javascript -o ./javascript/
also:
java -jar ./openapi-generator-cli-4.0.0-20190325.151629-451.jar generate -i ../openapi.yaml -g javascript --additional-properties usePromises=true --additional-properties useES6=false -o ./javascript/
Steps to reproduce
- Save the OpenAPI spec into a file called
openapi.yaml
. - Run either of the commands above.
Related issues/PRs
None that I am aware of.
Suggest a fix
Not sure.