Skip to content

[ObjC] add prefix and suffix support to ObjC models #2267

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public ObjcClientCodegen() {
// local variable names in API methods (endpoints)
"resourcePath", "pathParams", "queryParams", "headerParams",
"responseContentType", "requestContentType", "authSettings",
"formParams", "files", "bodyParam",
"formParams", "localVarFiles", "bodyParam",
// objc reserved words
"auto", "else", "long", "switch",
"break", "enum", "register", "typedef",
Expand Down Expand Up @@ -343,7 +343,15 @@ public String toModelNameWithoutReservedWordCheck(String type) {
}
// custom classes
else {
return classPrefix + camelize(type);
if (!StringUtils.isEmpty(modelNameSuffix)) { // set model suffix
type = type + "_" + modelNameSuffix;
}

if (!StringUtils.isEmpty(modelNamePrefix)) { // set model prefix
type = modelNamePrefix + "_" + type;
}

return classPrefix + camelize(type); // add class prefix
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static {{classname}}* singletonAPI = nil;

id bodyParam = nil;
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];
{{#bodyParam}}
bodyParam = {{paramName}};
{{/bodyParam}}{{^bodyParam}}
Expand All @@ -151,7 +151,7 @@ static {{classname}}* singletonAPI = nil;
formParams[@"{{baseName}}"] = {{paramName}};
}
{{/notFile}}{{#isFile}}
files[@"{{paramName}}"] = {{paramName}};
localVarFiles[@"{{paramName}}"] = {{paramName}};
{{/isFile}}
{{/formParams}}
{{/bodyParam}}
Expand All @@ -168,7 +168,7 @@ static {{classname}}* singletonAPI = nil;
pathParams: pathParams
queryParams: queryParams
formParams: formParams
files: files
files: localVarFiles
body: bodyParam
headerParams: headerParams
authSettings: authSettings
Expand Down
4 changes: 2 additions & 2 deletions samples/client/petstore/objc/SwaggerClient/SWGPetApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@
///
///
/// Finds Pets by status
/// Multiple status values can be provided with comma seperated strings
/// Multiple status values can be provided with comma separated strings
///
/// @param status Status values that need to be considered for filter
/// @param status Status values that need to be considered for query
///
///
/// @return NSArray<SWGPet>*
Expand Down
46 changes: 23 additions & 23 deletions samples/client/petstore/objc/SwaggerClient/SWGPetApi.m
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ -(NSNumber*) updatePetWithBody: (SWGPet*) body

id bodyParam = nil;
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];

bodyParam = body;

Expand All @@ -131,7 +131,7 @@ -(NSNumber*) updatePetWithBody: (SWGPet*) body
pathParams: pathParams
queryParams: queryParams
formParams: formParams
files: files
files: localVarFiles
body: bodyParam
headerParams: headerParams
authSettings: authSettings
Expand Down Expand Up @@ -195,7 +195,7 @@ -(NSNumber*) addPetWithBody: (SWGPet*) body

id bodyParam = nil;
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];

bodyParam = body;

Expand All @@ -206,7 +206,7 @@ -(NSNumber*) addPetWithBody: (SWGPet*) body
pathParams: pathParams
queryParams: queryParams
formParams: formParams
files: files
files: localVarFiles
body: bodyParam
headerParams: headerParams
authSettings: authSettings
Expand All @@ -221,8 +221,8 @@ -(NSNumber*) addPetWithBody: (SWGPet*) body

///
/// Finds Pets by status
/// Multiple status values can be provided with comma seperated strings
/// @param status Status values that need to be considered for filter
/// Multiple status values can be provided with comma separated strings
/// @param status Status values that need to be considered for query
///
/// @returns NSArray<SWGPet>*
///
Expand Down Expand Up @@ -276,7 +276,7 @@ -(NSNumber*) findPetsByStatusWithStatus: (NSArray* /* NSString */) status

id bodyParam = nil;
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];



Expand All @@ -287,7 +287,7 @@ -(NSNumber*) findPetsByStatusWithStatus: (NSArray* /* NSString */) status
pathParams: pathParams
queryParams: queryParams
formParams: formParams
files: files
files: localVarFiles
body: bodyParam
headerParams: headerParams
authSettings: authSettings
Expand Down Expand Up @@ -357,7 +357,7 @@ -(NSNumber*) findPetsByTagsWithTags: (NSArray* /* NSString */) tags

id bodyParam = nil;
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];



