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:
|
additionalProperties:
|
||||||
hideGenerationTimestamp: "true"
|
hideGenerationTimestamp: "true"
|
||||||
projectName: "PetstoreOpenAPI"
|
projectName: "PetstoreOpenAPI"
|
||||||
|
enumNameMappings:
|
||||||
|
delivered: shipped
|
||||||
|
@ -8,3 +8,5 @@ additionalProperties:
|
|||||||
podSummary: PetstoreClient
|
podSummary: PetstoreClient
|
||||||
projectName: PetstoreClient
|
projectName: PetstoreClient
|
||||||
podHomepage: https://github.com/openapitools/openapi-generator
|
podHomepage: https://github.com/openapitools/openapi-generator
|
||||||
|
enumNameMappings:
|
||||||
|
delivered: shipped
|
||||||
|
@ -1027,6 +1027,10 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toEnumVarName(String name, String datatype) {
|
public String toEnumVarName(String name, String datatype) {
|
||||||
|
if (enumNameMapping.containsKey(name)) {
|
||||||
|
return enumNameMapping.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
if (name.length() == 0) {
|
if (name.length() == 0) {
|
||||||
return "empty";
|
return "empty";
|
||||||
}
|
}
|
||||||
@ -1127,6 +1131,10 @@ public class Swift5ClientCodegen extends DefaultCodegen implements CodegenConfig
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toEnumName(CodegenProperty property) {
|
public String toEnumName(CodegenProperty property) {
|
||||||
|
if (enumNameMapping.containsKey(property.name)) {
|
||||||
|
return enumNameMapping.get(property.name);
|
||||||
|
}
|
||||||
|
|
||||||
String enumName = toModelName(property.name);
|
String enumName = toModelName(property.name);
|
||||||
|
|
||||||
// Ensure that the enum type doesn't match a reserved word or
|
// Ensure that the enum type doesn't match a reserved word or
|
||||||
|
@ -575,6 +575,10 @@ public class SwiftCombineClientCodegen extends DefaultCodegen implements Codegen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toEnumVarName(String name, String datatype) {
|
public String toEnumVarName(String name, String datatype) {
|
||||||
|
if (enumNameMapping.containsKey(name)) {
|
||||||
|
return enumNameMapping.get(name);
|
||||||
|
}
|
||||||
|
|
||||||
if (name.length() == 0) {
|
if (name.length() == 0) {
|
||||||
return "empty";
|
return "empty";
|
||||||
}
|
}
|
||||||
@ -630,6 +634,10 @@ public class SwiftCombineClientCodegen extends DefaultCodegen implements Codegen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toEnumName(CodegenProperty property) {
|
public String toEnumName(CodegenProperty property) {
|
||||||
|
if (enumNameMapping.containsKey(property.name)) {
|
||||||
|
return enumNameMapping.get(property.name);
|
||||||
|
}
|
||||||
|
|
||||||
String enumName = toModelName(property.name);
|
String enumName = toModelName(property.name);
|
||||||
|
|
||||||
// Ensure that the enum type doesn't match a reserved word or
|
// 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 {
|
public enum Status: String, Codable, CaseIterable {
|
||||||
case placed = "placed"
|
case placed = "placed"
|
||||||
case approved = "approved"
|
case approved = "approved"
|
||||||
case delivered = "delivered"
|
case shipped = "delivered"
|
||||||
}
|
}
|
||||||
public var id: Int64?
|
public var id: Int64?
|
||||||
public var petId: Int64?
|
public var petId: Int64?
|
||||||
|
@ -15,7 +15,7 @@ public struct Order: Codable, JSONEncodable, Hashable {
|
|||||||
public enum Status: String, Codable, CaseIterable {
|
public enum Status: String, Codable, CaseIterable {
|
||||||
case placed = "placed"
|
case placed = "placed"
|
||||||
case approved = "approved"
|
case approved = "approved"
|
||||||
case delivered = "delivered"
|
case shipped = "delivered"
|
||||||
}
|
}
|
||||||
public var id: Int64?
|
public var id: Int64?
|
||||||
public var petId: Int64?
|
public var petId: Int64?
|
||||||
|
@ -13,5 +13,5 @@ import AnyCodable
|
|||||||
public enum OuterEnum: String, Codable, CaseIterable {
|
public enum OuterEnum: String, Codable, CaseIterable {
|
||||||
case placed = "placed"
|
case placed = "placed"
|
||||||
case approved = "approved"
|
case approved = "approved"
|
||||||
case delivered = "delivered"
|
case shipped = "delivered"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user