mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 06:30:52 +00:00
added property for app name
This commit is contained in:
parent
b8cd52aa07
commit
de0e108d27
@ -34,7 +34,11 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
templateDir = "objc";
|
templateDir = "objc";
|
||||||
modelPackage = "";
|
modelPackage = "";
|
||||||
|
|
||||||
additionalProperties.put("projectName", "swaggerClient");
|
String appName = System.getProperty("appName");
|
||||||
|
if(appName == null) {
|
||||||
|
appName = "swaggerClient";
|
||||||
|
}
|
||||||
|
additionalProperties.put("projectName", appName);
|
||||||
|
|
||||||
defaultIncludes = new HashSet<String>(
|
defaultIncludes = new HashSet<String>(
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
@ -44,6 +48,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
"NSObject",
|
"NSObject",
|
||||||
"NSArray",
|
"NSArray",
|
||||||
"NSNumber",
|
"NSNumber",
|
||||||
|
"NSDate",
|
||||||
"NSDictionary",
|
"NSDictionary",
|
||||||
"NSMutableArray",
|
"NSMutableArray",
|
||||||
"NSMutableDictionary")
|
"NSMutableDictionary")
|
||||||
@ -52,6 +57,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"NSNumber",
|
"NSNumber",
|
||||||
"NSString",
|
"NSString",
|
||||||
|
"NSDate",
|
||||||
"NSObject",
|
"NSObject",
|
||||||
"bool")
|
"bool")
|
||||||
);
|
);
|
||||||
@ -66,9 +72,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
typeMapping = new HashMap<String, String>();
|
typeMapping = new HashMap<String, String>();
|
||||||
typeMapping.put("enum", "NSString");
|
typeMapping.put("enum", "NSString");
|
||||||
typeMapping.put("Date", "SWGDate");
|
typeMapping.put("Date", "NSDate");
|
||||||
typeMapping.put("DateTime", "SWGDate");
|
typeMapping.put("DateTime", "NSDate");
|
||||||
// typeMapping.put("Date", "SWGDate");
|
|
||||||
typeMapping.put("boolean", "NSNumber");
|
typeMapping.put("boolean", "NSNumber");
|
||||||
typeMapping.put("string", "NSString");
|
typeMapping.put("string", "NSString");
|
||||||
typeMapping.put("integer", "NSNumber");
|
typeMapping.put("integer", "NSNumber");
|
||||||
@ -83,13 +88,13 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
typeMapping.put("object", "NSObject");
|
typeMapping.put("object", "NSObject");
|
||||||
|
|
||||||
importMapping = new HashMap<String, String> ();
|
importMapping = new HashMap<String, String> ();
|
||||||
importMapping.put("Date", "SWGDate");
|
|
||||||
|
|
||||||
foundationClasses = new HashSet<String> (
|
foundationClasses = new HashSet<String> (
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"NSNumber",
|
"NSNumber",
|
||||||
"NSObject",
|
"NSObject",
|
||||||
"NSString",
|
"NSString",
|
||||||
|
"NSDate",
|
||||||
"NSDictionary")
|
"NSDictionary")
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -147,12 +152,46 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTypeDeclaration(Property p) {
|
public String getTypeDeclaration(Property p) {
|
||||||
|
if (p instanceof ArrayProperty) {
|
||||||
|
ArrayProperty ap = (ArrayProperty) p;
|
||||||
|
Property inner = ap.getItems();
|
||||||
|
String innerType = getSwaggerType(inner);
|
||||||
|
|
||||||
|
// In this codition, type of property p is array of primitive,
|
||||||
|
// return container type with pointer, e.g. `NSArray*'
|
||||||
|
if (languageSpecificPrimitives.contains(innerType))
|
||||||
|
return getSwaggerType(p) + "*";
|
||||||
|
|
||||||
|
// In this codition, type of property p is array of model,
|
||||||
|
// return container type combine inner type with pointer, e.g. `NSArray<SWGTag>*'
|
||||||
|
String innerTypeDeclaration = getTypeDeclaration(inner);
|
||||||
|
|
||||||
|
if (innerTypeDeclaration.endsWith("*"))
|
||||||
|
innerTypeDeclaration = innerTypeDeclaration.substring(0, innerTypeDeclaration.length() - 1);
|
||||||
|
|
||||||
|
return getSwaggerType(p) + "<" + innerTypeDeclaration + ">*";
|
||||||
|
}
|
||||||
|
else {
|
||||||
String swaggerType = getSwaggerType(p);
|
String swaggerType = getSwaggerType(p);
|
||||||
if(languageSpecificPrimitives.contains(swaggerType) && !foundationClasses.contains(swaggerType))
|
|
||||||
return toModelName(swaggerType);
|
// In this codition, type of p is objective-c primitive type, e.g. `NSSNumber',
|
||||||
else
|
// return type of p with pointer, e.g. `NSNumber*'
|
||||||
|
if (languageSpecificPrimitives.contains(swaggerType) &&
|
||||||
|
foundationClasses.contains(swaggerType)) {
|
||||||
return swaggerType + "*";
|
return swaggerType + "*";
|
||||||
}
|
}
|
||||||
|
// In this codition, type of p is c primitive type, e.g. `bool',
|
||||||
|
// return type of p, e.g. `bool'
|
||||||
|
else if (languageSpecificPrimitives.contains(swaggerType)) {
|
||||||
|
return swaggerType;
|
||||||
|
}
|
||||||
|
// In this codition, type of p is objective-c object type, e.g. `SWGPet',
|
||||||
|
// return type of p with pointer, e.g. `'
|
||||||
|
else {
|
||||||
|
return swaggerType + "*";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toModelName(String type) {
|
public String toModelName(String type) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user