-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Issue Type
This issue is with quicktype output
Context (Environment, Version, Language)
Version : Eclipse Temurin JDK 21.0
Language : java
Input Format: json
Output Language: Java
CLI, npm, or app.quicktype.io: npm
Version: 23.2.6
Description
We have a business requirement where we define an enum in a json file. I had a task to enhance this enum by adding another enum constant in it with the value "MULTI_SPA_IN_GROUP_REJECTED", however the generated Enum in java does some wierd case conversion and generates - "MULTI_Spa_IN_GROUP_REJECTED". This only happens for the substring - "SPA", it is getting automatically coverted to "Spa" ( loosing the original upper casing) which is super weird as the other enum value generations are working as expected, without any messing up of the casing.
Input Data
"MessageCode": { "title": "MessageCode", "type": "object", "required": [ "code" ], "properties": { "code": { "enum": [ "SOME_OTHER_VALUE", **"MULTI_SPA_IN_GROUP_REJECTED"** [newly added] ], "type": "string", "description": "the code of the message", "examples": [ "ITEM_REMOVED" ] } } }
Expected Behaviour / Output
The enum constants that contain the string "SPA" SHOULD NOT LOOSE the case in the generated code and show up as defined in the json schema definition.
`public enum MessageCode {
SOME_OTHER_VALUE, MULTI_SPA_IN_GROUP_REJECTED;
@JsonValue
public String toValue() {
switch (this) {
case SOME_OTHER_VALUE: return "SOME_OTHER_VALUE";
case MU_SPA: return "MULTI_SPA_IN_GROUP_REJECTED";
}
return null;
}`
Current Behaviour / Output
The enum constants that contain the string "SPA" LOOSES the case in the generated code and does not show up as defined in the json schema definition.
For the quicktype command, we are using below options:
--lang=java \ --array-type=list \ --datetime-provider java8 \ --lombok-copy-annotations \ --lombok \ --alphabetize-properties \ --acronym-style=camel
Currently generated java code :
`public enum MessageCode {
SOME_OTHER_VALUE, MULTI_Spa_IN_GROUP_REJECTED;
@JsonValue
public String toValue() {
switch (this) {
case SOME_OTHER_VALUE: return "SOME_OTHER_VALUE";
case MULTI_Spa_IN_GROUP_REJECTED: return "MULTI_SPA_IN_GROUP_REJECTED";
}
return null;
}`
Note: If you think that I am using acryonym-style as "camel", I want to emphasize that the enum code generation works perfectly well for other enums as long as they don't have the string "SPA" in it.
Steps to Reproduce
- Create a json file that defines an enum.
- In the enum, add this particular value - "MULTI_SPA_IN_GROUP_REJECTED".
- Generate the java code for this enum as per the options I have mentioned in the input.
- You should see that the java enum class for it will have the enum value as "MULTI_Spa_IN_GROUP_REJECTED".
- The string "SPA" looses cases and wrongly generated as "MULTI_Spa_IN_GROUP_REJECTED".
Possible Solution
Not sure, as I have not seen the code.