rebuilt sample

This commit is contained in:
Tony Tam 2015-03-24 19:56:45 -07:00
parent 30acfc1869
commit 85463f049c
6 changed files with 291 additions and 81 deletions

View File

@ -22,15 +22,15 @@
SWGPetApi * api = [[SWGPetApi alloc] init];
// [api getPetByIdWithCompletionBlock:@10 completionHandler:^(SWGPet *output, NSError *error) {
// NSLog(@"%@", [output asDictionary]);
// [output set_id:@101];
// [api addPetWithCompletionBlock:output completionHandler:^(NSError *error) {
// NSLog(@"Done!");
// }];
[api getPetByIdWithCompletionBlock:@10 completionHandler:^(SWGPet *output, NSError *error) {
NSLog(@"%@", [output asDictionary]);
[output set_id:@101];
[api addPetWithCompletionBlock:output completionHandler:^(NSError *error) {
NSLog(@"Done!");
}];
// load data into file
// }];
// load data into file
}];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test-1" ofType:@"png"];
NSData *myData = [NSData dataWithContentsOfFile:filePath];

View File

@ -1,3 +1,3 @@
platform :ios, '6.0'
xcodeproj 'swaggerClient/swaggerClient.xcodeproj'
xcodeproj 'PetstoreClient/PetstoreClient.xcodeproj'
pod 'AFNetworking', '~> 2.1'

View File

@ -27,4 +27,4 @@ DEPENDENCIES:
SPEC CHECKSUMS:
AFNetworking: 8bee59492a6ff15d69130efa4d0dc67e0094a52a
COCOAPODS: 0.35.0
COCOAPODS: 0.36.0

View File

@ -109,6 +109,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"PUT"
queryParams: queryParams
body: bodyDictionary
headerParams: headerParams
requestContentType: requestContentType
responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) {
if (error) {
completionBlock(error);
return;
}
completionBlock(nil);
}];
}
@ -170,6 +190,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"POST"
queryParams: queryParams
body: bodyDictionary
headerParams: headerParams
requestContentType: requestContentType
responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) {
if (error) {
completionBlock(error);
return;
}
completionBlock(nil);
}];
}
@ -199,18 +239,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
[bodyDictionary addObject:formParams];
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// response is in a container
// array container response type
return [client dictionary: requestUrl
method: @"GET"
@ -225,8 +265,24 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
return;
}
if([data isKindOfClass:[NSArray class]]){
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
for (NSDictionary* dict in (NSArray*)data) {
SWGPet* d = [[SWGPet alloc]initWithValues: dict];
[objs addObject:d];
}
completionBlock(objs, nil);
}
}];
}
@ -256,18 +312,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
[bodyDictionary addObject:formParams];
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// response is in a container
// array container response type
return [client dictionary: requestUrl
method: @"GET"
@ -282,8 +338,24 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
return;
}
if([data isKindOfClass:[NSArray class]]){
NSMutableArray * objs = [[NSMutableArray alloc] initWithCapacity:[data count]];
for (NSDictionary* dict in (NSArray*)data) {
SWGPet* d = [[SWGPet alloc]initWithValues: dict];
[objs addObject:d];
}
completionBlock(objs, nil);
}
}];
}
@ -312,12 +384,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
[bodyDictionary addObject:formParams];
@ -325,8 +395,14 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// non container response
// complex response
// comples response type
return [client dictionary: requestUrl
@ -342,16 +418,17 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
return;
}
SWGPet *result = nil;
SWGPet* result = nil;
if (data) {
result = [[SWGPet alloc]initWithValues: data];
result = [[SWGPet alloc] initWithValues : data];
}
completionBlock(result , nil);
}];
}
-(NSNumber*) updatePetWithFormWithCompletionBlock: (NSString*) petId
@ -381,23 +458,53 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
formParams[@"name"] = name;
if(bodyDictionary == nil) {
bodyDictionary = [[NSMutableArray alloc] init];
}
[bodyDictionary addObject:formParams];
formParams[@"status"] = status;
if(bodyDictionary == nil) {
bodyDictionary = [[NSMutableArray alloc] init];
}
[bodyDictionary addObject:formParams];
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"POST"
queryParams: queryParams
body: bodyDictionary
headerParams: headerParams
requestContentType: requestContentType
responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) {
if (error) {
completionBlock(error);
return;
}
completionBlock(nil);
}];
}
@ -429,12 +536,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
[bodyDictionary addObject:formParams];
@ -442,6 +547,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"DELETE"
queryParams: queryParams
body: bodyDictionary
headerParams: headerParams
requestContentType: requestContentType
responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) {
if (error) {
completionBlock(error);
return;
}
completionBlock(nil);
}];
}
@ -472,31 +597,44 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
formParams[@"additionalMetadata"] = additionalMetadata;
if(bodyDictionary == nil) {
bodyDictionary = [[NSMutableArray alloc] init];
}
[bodyDictionary addObject:formParams];
requestContentType = @"multipart/form-data";
if(bodyDictionary == nil) {
bodyDictionary = [[NSMutableArray alloc] init];
}
[bodyDictionary addObject:file];
file.paramName = @"file";
if(bodyDictionary == nil) {
bodyDictionary = [[NSMutableArray alloc] init];
}
[bodyDictionary addObject:formParams];
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// primitive response type
// no return base type
return [client stringWithCompletionBlock: requestUrl
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"POST"
queryParams: queryParams
body: bodyDictionary
@ -510,9 +648,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}
completionBlock(nil);
}];
}

