forked from loafle/openapi-generator-original
Merge branch 'ehyche-ehyche_update_reserved_words_swift4' into 2.4.0
This commit is contained in:
commit
8348d535ab
@ -139,19 +139,52 @@ public class Swift4Codegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
// name used by swift client
|
// name used by swift client
|
||||||
"ErrorResponse", "Response",
|
"ErrorResponse", "Response",
|
||||||
|
|
||||||
// swift keywords
|
// Added for Objective-C compatibility
|
||||||
"Int", "Int32", "Int64", "Int64", "Float", "Double", "Bool", "Void", "String",
|
"id", "description", "NSArray", "NSURL", "CGFloat", "NSSet", "NSString", "NSInteger", "NSUInteger",
|
||||||
"Character", "AnyObject", "Any", "Error", "URL", "class", "Class", "break",
|
"NSError", "NSDictionary",
|
||||||
"as", "associativity", "deinit", "case", "dynamicType", "convenience", "enum",
|
|
||||||
"continue", "false", "dynamic", "extension", "default", "is", "didSet",
|
//
|
||||||
"func", "do", "nil", "final", "import", "else", "self", "get", "init",
|
// Swift keywords. This list is taken from here:
|
||||||
"fallthrough", "Self", "infix", "internal", "for", "super", "inout", "let",
|
// https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/LexicalStructure.html#//apple_ref/doc/uid/TP40014097-CH30-ID410
|
||||||
"if", "true", "lazy", "operator", "in", "COLUMN", "left", "private", "return",
|
//
|
||||||
"FILE", "mutating", "protocol", "switch", "FUNCTION", "none", "public",
|
// Keywords used in declarations
|
||||||
"where", "LINE", "nonmutating", "static", "while", "optional", "struct",
|
"associatedtype", "class", "deinit", "enum", "extension", "fileprivate", "func", "import", "init",
|
||||||
"override", "subscript", "postfix", "typealias", "precedence", "var",
|
"inout", "internal", "let", "open", "operator", "private", "protocol", "public", "static", "struct",
|
||||||
"prefix", "Protocol", "required", "right", "set", "throw", "Type", "unowned", "weak",
|
"subscript", "typealias", "var",
|
||||||
"Data", "Codable", "Encodable", "Decodable")
|
// Keywords uses in statements
|
||||||
|
"break", "case", "continue", "default", "defer", "do", "else", "fallthrough", "for", "guard", "if",
|
||||||
|
"in", "repeat", "return", "switch", "where", "while",
|
||||||
|
// Keywords used in expressions and types
|
||||||
|
"as", "Any", "catch", "false", "is", "nil", "rethrows", "super", "self", "Self", "throw", "throws", "true", "try",
|
||||||
|
// Keywords used in patterns
|
||||||
|
"_",
|
||||||
|
// Keywords that begin with a number sign
|
||||||
|
"#available", "#colorLiteral", "#column", "#else", "#elseif", "#endif", "#file", "#fileLiteral", "#function", "#if",
|
||||||
|
"#imageLiteral", "#line", "#selector", "#sourceLocation",
|
||||||
|
// Keywords reserved in particular contexts
|
||||||
|
"associativity", "convenience", "dynamic", "didSet", "final", "get", "infix", "indirect", "lazy", "left",
|
||||||
|
"mutating", "none", "nonmutating", "optional", "override", "postfix", "precedence", "prefix", "Protocol",
|
||||||
|
"required", "right", "set", "Type", "unowned", "weak", "willSet",
|
||||||
|
|
||||||
|
//
|
||||||
|
// Swift Standard Library types
|
||||||
|
// https://developer.apple.com/documentation/swift
|
||||||
|
//
|
||||||
|
// Numbers and Basic Values
|
||||||
|
"Bool", "Int", "Double", "Float", "Range", "ClosedRange", "Error", "Optional",
|
||||||
|
// Special-Use Numeric Types
|
||||||
|
"UInt", "UInt8", "UInt16", "UInt32", "UInt64", "Int8", "Int16", "Int32", "Int64", "Float80", "Float32", "Float64",
|
||||||
|
// Strings and Text
|
||||||
|
"String", "Character", "Unicode", "StaticString",
|
||||||
|
// Collections
|
||||||
|
"Array", "Dictionary", "Set", "OptionSet", "CountableRange", "CountableClosedRange",
|
||||||
|
|
||||||
|
// The following are commonly-used Foundation types
|
||||||
|
"URL", "Data", "Codable", "Encodable", "Decodable",
|
||||||
|
|
||||||
|
// The following are other words we want to reserve
|
||||||
|
"Void", "AnyObject", "Class", "dynamicType", "COLUMN", "FILE", "FUNCTION", "LINE"
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
typeMapping = new HashMap<>();
|
typeMapping = new HashMap<>();
|
||||||
|
@ -39,7 +39,7 @@ public class Swift4ModelTest {
|
|||||||
final CodegenProperty property1 = cm.vars.get(0);
|
final CodegenProperty property1 = cm.vars.get(0);
|
||||||
Assert.assertEquals(property1.baseName, "id");
|
Assert.assertEquals(property1.baseName, "id");
|
||||||
Assert.assertEquals(property1.datatype, "Int64");
|
Assert.assertEquals(property1.datatype, "Int64");
|
||||||
Assert.assertEquals(property1.name, "id");
|
Assert.assertEquals(property1.name, "_id");
|
||||||
Assert.assertNull(property1.defaultValue);
|
Assert.assertNull(property1.defaultValue);
|
||||||
Assert.assertEquals(property1.baseType, "Int64");
|
Assert.assertEquals(property1.baseType, "Int64");
|
||||||
Assert.assertTrue(property1.hasMore);
|
Assert.assertTrue(property1.hasMore);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user