Bug Report Checklist
Description
- [all typescript generators] When
modelNameSuffix option is provided, generated enum names concatenate this with enumSuffix, resulting in smth like BaseNameModelSuffixEnum.
- [
typescript-angular] A custom option modelSuffix is added. When specified, it leads to the same issue with enums (when stringEnums=false)
- [
typescript-angular] The stringEnums=true option removes the default "Enum" suffix, but still keeps the one coming from modelSuffix.
Let's say we have schema with enum:
Response:
type: object
properties:
prop_name:
type: string
enum: [ Capital, UPPER, lower, snake_case, 'illegal+id' ]
Here is what is produced with various generator options:
| generator |
options |
enum name |
| typescript-angular |
stringEnums=true |
ResponsePropName |
| typescript-angular |
stringEnums=true, modelSuffix="Model" |
ResponseModelPropNameModel |
| typescript-angular |
stringEnums=false |
Response.PropNameEnum |
| typescript-angular |
stringEnums=false, modelSuffix="Model" |
ResponseModel.PropNameModelEnum |
| typescript-axios |
- |
ResponsePropNameEnum |
| typescript-axios |
modelNameSuffix="Model" |
ResponseModelPropNameModelEnum |
Other TS generators (typescript-fetch, typescript-rxjs) behave similar to typescript-axios.
openapi-generator version
master, stable
OpenAPI declaration file content or url
gist: spec-enum.yml
Related issues/PRs
Suggest a fix
I suggest the following behavior for all TS generators:
- Without modelNameSuffix, keep the existing behavior demonstrated by typescript-axios.
- With modelNameSuffix, only append "Enum" suffix but not model suffix. So instead of
ResponseModelPropNameModelEnum we should get ResponseModelPropNameEnum
- Make typescript-angular work the same way as other TS generators: deprecate custom
modelSuffix in favor of modelNameSuffix, use the standard enumSuffix="Enum"
- Make
enumSuffix configurable via options. This would provide smoother migration for existing users (e.g. one can set it to ModelEnum to mimic the old behavior)
I'm happy to create a PR implementing this change, if it sounds like a reasonable suggestion.
Actually, that's it: #5138
@macjohnny
Bug Report Checklist
Description
modelNameSuffixoption is provided, generated enum names concatenate this with enumSuffix, resulting in smth likeBaseNameModelSuffixEnum.typescript-angular] A custom optionmodelSuffixis added. When specified, it leads to the same issue with enums (whenstringEnums=false)typescript-angular] ThestringEnums=trueoption removes the default"Enum"suffix, but still keeps the one coming frommodelSuffix.Let's say we have schema with enum:
Here is what is produced with various generator options:
Other TS generators (typescript-fetch, typescript-rxjs) behave similar to typescript-axios.
openapi-generator version
master, stable
OpenAPI declaration file content or url
gist: spec-enum.yml
Related issues/PRs
Suggest a fix
I suggest the following behavior for all TS generators:
ResponseModelPropNameModelEnumwe should getResponseModelPropNameEnummodelSuffixin favor ofmodelNameSuffix, use the standardenumSuffix="Enum"enumSuffixconfigurable via options. This would provide smoother migration for existing users (e.g. one can set it toModelEnumto mimic the old behavior)I'm happy to create a PR implementing this change, if it sounds like a reasonable suggestion.Actually, that's it: #5138
@macjohnny