forked from loafle/openapi-generator-original
Supoort customize classPrefix in objc client.
This commit is contained in:
parent
e244d20152
commit
9a15ced211
@ -138,6 +138,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
additionalProperties.put("podName", podName);
|
additionalProperties.put("podName", podName);
|
||||||
additionalProperties.put("podVersion", podVersion);
|
additionalProperties.put("podVersion", podVersion);
|
||||||
|
additionalProperties.put("classPrefix", classPrefix);
|
||||||
|
|
||||||
String swaggerFolder = podName;
|
String swaggerFolder = podName;
|
||||||
|
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
#import "SWGApiClient.h"
|
#import "{{classPrefix}}ApiClient.h"
|
||||||
#import "SWGFile.h"
|
|
||||||
#import "SWGQueryParamCollection.h"
|
|
||||||
#import "SWGConfiguration.h"
|
|
||||||
|
|
||||||
@implementation SWGApiClient
|
@implementation {{classPrefix}}ApiClient
|
||||||
|
|
||||||
NSString *const SWGResponseObjectErrorKey = @"SWGResponseObject";
|
NSString *const {{classPrefix}}ResponseObjectErrorKey = @"{{classPrefix}}ResponseObject";
|
||||||
|
|
||||||
static long requestId = 0;
|
static long requestId = 0;
|
||||||
static bool offlineState = false;
|
static bool offlineState = false;
|
||||||
@ -58,7 +55,7 @@ static bool loggingEnabled = true;
|
|||||||
return sharedQueue;
|
return sharedQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
+(SWGApiClient *)sharedClientFromPool:(NSString *)baseUrl {
|
+({{classPrefix}}ApiClient *)sharedClientFromPool:(NSString *)baseUrl {
|
||||||
static NSMutableDictionary *_pool = nil;
|
static NSMutableDictionary *_pool = nil;
|
||||||
if (queuedRequests == nil) {
|
if (queuedRequests == nil) {
|
||||||
queuedRequests = [[NSMutableSet alloc]init];
|
queuedRequests = [[NSMutableSet alloc]init];
|
||||||
@ -72,16 +69,16 @@ static bool loggingEnabled = true;
|
|||||||
_pool = [[NSMutableDictionary alloc] init];
|
_pool = [[NSMutableDictionary alloc] init];
|
||||||
|
|
||||||
// initialize URL cache
|
// initialize URL cache
|
||||||
[SWGApiClient configureCacheWithMemoryAndDiskCapacity:4*1024*1024 diskSize:32*1024*1024];
|
[{{classPrefix}}ApiClient configureCacheWithMemoryAndDiskCapacity:4*1024*1024 diskSize:32*1024*1024];
|
||||||
|
|
||||||
// configure reachability
|
// configure reachability
|
||||||
[SWGApiClient configureCacheReachibilityForHost:baseUrl];
|
[{{classPrefix}}ApiClient configureCacheReachibilityForHost:baseUrl];
|
||||||
}
|
}
|
||||||
|
|
||||||
@synchronized(self) {
|
@synchronized(self) {
|
||||||
SWGApiClient * client = [_pool objectForKey:baseUrl];
|
{{classPrefix}}ApiClient * client = [_pool objectForKey:baseUrl];
|
||||||
if (client == nil) {
|
if (client == nil) {
|
||||||
client = [[SWGApiClient alloc] initWithBaseURL:[NSURL URLWithString:baseUrl]];
|
client = [[{{classPrefix}}ApiClient alloc] initWithBaseURL:[NSURL URLWithString:baseUrl]];
|
||||||
[_pool setValue:client forKey:baseUrl ];
|
[_pool setValue:client forKey:baseUrl ];
|
||||||
if(loggingEnabled)
|
if(loggingEnabled)
|
||||||
NSLog(@"new client for path %@", baseUrl);
|
NSLog(@"new client for path %@", baseUrl);
|
||||||
@ -156,7 +153,7 @@ static bool loggingEnabled = true;
|
|||||||
}
|
}
|
||||||
|
|
||||||
+(NSNumber*) queueRequest {
|
+(NSNumber*) queueRequest {
|
||||||
NSNumber* requestId = [SWGApiClient nextRequestId];
|
NSNumber* requestId = [{{classPrefix}}ApiClient nextRequestId];
|
||||||
if(loggingEnabled)
|
if(loggingEnabled)
|
||||||
NSLog(@"added %@ to request queue", requestId);
|
NSLog(@"added %@ to request queue", requestId);
|
||||||
[queuedRequests addObject:requestId];
|
[queuedRequests addObject:requestId];
|
||||||
@ -221,31 +218,31 @@ static bool loggingEnabled = true;
|
|||||||
}
|
}
|
||||||
|
|
||||||
+(void) configureCacheReachibilityForHost:(NSString*)host {
|
+(void) configureCacheReachibilityForHost:(NSString*)host {
|
||||||
[[SWGApiClient sharedClientFromPool:host].reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
|
[[{{classPrefix}}ApiClient sharedClientFromPool:host].reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
|
||||||
reachabilityStatus = status;
|
reachabilityStatus = status;
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case AFNetworkReachabilityStatusUnknown:
|
case AFNetworkReachabilityStatusUnknown:
|
||||||
if(loggingEnabled)
|
if(loggingEnabled)
|
||||||
NSLog(@"reachability changed to AFNetworkReachabilityStatusUnknown");
|
NSLog(@"reachability changed to AFNetworkReachabilityStatusUnknown");
|
||||||
[SWGApiClient setOfflineState:true];
|
[{{classPrefix}}ApiClient setOfflineState:true];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AFNetworkReachabilityStatusNotReachable:
|
case AFNetworkReachabilityStatusNotReachable:
|
||||||
if(loggingEnabled)
|
if(loggingEnabled)
|
||||||
NSLog(@"reachability changed to AFNetworkReachabilityStatusNotReachable");
|
NSLog(@"reachability changed to AFNetworkReachabilityStatusNotReachable");
|
||||||
[SWGApiClient setOfflineState:true];
|
[{{classPrefix}}ApiClient setOfflineState:true];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AFNetworkReachabilityStatusReachableViaWWAN:
|
case AFNetworkReachabilityStatusReachableViaWWAN:
|
||||||
if(loggingEnabled)
|
if(loggingEnabled)
|
||||||
NSLog(@"reachability changed to AFNetworkReachabilityStatusReachableViaWWAN");
|
NSLog(@"reachability changed to AFNetworkReachabilityStatusReachableViaWWAN");
|
||||||
[SWGApiClient setOfflineState:false];
|
[{{classPrefix}}ApiClient setOfflineState:false];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AFNetworkReachabilityStatusReachableViaWiFi:
|
case AFNetworkReachabilityStatusReachableViaWiFi:
|
||||||
if(loggingEnabled)
|
if(loggingEnabled)
|
||||||
NSLog(@"reachability changed to AFNetworkReachabilityStatusReachableViaWiFi");
|
NSLog(@"reachability changed to AFNetworkReachabilityStatusReachableViaWiFi");
|
||||||
[SWGApiClient setOfflineState:false];
|
[{{classPrefix}}ApiClient setOfflineState:false];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -255,7 +252,7 @@ static bool loggingEnabled = true;
|
|||||||
reachabilityChangeBlock(status);
|
reachabilityChangeBlock(status);
|
||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
[[SWGApiClient sharedClientFromPool:host].reachabilityManager startMonitoring];
|
[[{{classPrefix}}ApiClient sharedClientFromPool:host].reachabilityManager startMonitoring];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(NSString*) pathWithQueryParamsToString:(NSString*) path
|
-(NSString*) pathWithQueryParamsToString:(NSString*) path
|
||||||
@ -272,32 +269,32 @@ static bool loggingEnabled = true;
|
|||||||
id queryParam = [queryParams valueForKey:key];
|
id queryParam = [queryParams valueForKey:key];
|
||||||
if([queryParam isKindOfClass:[NSString class]]){
|
if([queryParam isKindOfClass:[NSString class]]){
|
||||||
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
|
[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]]){
|
else if([queryParam isKindOfClass:[{{classPrefix}}QueryParamCollection class]]){
|
||||||
SWGQueryParamCollection * coll = (SWGQueryParamCollection*) queryParam;
|
{{classPrefix}}QueryParamCollection * coll = ({{classPrefix}}QueryParamCollection*) queryParam;
|
||||||
NSArray* values = [coll values];
|
NSArray* values = [coll values];
|
||||||
NSString* format = [coll format];
|
NSString* format = [coll format];
|
||||||
|
|
||||||
if([format isEqualToString:@"csv"]) {
|
if([format isEqualToString:@"csv"]) {
|
||||||
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
|
[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"]) {
|
else if([format isEqualToString:@"tsv"]) {
|
||||||
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
|
[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"]) {
|
else if([format isEqualToString:@"pipes"]) {
|
||||||
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
|
[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"]) {
|
else if([format isEqualToString:@"multi"]) {
|
||||||
for(id obj in values) {
|
for(id obj in values) {
|
||||||
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
|
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
|
||||||
[SWGApiClient escape:key], [NSString stringWithFormat:@"%@", obj]]];
|
[{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", obj]]];
|
||||||
counter += 1;
|
counter += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,7 +302,7 @@ static bool loggingEnabled = true;
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
|
[requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator,
|
||||||
[SWGApiClient escape:key], [NSString stringWithFormat:@"%@", [queryParams valueForKey:key]]]];
|
[{{classPrefix}}ApiClient escape:key], [NSString stringWithFormat:@"%@", [queryParams valueForKey:key]]]];
|
||||||
}
|
}
|
||||||
|
|
||||||
counter += 1;
|
counter += 1;
|
||||||
@ -333,7 +330,7 @@ static bool loggingEnabled = true;
|
|||||||
NSMutableDictionary *headersWithAuth = [NSMutableDictionary dictionaryWithDictionary:*headers];
|
NSMutableDictionary *headersWithAuth = [NSMutableDictionary dictionaryWithDictionary:*headers];
|
||||||
NSMutableDictionary *querysWithAuth = [NSMutableDictionary dictionaryWithDictionary:*querys];
|
NSMutableDictionary *querysWithAuth = [NSMutableDictionary dictionaryWithDictionary:*querys];
|
||||||
|
|
||||||
SWGConfiguration *config = [SWGConfiguration sharedConfig];
|
{{classPrefix}}Configuration *config = [{{classPrefix}}Configuration sharedConfig];
|
||||||
for (NSString *auth in authSettings) {
|
for (NSString *auth in authSettings) {
|
||||||
NSDictionary *authSetting = [[config authSettings] objectForKey:auth];
|
NSDictionary *authSetting = [[config authSettings] objectForKey:auth];
|
||||||
|
|
||||||
@ -486,7 +483,7 @@ static bool loggingEnabled = true;
|
|||||||
completionBlock: (void (^)(id, NSError *))completionBlock {
|
completionBlock: (void (^)(id, NSError *))completionBlock {
|
||||||
// setting request serializer
|
// setting request serializer
|
||||||
if ([requestContentType isEqualToString:@"application/json"]) {
|
if ([requestContentType isEqualToString:@"application/json"]) {
|
||||||
self.requestSerializer = [SWGJSONRequestSerializer serializer];
|
self.requestSerializer = [{{classPrefix}}JSONRequestSerializer serializer];
|
||||||
}
|
}
|
||||||
else if ([requestContentType isEqualToString:@"application/x-www-form-urlencoded"]) {
|
else if ([requestContentType isEqualToString:@"application/x-www-form-urlencoded"]) {
|
||||||
self.requestSerializer = [AFHTTPRequestSerializer serializer];
|
self.requestSerializer = [AFHTTPRequestSerializer serializer];
|
||||||
@ -500,7 +497,7 @@ static bool loggingEnabled = true;
|
|||||||
|
|
||||||
// setting response serializer
|
// setting response serializer
|
||||||
if ([responseContentType isEqualToString:@"application/json"]) {
|
if ([responseContentType isEqualToString:@"application/json"]) {
|
||||||
self.responseSerializer = [SWGJSONResponseSerializer serializer];
|
self.responseSerializer = [{{classPrefix}}JSONResponseSerializer serializer];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
self.responseSerializer = [AFHTTPResponseSerializer serializer];
|
self.responseSerializer = [AFHTTPResponseSerializer serializer];
|
||||||
@ -511,11 +508,11 @@ static bool loggingEnabled = true;
|
|||||||
|
|
||||||
NSMutableURLRequest * request = nil;
|
NSMutableURLRequest * request = nil;
|
||||||
if (body != nil && [body isKindOfClass:[NSArray class]]){
|
if (body != nil && [body isKindOfClass:[NSArray class]]){
|
||||||
SWGFile * file;
|
{{classPrefix}}File * file;
|
||||||
NSMutableDictionary * params = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary * params = [[NSMutableDictionary alloc] init];
|
||||||
for(id obj in body) {
|
for(id obj in body) {
|
||||||
if([obj isKindOfClass:[SWGFile class]]) {
|
if([obj isKindOfClass:[{{classPrefix}}File class]]) {
|
||||||
file = (SWGFile*) obj;
|
file = ({{classPrefix}}File*) obj;
|
||||||
requestContentType = @"multipart/form-data";
|
requestContentType = @"multipart/form-data";
|
||||||
}
|
}
|
||||||
else if([obj isKindOfClass:[NSDictionary class]]) {
|
else if([obj isKindOfClass:[NSDictionary class]]) {
|
||||||
@ -598,7 +595,7 @@ static bool loggingEnabled = true;
|
|||||||
// Always disable cookies!
|
// Always disable cookies!
|
||||||
[request setHTTPShouldHandleCookies:NO];
|
[request setHTTPShouldHandleCookies:NO];
|
||||||
|
|
||||||
NSNumber* requestId = [SWGApiClient queueRequest];
|
NSNumber* requestId = [{{classPrefix}}ApiClient queueRequest];
|
||||||
AFHTTPRequestOperation *op = [self HTTPRequestOperationWithRequest:request
|
AFHTTPRequestOperation *op = [self HTTPRequestOperationWithRequest:request
|
||||||
success:^(AFHTTPRequestOperation *operation, id response) {
|
success:^(AFHTTPRequestOperation *operation, id response) {
|
||||||
if([self executeRequestWithId:requestId]) {
|
if([self executeRequestWithId:requestId]) {
|
||||||
@ -612,7 +609,7 @@ static bool loggingEnabled = true;
|
|||||||
NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
|
NSMutableDictionary *userInfo = [error.userInfo mutableCopy];
|
||||||
if(operation.responseObject) {
|
if(operation.responseObject) {
|
||||||
// Add in the (parsed) response body.
|
// 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];
|
NSError *augmentedError = [error initWithDomain:error.domain code:error.code userInfo:userInfo];
|
||||||
|
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <ISO8601/ISO8601.h>
|
#import <ISO8601/ISO8601.h>
|
||||||
#import "AFHTTPRequestOperationManager.h"
|
#import <AFNetworking/AFHTTPRequestOperationManager.h>
|
||||||
#import "SWGJSONResponseSerializer.h"
|
#import "{{classPrefix}}JSONResponseSerializer.h"
|
||||||
#import "SWGJSONRequestSerializer.h"
|
#import "{{classPrefix}}JSONRequestSerializer.h"
|
||||||
|
#import "{{classPrefix}}File.h"
|
||||||
|
#import "{{classPrefix}}QueryParamCollection.h"
|
||||||
|
#import "{{classPrefix}}Configuration.h"
|
||||||
|
|
||||||
|
|
||||||
{{#models}}{{#model}}#import "{{classname}}.h"
|
{{#models}}{{#model}}#import "{{classname}}.h"
|
||||||
{{/model}}{{/models}}
|
{{/model}}{{/models}}
|
||||||
@ -12,10 +16,10 @@
|
|||||||
*
|
*
|
||||||
* The corresponding value is the parsed response body for an HTTP error.
|
* 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) NSURLRequestCachePolicy cachePolicy;
|
||||||
@property(nonatomic, assign) NSTimeInterval timeoutInterval;
|
@property(nonatomic, assign) NSTimeInterval timeoutInterval;
|
||||||
@ -31,9 +35,9 @@ extern NSString *const SWGResponseObjectErrorKey;
|
|||||||
*
|
*
|
||||||
* @param baseUrl The base url of api client.
|
* @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
|
* Get the operations queue
|
||||||
@ -122,7 +126,7 @@ extern NSString *const SWGResponseObjectErrorKey;
|
|||||||
/**
|
/**
|
||||||
* Set the client reachability strategy
|
* Set the client reachability strategy
|
||||||
*
|
*
|
||||||
* @param host The host of SWGApiClient.
|
* @param host The host of {{classPrefix}}ApiClient.
|
||||||
*/
|
*/
|
||||||
+(void) configureCacheReachibilityForHost:(NSString*)host;
|
+(void) configureCacheReachibilityForHost:(NSString*)host;
|
||||||
|
|
||||||
|
@ -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 *mutableApiKey;
|
||||||
@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableApiKeyPrefix;
|
@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableApiKeyPrefix;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation SWGConfiguration
|
@implementation {{classPrefix}}Configuration
|
||||||
|
|
||||||
#pragma mark - Singletion Methods
|
#pragma mark - Singletion Methods
|
||||||
|
|
||||||
+ (instancetype) sharedConfig {
|
+ (instancetype) sharedConfig {
|
||||||
static SWGConfiguration *shardConfig = nil;
|
static {{classPrefix}}Configuration *shardConfig = nil;
|
||||||
static dispatch_once_t onceToken;
|
static dispatch_once_t onceToken;
|
||||||
dispatch_once(&onceToken, ^{
|
dispatch_once(&onceToken, ^{
|
||||||
shardConfig = [[self alloc] init];
|
shardConfig = [[self alloc] init];
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
@interface SWGConfiguration : NSObject
|
@interface {{classPrefix}}Configuration : NSObject
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#import "SWGFile.h"
|
#import "{{classPrefix}}File.h"
|
||||||
|
|
||||||
@implementation SWGFile
|
@implementation {{classPrefix}}File
|
||||||
|
|
||||||
@synthesize name = _name;
|
@synthesize name = _name;
|
||||||
@synthesize mimeType = _mimeType;
|
@synthesize mimeType = _mimeType;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
@interface SWGFile : NSObject
|
@interface {{classPrefix}}File : NSObject
|
||||||
|
|
||||||
@property(nonatomic, readonly) NSString* name;
|
@property(nonatomic, readonly) NSString* name;
|
||||||
@property(nonatomic, readonly) NSString* mimeType;
|
@property(nonatomic, readonly) NSString* mimeType;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#import "SWGJSONRequestSerializer.h"
|
#import "{{classPrefix}}JSONRequestSerializer.h"
|
||||||
|
|
||||||
@implementation SWGJSONRequestSerializer
|
@implementation {{classPrefix}}JSONRequestSerializer
|
||||||
|
|
||||||
///
|
///
|
||||||
/// When customize a request serializer,
|
/// When customize a request serializer,
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <AFNetworking/AFURLRequestSerialization.h>
|
#import <AFNetworking/AFURLRequestSerialization.h>
|
||||||
|
|
||||||
@interface SWGJSONRequestSerializer : AFJSONRequestSerializer
|
@interface {{classPrefix}}JSONRequestSerializer : AFJSONRequestSerializer
|
||||||
@end
|
@end
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#import "SWGJSONResponseSerializer.h"
|
#import "{{classPrefix}}JSONResponseSerializer.h"
|
||||||
|
|
||||||
static BOOL JSONParseError(NSError *error) {
|
static BOOL JSONParseError(NSError *error) {
|
||||||
if ([error.domain isEqualToString:NSCocoaErrorDomain] && error.code == 3840) {
|
if ([error.domain isEqualToString:NSCocoaErrorDomain] && error.code == 3840) {
|
||||||
@ -8,7 +8,7 @@ static BOOL JSONParseError(NSError *error) {
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
@implementation SWGJSONResponseSerializer
|
@implementation {{classPrefix}}JSONResponseSerializer
|
||||||
|
|
||||||
///
|
///
|
||||||
/// When customize a response serializer,
|
/// When customize a response serializer,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <AFNetworking/AFURLResponseSerialization.h>
|
#import <AFNetworking/AFURLResponseSerialization.h>
|
||||||
|
|
||||||
@interface SWGJSONResponseSerializer : AFJSONResponseSerializer
|
@interface {{classPrefix}}JSONResponseSerializer : AFJSONResponseSerializer
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#import "SWGObject.h"
|
#import "{{classPrefix}}Object.h"
|
||||||
|
|
||||||
@implementation SWGObject
|
@implementation {{classPrefix}}Object
|
||||||
@end
|
@end
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "JSONModel.h"
|
#import "JSONModel.h"
|
||||||
|
|
||||||
@interface SWGObject : JSONModel
|
@interface {{classPrefix}}Object : JSONModel
|
||||||
@end
|
@end
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#import "SWGQueryParamCollection.h"
|
#import "{{classPrefix}}QueryParamCollection.h"
|
||||||
|
|
||||||
@implementation SWGQueryParamCollection
|
@implementation {{classPrefix}}QueryParamCollection
|
||||||
|
|
||||||
@synthesize values = _values;
|
@synthesize values = _values;
|
||||||
@synthesize format = _format;
|
@synthesize format = _format;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
@interface SWGQueryParamCollection : NSObject
|
@interface {{classPrefix}}QueryParamCollection : NSObject
|
||||||
|
|
||||||
@property(nonatomic, readonly) NSArray* values;
|
@property(nonatomic, readonly) NSArray* values;
|
||||||
@property(nonatomic, readonly) NSString* format;
|
@property(nonatomic, readonly) NSString* format;
|
||||||
|
@ -69,7 +69,7 @@ static NSString * basePath = @"{{basePath}}";
|
|||||||
}
|
}
|
||||||
|
|
||||||
-(unsigned long) requestQueueSize {
|
-(unsigned long) requestQueueSize {
|
||||||
return [SWGApiClient requestQueueSize];
|
return [{{classPrefix}}ApiClient requestQueueSize];
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Api Methods
|
#pragma mark - Api Methods
|
||||||
@ -106,7 +106,7 @@ static NSString * basePath = @"{{basePath}}";
|
|||||||
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init];
|
||||||
{{#queryParams}}if({{paramName}} != nil) {
|
{{#queryParams}}if({{paramName}} != nil) {
|
||||||
{{#collectionFormat}}
|
{{#collectionFormat}}
|
||||||
queryParams[@"{{baseName}}"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: {{baseName}} format: @"{{collectionFormat}}"];
|
queryParams[@"{{baseName}}"] = [[{{classPrefix}}QueryParamCollection alloc] initWithValuesAndFormat: {{baseName}} format: @"{{collectionFormat}}"];
|
||||||
{{/collectionFormat}}
|
{{/collectionFormat}}
|
||||||
{{^collectionFormat}}queryParams[@"{{baseName}}"] = {{paramName}};{{/collectionFormat}}
|
{{^collectionFormat}}queryParams[@"{{baseName}}"] = {{paramName}};{{/collectionFormat}}
|
||||||
}
|
}
|
||||||
@ -118,7 +118,7 @@ static NSString * basePath = @"{{basePath}}";
|
|||||||
{{/headerParams}}
|
{{/headerParams}}
|
||||||
|
|
||||||
// HTTP header `Accept`
|
// 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) {
|
if ([headerParams[@"Accept"] length] == 0) {
|
||||||
[headerParams removeObjectForKey:@"Accept"];
|
[headerParams removeObjectForKey:@"Accept"];
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ static NSString * basePath = @"{{basePath}}";
|
|||||||
}
|
}
|
||||||
|
|
||||||
// request content type
|
// request content type
|
||||||
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[{{#consumes}}@"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}]];
|
NSString *requestContentType = [{{classPrefix}}ApiClient selectHeaderContentType:@[{{#consumes}}@"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}]];
|
||||||
|
|
||||||
// Authentication setting
|
// Authentication setting
|
||||||
NSArray *authSettings = @[{{#authMethods}}@"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}}];
|
NSArray *authSettings = @[{{#authMethods}}@"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}}];
|
||||||
@ -146,7 +146,7 @@ static NSString * basePath = @"{{basePath}}";
|
|||||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
||||||
for (id dict in (NSArray*)bodyParam) {
|
for (id dict in (NSArray*)bodyParam) {
|
||||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
if([dict respondsToSelector:@selector(toDictionary)]) {
|
||||||
[objs addObject:[(SWGObject*)dict toDictionary]];
|
[objs addObject:[({{classPrefix}}Object*)dict toDictionary]];
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
[objs addObject:dict];
|
[objs addObject:dict];
|
||||||
@ -155,7 +155,7 @@ static NSString * basePath = @"{{basePath}}";
|
|||||||
bodyParam = objs;
|
bodyParam = objs;
|
||||||
}
|
}
|
||||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
||||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
bodyParam = [({{classPrefix}}Object*)bodyParam toDictionary];
|
||||||
}
|
}
|
||||||
{{/bodyParam}}
|
{{/bodyParam}}
|
||||||
{{^bodyParam}}
|
{{^bodyParam}}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
{{#imports}}#import "{{import}}.h"
|
{{#imports}}#import "{{import}}.h"
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
#import "SWGObject.h"
|
#import "{{classPrefix}}Object.h"
|
||||||
#import "SWGApiClient.h"
|
#import "{{classPrefix}}ApiClient.h"
|
||||||
{{newline}}
|
{{newline}}
|
||||||
|
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
@interface {{classname}}: NSObject
|
@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;
|
-(void) addHeader:(NSString*)value forKey:(NSString*)key;
|
||||||
-(unsigned long) requestQueueSize;
|
-(unsigned long) requestQueueSize;
|
||||||
+({{classname}}*) apiWithHeader:(NSString*)headerValue key:(NSString*)key;
|
+({{classname}}*) apiWithHeader:(NSString*)headerValue key:(NSString*)key;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "SWGObject.h"
|
#import "{{classPrefix}}Object.h"
|
||||||
{{#imports}}#import "{{import}}.h"
|
{{#imports}}#import "{{import}}.h"
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
{{newline}}
|
{{newline}}
|
||||||
@ -9,7 +9,7 @@
|
|||||||
@protocol {{classname}}
|
@protocol {{classname}}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface {{classname}} : SWGObject
|
@interface {{classname}} : {{classPrefix}}Object
|
||||||
|
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
{{#description}}/* {{{description}}} {{^required}}[optional]{{/required}}
|
{{#description}}/* {{{description}}} {{^required}}[optional]{{/required}}
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
Copyright (c) 2015 geekerzp <geekerzp@gmail.com>
|
|
||||||
|
|
||||||
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.
|
|
@ -1,8 +1,12 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <ISO8601/ISO8601.h>
|
#import <ISO8601/ISO8601.h>
|
||||||
#import "AFHTTPRequestOperationManager.h"
|
#import <AFNetworking/AFHTTPRequestOperationManager.h>
|
||||||
#import "SWGJSONResponseSerializer.h"
|
#import "SWGJSONResponseSerializer.h"
|
||||||
#import "SWGJSONRequestSerializer.h"
|
#import "SWGJSONRequestSerializer.h"
|
||||||
|
#import "SWGFile.h"
|
||||||
|
#import "SWGQueryParamCollection.h"
|
||||||
|
#import "SWGConfiguration.h"
|
||||||
|
|
||||||
|
|
||||||
#import "SWGUser.h"
|
#import "SWGUser.h"
|
||||||
#import "SWGCategory.h"
|
#import "SWGCategory.h"
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
#import "SWGApiClient.h"
|
#import "SWGApiClient.h"
|
||||||
#import "SWGFile.h"
|
|
||||||
#import "SWGQueryParamCollection.h"
|
|
||||||
#import "SWGConfiguration.h"
|
|
||||||
|
|
||||||
@implementation SWGApiClient
|
@implementation SWGApiClient
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "SWGObject.h"
|
#import "SWGObject.h"
|
||||||
#import "SwaggerClient.SWGTag.h"
|
#import "SWGTag.h"
|
||||||
#import "SwaggerClient.SWGCategory.h"
|
#import "SWGCategory.h"
|
||||||
|
|
||||||
|
|
||||||
@protocol SWGPet
|
@protocol SWGPet
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "SwaggerClient.SWGPet.h"
|
#import "SWGPet.h"
|
||||||
#import "SwaggerClient.SWGFile.h"
|
#import "SWGFile.h"
|
||||||
#import "SWGObject.h"
|
#import "SWGObject.h"
|
||||||
#import "SWGApiClient.h"
|
#import "SWGApiClient.h"
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#import "SWGPetApi.h"
|
#import "SWGPetApi.h"
|
||||||
#import "SWGFile.h"
|
#import "SWGFile.h"
|
||||||
#import "SWGQueryParamCollection.h"
|
#import "SWGQueryParamCollection.h"
|
||||||
#import "SwaggerClient.SWGPet.h"
|
#import "SWGPet.h"
|
||||||
#import "SwaggerClient.SWGFile.h"
|
#import "SWGFile.h"
|
||||||
|
|
||||||
|
|
||||||
@interface SWGPetApi ()
|
@interface SWGPetApi ()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "SwaggerClient.SWGOrder.h"
|
#import "SWGOrder.h"
|
||||||
#import "SWGObject.h"
|
#import "SWGObject.h"
|
||||||
#import "SWGApiClient.h"
|
#import "SWGApiClient.h"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#import "SWGStoreApi.h"
|
#import "SWGStoreApi.h"
|
||||||
#import "SWGFile.h"
|
#import "SWGFile.h"
|
||||||
#import "SWGQueryParamCollection.h"
|
#import "SWGQueryParamCollection.h"
|
||||||
#import "SwaggerClient.SWGOrder.h"
|
#import "SWGOrder.h"
|
||||||
|
|
||||||
|
|
||||||
@interface SWGStoreApi ()
|
@interface SWGStoreApi ()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import "SwaggerClient.SWGUser.h"
|
#import "SWGUser.h"
|
||||||
#import "SWGObject.h"
|
#import "SWGObject.h"
|
||||||
#import "SWGApiClient.h"
|
#import "SWGApiClient.h"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#import "SWGUserApi.h"
|
#import "SWGUserApi.h"
|
||||||
#import "SWGFile.h"
|
#import "SWGFile.h"
|
||||||
#import "SWGQueryParamCollection.h"
|
#import "SWGQueryParamCollection.h"
|
||||||
#import "SwaggerClient.SWGUser.h"
|
#import "SWGUser.h"
|
||||||
|
|
||||||
|
|
||||||
@interface SWGUserApi ()
|
@interface SWGUserApi ()
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
/* End PBXContainerItemProxy section */
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
06B47F8BDBE73A9C03BFBEA2 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
|
|
||||||
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 = "<group>"; };
|
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 = "<group>"; };
|
||||||
4CCE21315897B7D544C83242 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
|
4CCE21315897B7D544C83242 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
|
||||||
56767C6E86DE2B2855ABF7B2 /* Pods_SwaggerClient_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_SwaggerClient_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
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 = (
|
children = (
|
||||||
E9675D953C6DCDE71A1BDFD4 /* SwaggerClient.podspec */,
|
E9675D953C6DCDE71A1BDFD4 /* SwaggerClient.podspec */,
|
||||||
4CCE21315897B7D544C83242 /* README.md */,
|
4CCE21315897B7D544C83242 /* README.md */,
|
||||||
06B47F8BDBE73A9C03BFBEA2 /* LICENSE */,
|
|
||||||
);
|
);
|
||||||
name = "Podspec Metadata";
|
name = "Podspec Metadata";
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
<argument>-workspace</argument>
|
<argument>-workspace</argument>
|
||||||
<argument>SwaggerClient.xcworkspace</argument>
|
<argument>SwaggerClient.xcworkspace</argument>
|
||||||
<argument>-scheme</argument>
|
<argument>-scheme</argument>
|
||||||
<argument>SwaggerClient</argument>
|
<argument>SwaggerClient-Example</argument>
|
||||||
<argument>test</argument>
|
<argument>test</argument>
|
||||||
<argument>-destination</argument>
|
<argument>-destination</argument>
|
||||||
<argument>platform=iOS Simulator,name=iPhone 6,OS=8.3</argument>
|
<argument>platform=iOS Simulator,name=iPhone 6,OS=8.3</argument>
|
Loading…
x
Reference in New Issue
Block a user