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
  • #7369
Closed
Open
Issue created Sep 08, 2020 by Administrator@rootContributor5 of 6 checklist items completed5/6 checklist items

[BUG] Incorrect enum values for typescript clients

Created by: epidemia

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 issuue still exists?
  • Have you search 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

Enum values are generated incorrectly for PascalCase enum property naming type when the source enum values are in uppercase with underscores. For example, original enum values:

"BookType": {
        "type": "string",
        "description": "Book Type",
        "example": "SCIENCE",
        "enum": [
          "SCIENCE",
          "SCIENCE_FICTION"
        ]
      }

Expected enum values:

export enum BookType {
  Science = 'SCIENCE',
  ScienceFiction = 'SCIENCE_FICTION'
}

Actual enum values:

export enum BookType {
  SCIENCE = 'SCIENCE',
  SCIENCEFICTION = 'SCIENCE_FICTION'
}
openapi-generator version

5.0.0-SNAPSHOT

OpenAPI declaration file content or url
{
  "openapi": "3.0.1",
  "info": {
    "title": "OpenAPI definition",
    "version": "v0"
  },
  "servers": [
    {
      "url": "/"
    }
  ],
  "paths": {
    "/books/{id}": {
      "get": {
        "tags": [
          "controller"
        ],
        "description": "Get book by ID",
        "operationId": "getBookById",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "*/*": {
                "schema": {
                  "$ref": "#/components/schemas/Book"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Book": {
        "required": [
          "id",
          "type"
        ],
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "ID",
            "format": "uuid"
          },
          "type": {
            "type": "string",
            "description": "Book type",
            "enum": [
              "SCIENCE",
              "SCIENCE_FICTION"
            ]
          }
        },
        "description": "Book"
      }
    },
    "securitySchemes": {
      "basicScheme": {
        "type": "http",
        "scheme": "basic"
      }
    }
  }
}
Generation Details

Generator: typescript-axios Config options:

<configOptions>
   <enumPropertyNaming>PascalCase</enumPropertyNaming>
</configOptions>
Steps to reproduce

This issue can be reproduced by using the typescript-axios generator with the OpenAPI declaration & config from above.

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