forked from loafle/openapi-generator-original
add enum name mapping support to php generators (#17195)
This commit is contained in:
parent
ac687657ba
commit
e2a8118c86
@ -2,3 +2,5 @@ generatorName: php-nextgen
|
||||
outputDir: samples/client/petstore/php-nextgen/OpenAPIClient-php
|
||||
inputSpec: modules/openapi-generator/src/test/resources/3_0/php-nextgen/petstore-with-fake-endpoints-models-for-testing.yaml
|
||||
templateDir: modules/openapi-generator/src/main/resources/php-nextgen
|
||||
enumNameMappings:
|
||||
delivered: SHIPPED
|
||||
|
@ -742,6 +742,10 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String name, String datatype) {
|
||||
if (enumNameMapping.containsKey(name)) {
|
||||
return enumNameMapping.get(name);
|
||||
}
|
||||
|
||||
if (name.length() == 0) {
|
||||
return "EMPTY";
|
||||
}
|
||||
@ -778,6 +782,10 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
if (enumNameMapping.containsKey(property.name)) {
|
||||
return enumNameMapping.get(property.name);
|
||||
}
|
||||
|
||||
String enumName = underscore(toGenericName(property.name)).toUpperCase(Locale.ROOT);
|
||||
|
||||
// remove [] for array or map of enum
|
||||
|
@ -259,7 +259,7 @@ class Order implements ModelInterface, ArrayAccess, JsonSerializable
|
||||
|
||||
public const STATUS_PLACED = 'placed';
|
||||
public const STATUS_APPROVED = 'approved';
|
||||
public const STATUS_DELIVERED = 'delivered';
|
||||
public const STATUS_SHIPPED = 'delivered';
|
||||
|
||||
/**
|
||||
* Gets allowable values of the enum
|
||||
@ -271,7 +271,7 @@ class Order implements ModelInterface, ArrayAccess, JsonSerializable
|
||||
return [
|
||||
self::STATUS_PLACED,
|
||||
self::STATUS_APPROVED,
|
||||
self::STATUS_DELIVERED,
|
||||
self::STATUS_SHIPPED,
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ enum OuterEnum: string
|
||||
|
||||
case APPROVED = 'approved';
|
||||
|
||||
case DELIVERED = 'delivered';
|
||||
case SHIPPED = 'delivered';
|
||||
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ enum OuterEnumDefaultValue: string
|
||||
|
||||
case APPROVED = 'approved';
|
||||
|
||||
case DELIVERED = 'delivered';
|
||||
case SHIPPED = 'delivered';
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user