Skip to content

Commit de0e108

Browse files
committed
added property for app name
1 parent b8cd52a commit de0e108

File tree

1 file changed

+50
-11
lines changed

1 file changed

+50
-11
lines changed

modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/ObjcClientCodegen.java

Lines changed: 50 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,11 @@ public ObjcClientCodegen() {
3434
templateDir = "objc";
3535
modelPackage = "";
3636

37-
additionalProperties.put("projectName", "swaggerClient");
37+
String appName = System.getProperty("appName");
38+
if(appName == null) {
39+
appName = "swaggerClient";
40+
}
41+
additionalProperties.put("projectName", appName);
3842

3943
defaultIncludes = new HashSet<String>(
4044
Arrays.asList(
@@ -44,6 +48,7 @@ public ObjcClientCodegen() {
4448
"NSObject",
4549
"NSArray",
4650
"NSNumber",
51+
"NSDate",
4752
"NSDictionary",
4853
"NSMutableArray",
4954
"NSMutableDictionary")
@@ -52,6 +57,7 @@ public ObjcClientCodegen() {
5257
Arrays.asList(
5358
"NSNumber",
5459
"NSString",
60+
"NSDate",
5561
"NSObject",
5662
"bool")
5763
);
@@ -66,9 +72,8 @@ public ObjcClientCodegen() {
6672

6773
typeMapping = new HashMap<String, String>();
6874
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");
7277
typeMapping.put("boolean", "NSNumber");
7378
typeMapping.put("string", "NSString");
7479
typeMapping.put("integer", "NSNumber");
@@ -83,13 +88,13 @@ public ObjcClientCodegen() {
8388
typeMapping.put("object", "NSObject");
8489

8590
importMapping = new HashMap<String, String> ();
86-
importMapping.put("Date", "SWGDate");
8791

8892
foundationClasses = new HashSet<String> (
8993
Arrays.asList(
9094
"NSNumber",
9195
"NSObject",
9296
"NSString",
97+
"NSDate",
9398
"NSDictionary")
9499
);
95100

@@ -147,11 +152,45 @@ public String getSwaggerType(Property p) {
147152

148153
@Override
149154
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+
}
155194
}
156195

157196
@Override
@@ -229,4 +268,4 @@ public String toVarName(String name) {
229268
public String escapeReservedWord(String name) {
230269
return "_" + name;
231270
}
232-
}
271+
}

0 commit comments

Comments
 (0)