View File

@ -73,18 +73,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
[bodyDictionary addObject:formParams];
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// response is in a container
// map container response type
return [client dictionary: requestUrl
method: @"GET"
@ -107,6 +107,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}];
}
@ -168,8 +171,14 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// non container response
// complex response
// comples response type
return [client dictionary: requestUrl
@ -185,16 +194,17 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
return;
}
SWGOrder *result = nil;
SWGOrder* result = nil;
if (data) {
result = [[SWGOrder alloc]initWithValues: data];
result = [[SWGOrder alloc] initWithValues : data];
}
completionBlock(result , nil);
}];
}
-(NSNumber*) getOrderByIdWithCompletionBlock: (NSString*) orderId
@ -222,12 +232,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
[bodyDictionary addObject:formParams];
@ -235,8 +243,14 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// non container response
// complex response
// comples response type
return [client dictionary: requestUrl
@ -252,16 +266,17 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
return;
}
SWGOrder *result = nil;
SWGOrder* result = nil;
if (data) {
result = [[SWGOrder alloc]initWithValues: data];
result = [[SWGOrder alloc] initWithValues : data];
}
completionBlock(result , nil);
}];
}
-(NSNumber*) deleteOrderWithCompletionBlock: (NSString*) orderId
@ -289,12 +304,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
[bodyDictionary addObject:formParams];
@ -302,6 +315,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"DELETE"
queryParams: queryParams
body: bodyDictionary
headerParams: headerParams
requestContentType: requestContentType
responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) {
if (error) {
completionBlock(error);
return;
}
completionBlock(nil);
}];
}

View File

@ -108,12 +108,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// primitive response type
// no return base type
return [client stringWithCompletionBlock: requestUrl
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"POST"
queryParams: queryParams
body: bodyDictionary
@ -127,9 +127,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}
completionBlock(nil);
}];
}
@ -191,12 +189,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// primitive response type
// no return base type
return [client stringWithCompletionBlock: requestUrl
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"POST"
queryParams: queryParams
body: bodyDictionary
@ -210,9 +208,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}
completionBlock(nil);
}];
}
@ -274,12 +270,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// primitive response type
// no return base type
return [client stringWithCompletionBlock: requestUrl
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"POST"
queryParams: queryParams
body: bodyDictionary
@ -293,9 +289,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}
completionBlock(nil);
}];
}
@ -328,12 +322,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
[bodyDictionary addObject:formParams];
@ -341,7 +333,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// non container response
// primitive response
// primitive response type
return [client stringWithCompletionBlock: requestUrl
method: @"GET"
@ -361,8 +358,13 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// complex response
}
-(NSNumber*) logoutUserWithCompletionBlock:
@ -388,12 +390,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
[bodyDictionary addObject:formParams];
@ -401,12 +401,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// primitive response type
// no return base type
return [client stringWithCompletionBlock: requestUrl
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"GET"
queryParams: queryParams
body: bodyDictionary
@ -420,9 +420,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}
completionBlock(nil);
}];
}
@ -451,12 +449,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
[bodyDictionary addObject:formParams];
@ -464,8 +460,14 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// non container response
// complex response
// comples response type
return [client dictionary: requestUrl
@ -481,16 +483,17 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
return;
}
SWGUser *result = nil;
SWGUser* result = nil;
if (data) {
result = [[SWGUser alloc]initWithValues: data];
result = [[SWGUser alloc] initWithValues : data];
}
completionBlock(result , nil);
}];
}
-(NSNumber*) updateUserWithCompletionBlock: (NSString*) username
@ -553,6 +556,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"PUT"
queryParams: queryParams
body: bodyDictionary
headerParams: headerParams
requestContentType: requestContentType
responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) {
if (error) {
completionBlock(error);
return;
}
completionBlock(nil);
}];
}
@ -581,12 +604,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
[bodyDictionary addObject:formParams];
@ -594,6 +615,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"DELETE"
queryParams: queryParams
body: bodyDictionary
headerParams: headerParams
requestContentType: requestContentType
responseContentType: responseContentType
completionBlock: ^(NSString *data, NSError *error) {
if (error) {
completionBlock(error);
return;
}
completionBlock(nil);
}];
}