From 9a15ced211eaefdc5cb848188f12a6cdd84f811e Mon Sep 17 00:00:00 2001 From: geekerzp Date: Sat, 27 Jun 2015 16:10:28 +0800 Subject: [PATCH] Supoort customize classPrefix in objc client. --- .../codegen/languages/ObjcClientCodegen.java | 1 + .../resources/objc/ApiClient-body.mustache | 65 +++++++++---------- .../resources/objc/ApiClient-header.mustache | 20 +++--- .../objc/Configuration-body.mustache | 8 +-- .../objc/Configuration-header.mustache | 2 +- .../main/resources/objc/File-body.mustache | 6 +- .../main/resources/objc/File-header.mustache | 4 +- .../objc/JSONRequestSerializer-body.mustache | 4 +- .../JSONRequestSerializer-header.mustache | 2 +- .../objc/JSONResponseSerializer-body.mustache | 4 +- .../JSONResponseSerializer-header.mustache | 2 +- .../main/resources/objc/Object-body.mustache | 4 +- .../resources/objc/Object-header.mustache | 2 +- .../objc/QueryParamCollection-body.mustache | 4 +- .../objc/QueryParamCollection-header.mustache | 2 +- .../src/main/resources/objc/api-body.mustache | 12 ++-- .../main/resources/objc/api-header.mustache | 8 +-- .../main/resources/objc/model-header.mustache | 4 +- samples/client/petstore/objc/LICENSE | 19 ------ .../objc/SwaggerClient/SWGApiClient.h | 8 ++- .../objc/SwaggerClient/SWGApiClient.m | 3 - .../petstore/objc/SwaggerClient/SWGFile.h | 2 +- .../petstore/objc/SwaggerClient/SWGFile.m | 2 +- .../petstore/objc/SwaggerClient/SWGPet.h | 4 +- .../petstore/objc/SwaggerClient/SWGPetApi.h | 4 +- .../petstore/objc/SwaggerClient/SWGPetApi.m | 4 +- .../petstore/objc/SwaggerClient/SWGStoreApi.h | 2 +- .../petstore/objc/SwaggerClient/SWGStoreApi.m | 2 +- .../petstore/objc/SwaggerClient/SWGUserApi.h | 2 +- .../petstore/objc/SwaggerClient/SWGUserApi.m | 2 +- .../SwaggerClient.xcodeproj/project.pbxproj | 2 - .../objc/{ => SwaggerClientTests}/pom.xml | 2 +- 32 files changed, 97 insertions(+), 115 deletions(-) delete mode 100644 samples/client/petstore/objc/LICENSE rename samples/client/petstore/objc/{ => SwaggerClientTests}/pom.xml (97%) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java index 6859ba56ea6..287957d1924 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java @@ -138,6 +138,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { additionalProperties.put("podName", podName); additionalProperties.put("podVersion", podVersion); + additionalProperties.put("classPrefix", classPrefix); String swaggerFolder = podName; diff --git a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache index d7e6fac8385..13c0c84ac58 100644 --- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-body.mustache @@ -1,11 +1,8 @@ -#import "SWGApiClient.h" -#import "SWGFile.h" -#import "SWGQueryParamCollection.h" -#import "SWGConfiguration.h" +#import "{{classPrefix}}ApiClient.h" -@implementation SWGApiClient +@implementation {{classPrefix}}ApiClient -NSString *const SWGResponseObjectErrorKey = @"SWGResponseObject"; +NSString *const {{classPrefix}}ResponseObjectErrorKey = @"{{classPrefix}}ResponseObject"; static long requestId = 0; static bool offlineState = false; @@ -58,7 +55,7 @@ static bool loggingEnabled = true; return sharedQueue; } -+(SWGApiClient *)sharedClientFromPool:(NSString *)baseUrl { ++({{classPrefix}}ApiClient *)sharedClientFromPool:(NSString *)baseUrl { static NSMutableDictionary *_pool = nil; if (queuedRequests == nil) { queuedRequests = [[NSMutableSet alloc]init]; @@ -72,16 +69,16 @@ static bool loggingEnabled = true; _pool = [[NSMutableDictionary alloc] init]; // initialize URL cache - [SWGApiClient configureCacheWithMemoryAndDiskCapacity:4*1024*1024 diskSize:32*1024*1024]; + [{{classPrefix}}ApiClient configureCacheWithMemoryAndDiskCapacity:4*1024*1024 diskSize:32*1024*1024]; // configure reachability - [SWGApiClient configureCacheReachibilityForHost:baseUrl]; + [{{classPrefix}}ApiClient configureCacheReachibilityForHost:baseUrl]; } @synchronized(self) { - SWGApiClient * client = [_pool objectForKey:baseUrl]; + {{classPrefix}}ApiClient * client = [_pool objectForKey:baseUrl]; if (client == nil) { - client = [[SWGApiClient alloc] initWithBaseURL:[NSURL URLWithString:baseUrl]]; + client = [[{{classPrefix}}ApiClient alloc] initWithBaseURL:[NSURL URLWithString:baseUrl]]; [_pool setValue:client forKey:baseUrl ]; if(loggingEnabled) NSLog(@"new client for path %@", baseUrl); @@ -156,7 +153,7 @@ static bool loggingEnabled = true; } +(NSNumber*) queueRequest { - NSNumber* requestId = [SWGApiClient nextRequestId]; + NSNumber* requestId = [{{classPrefix}}ApiClient nextRequestId]; if(loggingEnabled) NSLog(@"added %@ to request queue", requestId); [queuedRequests addObject:requestId]; @@ -221,31 +218,31 @@ static bool loggingEnabled = true; } +(void) configureCacheReachibilityForHost:(NSString*)host { - [[SWGApiClient sharedClientFromPool:host].reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { + [[{{classPrefix}}ApiClient sharedClientFromPool:host].reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) { reachabilityStatus = status; switch (status) { case AFNetworkReachabilityStatusUnknown: if(loggingEnabled) NSLog(@"reachability changed to AFNetworkReachabilityStatusUnknown"); - [SWGApiClient setOfflineState:true]; + [{{classPrefix}}ApiClient setOfflineState:true]; break; case AFNetworkReachabilityStatusNotReachable: if(loggingEnabled) NSLog(@"reachability changed to AFNetworkReachabilityStatusNotReachable"); - [SWGApiClient setOfflineState:true]; + [{{classPrefix}}ApiClient setOfflineState:true]; break; case AFNetworkReachabilityStatusReachableViaWWAN: if(loggingEnabled) NSLog(@"reachability changed to AFNetworkReachabilityStatusReachableViaWWAN"); - [SWGApiClient setOfflineState:false]; + [{{classPrefix}}ApiClient setOfflineState:false]; break; case AFNetworkReachabilityStatusReachableViaWiFi: if(loggingEnabled) NSLog(@"reachability changed to AFNetworkReachabilityStatusReachableViaWiFi"); - [SWGApiClient setOfflineState:false]; + [{{classPrefix}}ApiClient setOfflineState:false]; break; default: break; @@ -255,7 +252,7 @@ static bool loggingEnabled = true; reachabilityChangeBlock(status); } }]; - [[SWGApiClient sharedClientFromPool:host].reachabilityManager startMonitoring]; + [[{{classPrefix}}ApiClient sharedClientFromPool:host].reachabilityManager startMonitoring]; } -(NSString*) pathWithQueryParamsToString:(NSString*) path @@ -272,32 +269,32 @@ static bool loggingEnabled = true; id queryParam = [queryParams valueForKey:key]; if([queryParam isKindOfClass:[NSString class]]){ [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, - [SWGApiClient escape:key], [SWGApiClient escape:[queryParams valueForKey:key]]]]; + [{{classPrefix}}ApiClient escape:key], [{{classPrefix}}ApiClient escape:[queryParams valueForKey:key]]]]; } - else if([queryParam isKindOfClass:[SWGQueryParamCollection class]]){ - SWGQueryParamCollection * coll = (SWGQueryParamCollection*) queryParam; + else if([queryParam isKindOfClass:[{{classPrefix}}QueryParamCollection class]]){ + {{classPrefix}}QueryParamCollection * coll = ({{classPrefix}}QueryParamCollection*) queryParam; NSArray* values = [coll values]; NSString* format = [coll format]; if([format isEqualToString:@"csv"]) { [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, - [SWGApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@","]]]]; + [{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@","]]]]; } else if([format isEqualToString:@"tsv"]) { [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, - [SWGApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@"\t"]]]]; + [{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@"\t"]]]]; } else if([format isEqualToString:@"pipes"]) { [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, - [SWGApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@"|"]]]]; + [{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", [values componentsJoinedByString:@"|"]]]]; } else if([format isEqualToString:@"multi"]) { for(id obj in values) { [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, - [SWGApiClient escape:key], [NSString stringWithFormat:@"%@", obj]]]; + [{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", obj]]]; counter += 1; } @@ -305,7 +302,7 @@ static bool loggingEnabled = true; } else { [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, - [SWGApiClient escape:key], [NSString stringWithFormat:@"%@", [queryParams valueForKey:key]]]]; + [{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", [queryParams valueForKey:key]]]]; } counter += 1; @@ -333,7 +330,7 @@ static bool loggingEnabled = true; NSMutableDictionary *headersWithAuth = [NSMutableDictionary dictionaryWithDictionary:*headers]; NSMutableDictionary *querysWithAuth = [NSMutableDictionary dictionaryWithDictionary:*querys]; - SWGConfiguration *config = [SWGConfiguration sharedConfig]; + {{classPrefix}}Configuration *config = [{{classPrefix}}Configuration sharedConfig]; for (NSString *auth in authSettings) { NSDictionary *authSetting = [[config authSettings] objectForKey:auth]; @@ -486,7 +483,7 @@ static bool loggingEnabled = true; completionBlock: (void (^)(id, NSError *))completionBlock { // setting request serializer if ([requestContentType isEqualToString:@"application/json"]) { - self.requestSerializer = [SWGJSONRequestSerializer serializer]; + self.requestSerializer = [{{classPrefix}}JSONRequestSerializer serializer]; } else if ([requestContentType isEqualToString:@"application/x-www-form-urlencoded"]) { self.requestSerializer = [AFHTTPRequestSerializer serializer]; @@ -500,7 +497,7 @@ static bool loggingEnabled = true; // setting response serializer if ([responseContentType isEqualToString:@"application/json"]) { - self.responseSerializer = [SWGJSONResponseSerializer serializer]; + self.responseSerializer = [{{classPrefix}}JSONResponseSerializer serializer]; } else { self.responseSerializer = [AFHTTPResponseSerializer serializer]; @@ -511,11 +508,11 @@ static bool loggingEnabled = true; NSMutableURLRequest * request = nil; if (body != nil && [body isKindOfClass:[NSArray class]]){ - SWGFile * file; + {{classPrefix}}File * file; NSMutableDictionary * params = [[NSMutableDictionary alloc] init]; for(id obj in body) { - if([obj isKindOfClass:[SWGFile class]]) { - file = (SWGFile*) obj; + if([obj isKindOfClass:[{{classPrefix}}File class]]) { + file = ({{classPrefix}}File*) obj; requestContentType = @"multipart/form-data"; } else if([obj isKindOfClass:[NSDictionary class]]) { @@ -598,7 +595,7 @@ static bool loggingEnabled = true; // Always disable cookies! [request setHTTPShouldHandleCookies:NO]; - NSNumber* requestId = [SWGApiClient queueRequest]; + NSNumber* requestId = [{{classPrefix}}ApiClient queueRequest]; AFHTTPRequestOperation *op = [self HTTPRequestOperationWithRequest:request success:^(AFHTTPRequestOperation *operation, id response) { if([self executeRequestWithId:requestId]) { @@ -612,7 +609,7 @@ static bool loggingEnabled = true; NSMutableDictionary *userInfo = [error.userInfo mutableCopy]; if(operation.responseObject) { // Add in the (parsed) response body. - userInfo[SWGResponseObjectErrorKey] = operation.responseObject; + userInfo[{{classPrefix}}ResponseObjectErrorKey] = operation.responseObject; } NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo]; diff --git a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache index d4bc3e3b81d..68647a9175b 100644 --- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache @@ -1,8 +1,12 @@ #import #import -#import "AFHTTPRequestOperationManager.h" -#import "SWGJSONResponseSerializer.h" -#import "SWGJSONRequestSerializer.h" +#import +#import "{{classPrefix}}JSONResponseSerializer.h" +#import "{{classPrefix}}JSONRequestSerializer.h" +#import "{{classPrefix}}File.h" +#import "{{classPrefix}}QueryParamCollection.h" +#import "{{classPrefix}}Configuration.h" + {{#models}}{{#model}}#import "{{classname}}.h" {{/model}}{{/models}} @@ -12,10 +16,10 @@ * * The corresponding value is the parsed response body for an HTTP error. */ -extern NSString *const SWGResponseObjectErrorKey; +extern NSString *const {{classPrefix}}ResponseObjectErrorKey; -@interface SWGApiClient : AFHTTPRequestOperationManager +@interface {{classPrefix}}ApiClient : AFHTTPRequestOperationManager @property(nonatomic, assign) NSURLRequestCachePolicy cachePolicy; @property(nonatomic, assign) NSTimeInterval timeoutInterval; @@ -31,9 +35,9 @@ extern NSString *const SWGResponseObjectErrorKey; * * @param baseUrl The base url of api client. * - * @return The SWGApiClient instance. + * @return The {{classPrefix}}ApiClient instance. */ -+(SWGApiClient *)sharedClientFromPool:(NSString *)baseUrl; ++({{classPrefix}}ApiClient *)sharedClientFromPool:(NSString *)baseUrl; /** * Get the operations queue @@ -122,7 +126,7 @@ extern NSString *const SWGResponseObjectErrorKey; /** * Set the client reachability strategy * - * @param host The host of SWGApiClient. + * @param host The host of {{classPrefix}}ApiClient. */ +(void) configureCacheReachibilityForHost:(NSString*)host; diff --git a/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache b/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache index 1e5e7135574..b410c45371f 100644 --- a/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache @@ -1,18 +1,18 @@ -#import "SWGConfiguration.h" +#import "{{classPrefix}}Configuration.h" -@interface SWGConfiguration () +@interface {{classPrefix}}Configuration () @property (readwrite, nonatomic, strong) NSMutableDictionary *mutableApiKey; @property (readwrite, nonatomic, strong) NSMutableDictionary *mutableApiKeyPrefix; @end -@implementation SWGConfiguration +@implementation {{classPrefix}}Configuration #pragma mark - Singletion Methods + (instancetype) sharedConfig { - static SWGConfiguration *shardConfig = nil; + static {{classPrefix}}Configuration *shardConfig = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ shardConfig = [[self alloc] init]; diff --git a/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache b/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache index 33023ca3c6f..03af5bf76a7 100644 --- a/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache @@ -1,6 +1,6 @@ #import -@interface SWGConfiguration : NSObject +@interface {{classPrefix}}Configuration : NSObject /** diff --git a/modules/swagger-codegen/src/main/resources/objc/File-body.mustache b/modules/swagger-codegen/src/main/resources/objc/File-body.mustache index 42552767af4..83a382ec6bc 100644 --- a/modules/swagger-codegen/src/main/resources/objc/File-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/File-body.mustache @@ -1,6 +1,6 @@ -#import "SWGFile.h" +#import "{{classPrefix}}File.h" -@implementation SWGFile +@implementation {{classPrefix}}File @synthesize name = _name; @synthesize mimeType = _mimeType; @@ -23,4 +23,4 @@ return self; } -@end \ No newline at end of file +@end diff --git a/modules/swagger-codegen/src/main/resources/objc/File-header.mustache b/modules/swagger-codegen/src/main/resources/objc/File-header.mustache index fd87e13bace..3395ba6d796 100644 --- a/modules/swagger-codegen/src/main/resources/objc/File-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/File-header.mustache @@ -1,6 +1,6 @@ #import -@interface SWGFile : NSObject +@interface {{classPrefix}}File : NSObject @property(nonatomic, readonly) NSString* name; @property(nonatomic, readonly) NSString* mimeType; @@ -11,4 +11,4 @@ mimeType: (NSString*) mimeType data: (NSData*) data; -@end \ No newline at end of file +@end diff --git a/modules/swagger-codegen/src/main/resources/objc/JSONRequestSerializer-body.mustache b/modules/swagger-codegen/src/main/resources/objc/JSONRequestSerializer-body.mustache index 631a20a5a6e..78b1409b6b9 100644 --- a/modules/swagger-codegen/src/main/resources/objc/JSONRequestSerializer-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/JSONRequestSerializer-body.mustache @@ -1,6 +1,6 @@ -#import "SWGJSONRequestSerializer.h" +#import "{{classPrefix}}JSONRequestSerializer.h" -@implementation SWGJSONRequestSerializer +@implementation {{classPrefix}}JSONRequestSerializer /// /// When customize a request serializer, diff --git a/modules/swagger-codegen/src/main/resources/objc/JSONRequestSerializer-header.mustache b/modules/swagger-codegen/src/main/resources/objc/JSONRequestSerializer-header.mustache index 49dd7fca3e2..a0732b93706 100644 --- a/modules/swagger-codegen/src/main/resources/objc/JSONRequestSerializer-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/JSONRequestSerializer-header.mustache @@ -1,5 +1,5 @@ #import #import -@interface SWGJSONRequestSerializer : AFJSONRequestSerializer +@interface {{classPrefix}}JSONRequestSerializer : AFJSONRequestSerializer @end diff --git a/modules/swagger-codegen/src/main/resources/objc/JSONResponseSerializer-body.mustache b/modules/swagger-codegen/src/main/resources/objc/JSONResponseSerializer-body.mustache index a2dd21bcf5d..3a19dd1ca4e 100644 --- a/modules/swagger-codegen/src/main/resources/objc/JSONResponseSerializer-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/JSONResponseSerializer-body.mustache @@ -1,4 +1,4 @@ -#import "SWGJSONResponseSerializer.h" +#import "{{classPrefix}}JSONResponseSerializer.h" static BOOL JSONParseError(NSError *error) { if ([error.domain isEqualToString:NSCocoaErrorDomain] && error.code == 3840) { @@ -8,7 +8,7 @@ static BOOL JSONParseError(NSError *error) { return NO; } -@implementation SWGJSONResponseSerializer +@implementation {{classPrefix}}JSONResponseSerializer /// /// When customize a response serializer, diff --git a/modules/swagger-codegen/src/main/resources/objc/JSONResponseSerializer-header.mustache b/modules/swagger-codegen/src/main/resources/objc/JSONResponseSerializer-header.mustache index 16cda122217..7a5f152e271 100644 --- a/modules/swagger-codegen/src/main/resources/objc/JSONResponseSerializer-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/JSONResponseSerializer-header.mustache @@ -1,6 +1,6 @@ #import #import -@interface SWGJSONResponseSerializer : AFJSONResponseSerializer +@interface {{classPrefix}}JSONResponseSerializer : AFJSONResponseSerializer @end diff --git a/modules/swagger-codegen/src/main/resources/objc/Object-body.mustache b/modules/swagger-codegen/src/main/resources/objc/Object-body.mustache index 1f897ab1d56..122484f1ad4 100644 --- a/modules/swagger-codegen/src/main/resources/objc/Object-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/Object-body.mustache @@ -1,4 +1,4 @@ -#import "SWGObject.h" +#import "{{classPrefix}}Object.h" -@implementation SWGObject +@implementation {{classPrefix}}Object @end diff --git a/modules/swagger-codegen/src/main/resources/objc/Object-header.mustache b/modules/swagger-codegen/src/main/resources/objc/Object-header.mustache index ccec208abc0..f73d1bab9b0 100644 --- a/modules/swagger-codegen/src/main/resources/objc/Object-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/Object-header.mustache @@ -1,5 +1,5 @@ #import #import "JSONModel.h" -@interface SWGObject : JSONModel +@interface {{classPrefix}}Object : JSONModel @end diff --git a/modules/swagger-codegen/src/main/resources/objc/QueryParamCollection-body.mustache b/modules/swagger-codegen/src/main/resources/objc/QueryParamCollection-body.mustache index 83303045185..23d0c8eaa86 100644 --- a/modules/swagger-codegen/src/main/resources/objc/QueryParamCollection-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/QueryParamCollection-body.mustache @@ -1,6 +1,6 @@ -#import "SWGQueryParamCollection.h" +#import "{{classPrefix}}QueryParamCollection.h" -@implementation SWGQueryParamCollection +@implementation {{classPrefix}}QueryParamCollection @synthesize values = _values; @synthesize format = _format; diff --git a/modules/swagger-codegen/src/main/resources/objc/QueryParamCollection-header.mustache b/modules/swagger-codegen/src/main/resources/objc/QueryParamCollection-header.mustache index 3b771881b0f..0389cce98be 100644 --- a/modules/swagger-codegen/src/main/resources/objc/QueryParamCollection-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/QueryParamCollection-header.mustache @@ -1,6 +1,6 @@ #import -@interface SWGQueryParamCollection : NSObject +@interface {{classPrefix}}QueryParamCollection : NSObject @property(nonatomic, readonly) NSArray* values; @property(nonatomic, readonly) NSString* format; diff --git a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache index 473f3684243..1b9d09985ff 100644 --- a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache @@ -69,7 +69,7 @@ static NSString * basePath = @"{{basePath}}"; } -(unsigned long) requestQueueSize { - return [SWGApiClient requestQueueSize]; + return [{{classPrefix}}ApiClient requestQueueSize]; } #pragma mark - Api Methods @@ -106,7 +106,7 @@ static NSString * basePath = @"{{basePath}}"; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; {{#queryParams}}if({{paramName}} != nil) { {{#collectionFormat}} - queryParams[@"{{baseName}}"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: {{baseName}} format: @"{{collectionFormat}}"]; + queryParams[@"{{baseName}}"] = [[{{classPrefix}}QueryParamCollection alloc] initWithValuesAndFormat: {{baseName}} format: @"{{collectionFormat}}"]; {{/collectionFormat}} {{^collectionFormat}}queryParams[@"{{baseName}}"] = {{paramName}};{{/collectionFormat}} } @@ -118,7 +118,7 @@ static NSString * basePath = @"{{basePath}}"; {{/headerParams}} // HTTP header `Accept` - headerParams[@"Accept"] = [SWGApiClient selectHeaderAccept:@[{{#produces}}@"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}]]; + headerParams[@"Accept"] = [{{classPrefix}}ApiClient selectHeaderAccept:@[{{#produces}}@"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}]]; if ([headerParams[@"Accept"] length] == 0) { [headerParams removeObjectForKey:@"Accept"]; } @@ -133,7 +133,7 @@ static NSString * basePath = @"{{basePath}}"; } // request content type - NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[{{#consumes}}@"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}]]; + NSString *requestContentType = [{{classPrefix}}ApiClient selectHeaderContentType:@[{{#consumes}}@"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}]]; // Authentication setting NSArray *authSettings = @[{{#authMethods}}@"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}}]; @@ -146,7 +146,7 @@ static NSString * basePath = @"{{basePath}}"; NSMutableArray *objs = [[NSMutableArray alloc] init]; for (id dict in (NSArray*)bodyParam) { if([dict respondsToSelector:@selector(toDictionary)]) { - [objs addObject:[(SWGObject*)dict toDictionary]]; + [objs addObject:[({{classPrefix}}Object*)dict toDictionary]]; } else{ [objs addObject:dict]; @@ -155,7 +155,7 @@ static NSString * basePath = @"{{basePath}}"; bodyParam = objs; } else if([bodyParam respondsToSelector:@selector(toDictionary)]) { - bodyParam = [(SWGObject*)bodyParam toDictionary]; + bodyParam = [({{classPrefix}}Object*)bodyParam toDictionary]; } {{/bodyParam}} {{^bodyParam}} diff --git a/modules/swagger-codegen/src/main/resources/objc/api-header.mustache b/modules/swagger-codegen/src/main/resources/objc/api-header.mustache index 7f14262d116..263c213dd6f 100644 --- a/modules/swagger-codegen/src/main/resources/objc/api-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/api-header.mustache @@ -1,16 +1,16 @@ #import {{#imports}}#import "{{import}}.h" {{/imports}} -#import "SWGObject.h" -#import "SWGApiClient.h" +#import "{{classPrefix}}Object.h" +#import "{{classPrefix}}ApiClient.h" {{newline}} {{#operations}} @interface {{classname}}: NSObject -@property(nonatomic, assign)SWGApiClient *apiClient; +@property(nonatomic, assign){{classPrefix}}ApiClient *apiClient; --(instancetype) initWithApiClient:(SWGApiClient *)apiClient; +-(instancetype) initWithApiClient:({{classPrefix}}ApiClient *)apiClient; -(void) addHeader:(NSString*)value forKey:(NSString*)key; -(unsigned long) requestQueueSize; +({{classname}}*) apiWithHeader:(NSString*)headerValue key:(NSString*)key; diff --git a/modules/swagger-codegen/src/main/resources/objc/model-header.mustache b/modules/swagger-codegen/src/main/resources/objc/model-header.mustache index 81ac19a0b73..4afaec31a24 100644 --- a/modules/swagger-codegen/src/main/resources/objc/model-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/model-header.mustache @@ -1,5 +1,5 @@ #import -#import "SWGObject.h" +#import "{{classPrefix}}Object.h" {{#imports}}#import "{{import}}.h" {{/imports}} {{newline}} @@ -9,7 +9,7 @@ @protocol {{classname}} @end -@interface {{classname}} : SWGObject +@interface {{classname}} : {{classPrefix}}Object {{#vars}} {{#description}}/* {{{description}}} {{^required}}[optional]{{/required}} diff --git a/samples/client/petstore/objc/LICENSE b/samples/client/petstore/objc/LICENSE deleted file mode 100644 index 0a7c3babc79..00000000000 --- a/samples/client/petstore/objc/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015 geekerzp - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h index 34722ed3ad9..e3f70231b2b 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h @@ -1,8 +1,12 @@ #import #import -#import "AFHTTPRequestOperationManager.h" +#import #import "SWGJSONResponseSerializer.h" -#import "SWGJSONRequestSerializer.h" +#import "SWGJSONRequestSerializer.h" +#import "SWGFile.h" +#import "SWGQueryParamCollection.h" +#import "SWGConfiguration.h" + #import "SWGUser.h" #import "SWGCategory.h" diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m index d7e6fac8385..2206b95ed1a 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m @@ -1,7 +1,4 @@ #import "SWGApiClient.h" -#import "SWGFile.h" -#import "SWGQueryParamCollection.h" -#import "SWGConfiguration.h" @implementation SWGApiClient diff --git a/samples/client/petstore/objc/SwaggerClient/SWGFile.h b/samples/client/petstore/objc/SwaggerClient/SWGFile.h index fd87e13bace..f96fb1fab8a 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGFile.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGFile.h @@ -11,4 +11,4 @@ mimeType: (NSString*) mimeType data: (NSData*) data; -@end \ No newline at end of file +@end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGFile.m b/samples/client/petstore/objc/SwaggerClient/SWGFile.m index 42552767af4..9a1304c2696 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGFile.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGFile.m @@ -23,4 +23,4 @@ return self; } -@end \ No newline at end of file +@end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPet.h b/samples/client/petstore/objc/SwaggerClient/SWGPet.h index 9b8a274d20b..edd54e9f31a 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPet.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGPet.h @@ -1,7 +1,7 @@ #import #import "SWGObject.h" -#import "SwaggerClient.SWGTag.h" -#import "SwaggerClient.SWGCategory.h" +#import "SWGTag.h" +#import "SWGCategory.h" @protocol SWGPet diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h index ef8e4d1f271..257a7d1453e 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h @@ -1,6 +1,6 @@ #import -#import "SwaggerClient.SWGPet.h" -#import "SwaggerClient.SWGFile.h" +#import "SWGPet.h" +#import "SWGFile.h" #import "SWGObject.h" #import "SWGApiClient.h" diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m index 88fda7755b0..01d127bc283 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m @@ -1,8 +1,8 @@ #import "SWGPetApi.h" #import "SWGFile.h" #import "SWGQueryParamCollection.h" -#import "SwaggerClient.SWGPet.h" -#import "SwaggerClient.SWGFile.h" +#import "SWGPet.h" +#import "SWGFile.h" @interface SWGPetApi () diff --git a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h index d155f275d1e..7488c1baa70 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h @@ -1,5 +1,5 @@ #import -#import "SwaggerClient.SWGOrder.h" +#import "SWGOrder.h" #import "SWGObject.h" #import "SWGApiClient.h" diff --git a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m index 8248b043431..71b5af87744 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m @@ -1,7 +1,7 @@ #import "SWGStoreApi.h" #import "SWGFile.h" #import "SWGQueryParamCollection.h" -#import "SwaggerClient.SWGOrder.h" +#import "SWGOrder.h" @interface SWGStoreApi () diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h index 481ce8c9c4d..6fda87cca70 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h @@ -1,5 +1,5 @@ #import -#import "SwaggerClient.SWGUser.h" +#import "SWGUser.h" #import "SWGObject.h" #import "SWGApiClient.h" diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m index 52f3fed4133..06b6d2ce666 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.m @@ -1,7 +1,7 @@ #import "SWGUserApi.h" #import "SWGFile.h" #import "SWGQueryParamCollection.h" -#import "SwaggerClient.SWGUser.h" +#import "SWGUser.h" @interface SWGUserApi () diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj index 5e768ade5c6..160ab6c70a8 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj +++ b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj @@ -40,7 +40,6 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ - 06B47F8BDBE73A9C03BFBEA2 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; 1A81C3BE3E54961CD827EAE3 /* Pods-SwaggerClient_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwaggerClient_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-SwaggerClient_Tests/Pods-SwaggerClient_Tests.release.xcconfig"; sourceTree = ""; }; 4CCE21315897B7D544C83242 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 56767C6E86DE2B2855ABF7B2 /* Pods_SwaggerClient_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwaggerClient_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -189,7 +188,6 @@ children = ( E9675D953C6DCDE71A1BDFD4 /* SwaggerClient.podspec */, 4CCE21315897B7D544C83242 /* README.md */, - 06B47F8BDBE73A9C03BFBEA2 /* LICENSE */, ); name = "Podspec Metadata"; sourceTree = ""; diff --git a/samples/client/petstore/objc/pom.xml b/samples/client/petstore/objc/SwaggerClientTests/pom.xml similarity index 97% rename from samples/client/petstore/objc/pom.xml rename to samples/client/petstore/objc/SwaggerClientTests/pom.xml index 85fc5ff6139..d1f461da7fd 100644 --- a/samples/client/petstore/objc/pom.xml +++ b/samples/client/petstore/objc/SwaggerClientTests/pom.xml @@ -51,7 +51,7 @@ -workspace SwaggerClient.xcworkspace -scheme - SwaggerClient + SwaggerClient-Example test -destination platform=iOS Simulator,name=iPhone 6,OS=8.3