Expand All @@ -368,7 +368,7 @@ -(NSNumber*) findPetsByTagsWithTags: (NSArray* /* NSString */) tags
pathParams: pathParams
queryParams: queryParams
formParams: formParams
files: files
files: localVarFiles
body: bodyParam
headerParams: headerParams
authSettings: authSettings
Expand Down Expand Up @@ -440,7 +440,7 @@ -(NSNumber*) getPetByIdWithPetId: (NSNumber*) petId

id bodyParam = nil;
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];



Expand All @@ -451,7 +451,7 @@ -(NSNumber*) getPetByIdWithPetId: (NSNumber*) petId
pathParams: pathParams
queryParams: queryParams
formParams: formParams
files: files
files: localVarFiles
body: bodyParam
headerParams: headerParams
authSettings: authSettings
Expand Down Expand Up @@ -529,7 +529,7 @@ -(NSNumber*) updatePetWithFormWithPetId: (NSString*) petId

id bodyParam = nil;
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];



Expand All @@ -552,7 +552,7 @@ -(NSNumber*) updatePetWithFormWithPetId: (NSString*) petId
pathParams: pathParams
queryParams: queryParams
formParams: formParams
files: files
files: localVarFiles
body: bodyParam
headerParams: headerParams
authSettings: authSettings
Expand Down Expand Up @@ -630,7 +630,7 @@ -(NSNumber*) deletePetWithPetId: (NSNumber*) petId

id bodyParam = nil;
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];



Expand All @@ -641,7 +641,7 @@ -(NSNumber*) deletePetWithPetId: (NSNumber*) petId
pathParams: pathParams
queryParams: queryParams
formParams: formParams
files: files
files: localVarFiles
body: bodyParam
headerParams: headerParams
authSettings: authSettings
Expand Down Expand Up @@ -719,7 +719,7 @@ -(NSNumber*) uploadFileWithPetId: (NSNumber*) petId

id bodyParam = nil;
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];



Expand All @@ -729,7 +729,7 @@ -(NSNumber*) uploadFileWithPetId: (NSNumber*) petId



files[@"file"] = file;
localVarFiles[@"file"] = file;



Expand All @@ -740,7 +740,7 @@ -(NSNumber*) uploadFileWithPetId: (NSNumber*) petId
pathParams: pathParams
queryParams: queryParams
formParams: formParams
files: files
files: localVarFiles
body: bodyParam
headerParams: headerParams
authSettings: authSettings
Expand Down Expand Up @@ -812,7 +812,7 @@ -(NSNumber*) petPetIdtestingByteArraytrueGetWithPetId: (NSNumber*) petId

id bodyParam = nil;
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];



Expand All @@ -823,7 +823,7 @@ -(NSNumber*) petPetIdtestingByteArraytrueGetWithPetId: (NSNumber*) petId
pathParams: pathParams
queryParams: queryParams
formParams: formParams
files: files
files: localVarFiles
body: bodyParam
headerParams: headerParams
authSettings: authSettings
Expand Down Expand Up @@ -887,7 +887,7 @@ -(NSNumber*) addPetUsingByteArrayWithBody: (NSString*) body

id bodyParam = nil;
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
NSMutableDictionary *localVarFiles = [[NSMutableDictionary alloc] init];

bodyParam = body;

Expand All @@ -898,7 +898,7 @@ -(NSNumber*) addPetUsingByteArrayWithBody: (NSString*) body
pathParams: pathParams
queryParams: queryParams
formParams: formParams
files: files
files: localVarFiles
body: bodyParam
headerParams: headerParams
authSettings: authSettings
Expand Down
13 changes: 13 additions & 0 deletions samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@
-(unsigned long) requestQueueSize;
+(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key;
+(SWGStoreApi*) sharedAPI;
///
///
/// Finds orders by status
/// A single status value can be provided as a string
///
/// @param status Status value that needs to be considered for query
///
///
/// @return NSArray<SWGOrder>*
-(NSNumber*) findOrdersByStatusWithStatus: (NSString*) status
completionHandler: (void (^)(NSArray<SWGOrder>* output, NSError* error)) handler;


///
///
/// Returns pet inventories by status
Expand Down
Loading