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

@ -110,6 +110,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// 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);
}];
}
-(NSNumber*) addPetWithCompletionBlock: (SWGPet*) body
@ -171,6 +191,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// 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);
}];
}
-(NSNumber*) findPetsByStatusWithCompletionBlock: (NSArray*) status
@ -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,9 +265,25 @@ 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);
}
}];
}
-(NSNumber*) findPetsByTagsWithCompletionBlock: (NSArray*) tags
@ -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,9 +338,25 @@ 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);
}
}];
}
-(NSNumber*) getPetByIdWithCompletionBlock: (NSNumber*) petId
@ -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];
@ -327,6 +397,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// 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,24 +458,54 @@ 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);
}];
}
-(NSNumber*) deletePetWithCompletionBlock: (NSString*) api_key
@ -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];
@ -443,6 +548,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// 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);
}];
}
-(NSNumber*) uploadFileWithCompletionBlock: (NSNumber*) petId
@ -472,30 +597,43 @@ 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
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"POST"
queryParams: queryParams
@ -512,8 +650,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}];
}

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"
@ -108,6 +108,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}];
}
-(NSNumber*) placeOrderWithCompletionBlock: (SWGOrder*) body
@ -170,6 +173,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// 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];
@ -237,6 +245,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// 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];
@ -303,6 +316,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// 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

@ -109,10 +109,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// primitive response type
// no return base type
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"POST"
queryParams: queryParams
@ -129,8 +129,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}];
}
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock: (NSArray*) body
@ -192,10 +190,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// primitive response type
// no return base type
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"POST"
queryParams: queryParams
@ -212,8 +210,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}];
}
-(NSNumber*) createUsersWithListInputWithCompletionBlock: (NSArray*) body
@ -275,10 +271,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// primitive response type
// no return base type
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"POST"
queryParams: queryParams
@ -295,8 +291,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}];
}
-(NSNumber*) loginUserWithCompletionBlock: (NSString*) username
@ -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];
@ -342,6 +334,11 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// non container response
// primitive response
// primitive response type
return [client stringWithCompletionBlock: requestUrl
method: @"GET"
@ -363,6 +360,11 @@ 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];
@ -402,10 +402,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// primitive response type
// no return base type
// it's void
return [client stringWithCompletionBlock: requestUrl
method: @"GET"
queryParams: queryParams
@ -422,8 +422,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}];
}
-(NSNumber*) getUserByNameWithCompletionBlock: (NSString*) username
@ -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];
@ -466,6 +462,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// 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
@ -554,6 +557,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// 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);
}];
}
-(NSNumber*) deleteUserWithCompletionBlock: (NSString*) username
@ -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];
@ -595,6 +616,26 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// 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);
}];
}