Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #710
Closed
Open
Issue created Aug 01, 2018 by Administrator@rootContributor

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

https://github.com/OpenAPITools/openapi-generator/blob/ab08dd1d26c3140f35fe9e0b65231fdde27de9ce/modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml#L1221-L1277

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

Related issues/PRs
Suggest a fix/enhancement
Assignee
Assign to
Time tracking