@@ -34,7 +34,11 @@ public ObjcClientCodegen() {
34
34
templateDir = "objc" ;
35
35
modelPackage = "" ;
36
36
37
- additionalProperties .put ("projectName" , "swaggerClient" );
37
+ String appName = System .getProperty ("appName" );
38
+ if (appName == null ) {
39
+ appName = "swaggerClient" ;
40
+ }
41
+ additionalProperties .put ("projectName" , appName );
38
42
39
43
defaultIncludes = new HashSet <String >(
40
44
Arrays .asList (
@@ -44,6 +48,7 @@ public ObjcClientCodegen() {
44
48
"NSObject" ,
45
49
"NSArray" ,
46
50
"NSNumber" ,
51
+ "NSDate" ,
47
52
"NSDictionary" ,
48
53
"NSMutableArray" ,
49
54
"NSMutableDictionary" )
@@ -52,6 +57,7 @@ public ObjcClientCodegen() {
52
57
Arrays .asList (
53
58
"NSNumber" ,
54
59
"NSString" ,
60
+ "NSDate" ,
55
61
"NSObject" ,
56
62
"bool" )
57
63
);
@@ -66,9 +72,8 @@ public ObjcClientCodegen() {
66
72
67
73
typeMapping = new HashMap <String , String >();
68
74
typeMapping .put ("enum" , "NSString" );
69
- typeMapping .put ("Date" , "SWGDate" );
70
- typeMapping .put ("DateTime" , "SWGDate" );
71
- // typeMapping.put("Date", "SWGDate");
75
+ typeMapping .put ("Date" , "NSDate" );
76
+ typeMapping .put ("DateTime" , "NSDate" );
72
77
typeMapping .put ("boolean" , "NSNumber" );
73
78
typeMapping .put ("string" , "NSString" );
74
79
typeMapping .put ("integer" , "NSNumber" );
@@ -83,13 +88,13 @@ public ObjcClientCodegen() {
83
88
typeMapping .put ("object" , "NSObject" );
84
89
85
90
importMapping = new HashMap <String , String > ();
86
- importMapping .put ("Date" , "SWGDate" );
87
91
88
92
foundationClasses = new HashSet <String > (
89
93
Arrays .asList (
90
94
"NSNumber" ,
91
95
"NSObject" ,
92
96
"NSString" ,
97
+ "NSDate" ,
93
98
"NSDictionary" )
94
99
);
95
100
@@ -147,11 +152,45 @@ public String getSwaggerType(Property p) {
147
152
148
153
@ Override
149
154
public String getTypeDeclaration (Property p ) {
150
- String swaggerType = getSwaggerType (p );
151
- if (languageSpecificPrimitives .contains (swaggerType ) && !foundationClasses .contains (swaggerType ))
152
- return toModelName (swaggerType );
153
- else
154
- return swaggerType + "*" ;
155
+ if (p instanceof ArrayProperty ) {
156
+ ArrayProperty ap = (ArrayProperty ) p ;
157
+ Property inner = ap .getItems ();
158
+ String innerType = getSwaggerType (inner );
159
+
160
+ // In this codition, type of property p is array of primitive,
161
+ // return container type with pointer, e.g. `NSArray*'
162
+ if (languageSpecificPrimitives .contains (innerType ))
163
+ return getSwaggerType (p ) + "*" ;
164
+
165
+ // In this codition, type of property p is array of model,
166
+ // return container type combine inner type with pointer, e.g. `NSArray<SWGTag>*'
167
+ String innerTypeDeclaration = getTypeDeclaration (inner );
168
+
169
+ if (innerTypeDeclaration .endsWith ("*" ))
170
+ innerTypeDeclaration = innerTypeDeclaration .substring (0 , innerTypeDeclaration .length () - 1 );
171
+
172
+ return getSwaggerType (p ) + "<" + innerTypeDeclaration + ">*" ;
173
+ }
174
+ else {
175
+ String swaggerType = getSwaggerType (p );
176
+
177
+ // In this codition, type of p is objective-c primitive type, e.g. `NSSNumber',
178
+ // return type of p with pointer, e.g. `NSNumber*'
179
+ if (languageSpecificPrimitives .contains (swaggerType ) &&
180
+ foundationClasses .contains (swaggerType )) {
181
+ return swaggerType + "*" ;
182
+ }
183
+ // In this codition, type of p is c primitive type, e.g. `bool',
184
+ // return type of p, e.g. `bool'
185
+ else if (languageSpecificPrimitives .contains (swaggerType )) {
186
+ return swaggerType ;
187
+ }
188
+ // In this codition, type of p is objective-c object type, e.g. `SWGPet',
189
+ // return type of p with pointer, e.g. `'
190
+ else {
191
+ return swaggerType + "*" ;
192
+ }
193
+ }
155
194
}
156
195
157
196
@ Override
@@ -229,4 +268,4 @@ public String toVarName(String name) {
229
268
public String escapeReservedWord (String name ) {
230
269
return "_" + name ;
231
270
}
232
- }
271
+ }
0 commit comments