forked from loafle/openapi-generator-original
add enum name mapping option to swift generators (#17297)
This commit is contained in:
parent
bbd0ce38be
commit
cdb020d044
@ -5,3 +5,5 @@ templateDir: modules/openapi-generator/src/main/resources/swift-combine
|
||||
additionalProperties:
|
||||
hideGenerationTimestamp: "true"
|
||||
projectName: "PetstoreOpenAPI"
|
||||
enumNameMappings:
|
||||
delivered: shipped
|
||||
|
@ -8,3 +8,5 @@ additionalProperties:
|
||||
podSummary: PetstoreClient
|
||||
projectName: PetstoreClient
|
||||
podHomepage: https://github.com/openapitools/openapi-generator
|
||||
enumNameMappings:
|
||||
delivered: shipped
|
||||
|
@ -1027,6 +1027,10 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String name, String datatype) {
|
||||
if (enumNameMapping.containsKey(name)) {
|
||||
return enumNameMapping.get(name);
|
||||
}
|
||||
|
||||
if (name.length() == 0) {
|
||||
return "empty";
|
||||
}
|
||||
@ -1127,6 +1131,10 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
if (enumNameMapping.containsKey(property.name)) {
|
||||
return enumNameMapping.get(property.name);
|
||||
}
|
||||
|
||||
String enumName = toModelName(property.name);
|
||||
|
||||
// Ensure that the enum type doesn't match a reserved word or
|
||||
|
@ -575,6 +575,10 @@ public class SwiftCombineClientCodegen extends DefaultCodegen implements Codegen
|
||||
|
||||
@Override
|
||||
public String toEnumVarName(String name, String datatype) {
|
||||
if (enumNameMapping.containsKey(name)) {
|
||||
return enumNameMapping.get(name);
|
||||
}
|
||||
|
||||
if (name.length() == 0) {
|
||||
return "empty";
|
||||
}
|
||||
@ -630,6 +634,10 @@ public class SwiftCombineClientCodegen extends DefaultCodegen implements Codegen
|
||||
|
||||
@Override
|
||||
public String toEnumName(CodegenProperty property) {
|
||||
if (enumNameMapping.containsKey(property.name)) {
|
||||
return enumNameMapping.get(property.name);
|
||||
}
|
||||
|
||||
String enumName = toModelName(property.name);
|
||||
|
||||
// Ensure that the enum type doesn't match a reserved word or
|
||||
|
@ -12,7 +12,7 @@ public struct Order: Codable {
|
||||
public enum Status: String, Codable, CaseIterable {
|
||||
case placed = "placed"
|
||||
case approved = "approved"
|
||||
case delivered = "delivered"
|
||||
case shipped = "delivered"
|
||||
}
|
||||
public var id: Int64?
|
||||
public var petId: Int64?
|
||||
|
@ -15,7 +15,7 @@ public struct Order: Codable, JSONEncodable, Hashable {
|
||||
public enum Status: String, Codable, CaseIterable {
|
||||
case placed = "placed"
|
||||
case approved = "approved"
|
||||
case delivered = "delivered"
|
||||
case shipped = "delivered"
|
||||
}
|
||||
public var id: Int64?
|
||||
public var petId: Int64?
|
||||
|
@ -13,5 +13,5 @@ import AnyCodable
|
||||
public enum OuterEnum: String, Codable, CaseIterable {
|
||||
case placed = "placed"
|
||||
case approved = "approved"
|
||||
case delivered = "delivered"
|
||||
case shipped = "delivered"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user