[BUG] [Elm] elmPrefixCustomTypeVariants
Created by: andys8
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
"Answers": {
"type": "object",
"required": [
"houseLiving",
"liabilityLegalProtection",
"pets"
],
"properties": {
"houseLiving": {
"type": "string",
"enum": [
"RENTED",
"OWN_HOUSE",
"OWN_FLAT",
"PARENTS_HOUSE",
"SHARED_FLAT",
"RENT_FREE"
]
},
"liabilityLegalProtection": {
"type": "array",
"items": { "type": "string", "enum": ["BUILDER", "LANDLORD"] }
},
"pets": {
"type": "array",
"items": {
"type": "string",
"enum": ["DOG", "CAT", "HORSE", "AQUARIUM"]
}
}
},
"title": "Answers"
}
type HouseLiving
= HouseLivingRENTED
| HouseLivingOWNHOUSE
| HouseLivingOWNFLAT
| HouseLivingPARENTSHOUSE
| HouseLivingSHAREDFLAT
| HouseLivingRENTFREE
type LiabilityLegalProtection
= LiabilityLegalProtectionLiabilityLegalProtectionLiabilityLegalProtectionLiabilityLegalProtectionBUILDER
| LiabilityLegalProtectionLiabilityLegalProtectionLiabilityLegalProtectionLiabilityLegalProtectionLANDLORD
type Pets
= PetsPetsPetsPetsDOG
| PetsPetsPetsPetsCAT
| PetsPetsPetsPetsHORSE
| PetsPetsPetsPetsAQUARIUM
The actual output for LiabilityLegalProtection
and Pets
should only add the prefix a single time.
openapi-generator version
v4.0.0-beta3
Command line used for generation
docker run --rm \
-v "$PWD:/local" \
openapitools/openapi-generator-cli:${OPEN_API_VERSION} generate \
-i /local/swagger.json \
-o "/local/$SDK_DIR/$generator" \
-g "$generator" \
--invoker-package "crm" \
--additional-properties elmEnableCustomBasePaths=true \
--additional-properties elmPrefixCustomTypeVariants=true
Suggest a fix
A fix would be to check if the prefix is already part of the value. This will work, but will not remove the root cause. It seems that certain cases leed to concatenating the prefix 4 times. In other cases it's working fine.
@eriktim What do you think?