Parser optionalVars.hasMore in models
Created by: ybelenko
Description
Found weird parser bug.
Last variable in optionalVars
array shows hasMore: true
which is obviously wrong.
It's even more weird that this behavior noticed only with FormatTest
(definition: format_test
) model withing all spec.
This bug breaks constructor function in models generation.
Mustache
public function construct(
{{#hasRequired}}
{{#requiredVars}}
${{name}}{{#hasMore}},{{/hasMore}}{{^hasMore}}{{#hasOptional}},{{/hasOptional}}{{/hasMore}}
{{/requiredVars}}
{{/hasRequired}}
{{#hasOptional}}
{{#optionalVars}}
${{name}} = null{{#hasMore}},{{/hasMore}}
{{/optionalVars}}
{{/hasOptional}}
) {
}
Output:
public function __construct(
$number,
$byte,
$date,
$password,
$integer = null,
$int32 = null,
$int64 = null,
$float = null,
$double = null,
$string = null,
$binary = null,
$dateTime = null,
$uuid = null,
) {
}
Link to parser output: https://gist.github.com/ybelenko/89f11291565ed4f8719061c89f082f39#file-formattest-json-L1296-L1345
{
"optionalVars": [
{
"baseName": "uuid",
"getter": "getUuid",
"setter": "setUuid",
"dataType": "string",
"datatypeWithEnum": "string",
"dataFormat": "uuid",
"name": "uuid",
"defaultValueWithParam": " = data.uuid;",
"baseType": "string",
"jsonSchema":
"{\r\n \"type\" : \"string\",\r\n \"format\" : \"uuid\"\r\n}",
"exclusiveMinimum": false,
"exclusiveMaximum": false,
"hasMore": true,
"required": false,
"secondaryParam": false,
"hasMoreNonReadOnly": true,
"isPrimitiveType": true,
"isContainer": false,
"isNotContainer": true,
"isString": true,
"isNumeric": false,
"isInteger": false,
"isLong": false,
"isNumber": false,
"isFloat": false,
"isDouble": false,
"isByteArray": false,
"isBinary": false,
"isFile": false,
"isBoolean": false,
"isDate": false,
"isDateTime": false,
"isUuid": true,
"isListContainer": false,
"isMapContainer": false,
"isEnum": false,
"isReadOnly": false,
"vendorExtensions": {},
"hasValidation": false,
"isInherited": false,
"nameInCamelCase": "Uuid",
"nameInSnakeCase": "UUID",
"isXmlAttribute": false,
"isXmlWrapped": false,
"iexclusiveMaximum": false,
"datatype": "string"
}
]
}
openapi-generator version
3.2.0-SNAPSHOT
OpenAPI declaration file content or url
Command line used for generation
$ bin/php-slim-server-petstore.sh
with -DdebugModels
option
Steps to reproduce
Run generate execution with -DebugModels
option and point to fake spec from description above