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
  • #893
Closed
Open
Issue created Aug 24, 2018 by Administrator@rootContributor

Invalid enum var names are generated by multi-byte characters

Created by: osjupiter

Description

Hi. I have been using openapi-generator with definitions which contains multi-byte characters. When I wrote enum definitions which names contain only non-word characters(RegExp \W), invalid code generated. (All of enum names become "_".)

Are double-byte characters not allowed for enum names in OAS ? If it is valid, I hope these characters will be supported.

generated code

java

@JsonAdapter(PetType.Adapter.class)
public enum PetType {
  _("猫"), // cat   --compile error
  _("犬"); // dog

go

type PetType string
// List of PetType
const (
	 PetType = "猫" // compile error
	 PetType = "犬"
)
openapi-generator version

3.2.3-SNAPSHOT

OpenAPI declaration file content or url
swagger: "2.0"
info:
  title: "example"
  version: "1.0"
paths:
  /pet:
    post:
      parameters:
        - in: body
          name: data
          schema:
            type: object
            properties:
              animal:
                $ref: "#/definitions/PetType"
      responses:
        "200":
          description: ok
definitions:
  PetType:
    type: string
    enum:
      - 猫
      - 犬
    x-enum-names:
      - Cat
      - Dog
Command line used for generation
java -jar openapi-generator-cli-3.2.3-20180824.092221-7.jar generate  -i sample.yaml -g java -o dest
Steps to reproduce

just generated

Related issues/PRs

I could not find it.

Suggest a fix/enhancement

I always create a customized config class and add x-enum-names extension by overriding postProcessModelsEnum and updateCodegenPropertyEnum like this.

I think it is not good to positively use multi-byte characters as an api parameter.
So it is enough to be able to use it by extension.

Thanks.

Assignee
Assign to
Time tracking