Skip to content

Commit

Permalink
Add enum name mapping feature to typescript generators (#18064)
Browse files Browse the repository at this point in the history
* feat: add enum mapping for typescript

* revert unnecessary change
  • Loading branch information
linxin1019 committed Mar 10, 2024
1 parent 0bc979e commit 20bd649
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bin/configs/typescript-angular-v16-provided-in-root.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ templateDir: modules/openapi-generator/src/main/resources/typescript-angular
additionalProperties:
ngVersion: 16.1.2
supportsES6: true
enumNameMappings:
delivered: SHIPPED
Original file line number Diff line number Diff line change
Expand Up @@ -888,6 +888,10 @@ public String toEnumDefaultValue(String value, String datatype) {

@Override
public String toEnumVarName(String name, String datatype) {
if (enumNameMapping.containsKey(name)) {
return enumNameMapping.get(name);
}

if (name.length() == 0) {
return getNameUsingEnumPropertyNaming("empty");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export namespace Order {
export const StatusEnum = {
Placed: 'placed' as StatusEnum,
Approved: 'approved' as StatusEnum,
Delivered: 'delivered' as StatusEnum
SHIPPED: 'delivered' as StatusEnum
};
}

Expand Down

0 comments on commit 20bd649

Please sign in to comment.