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.