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

View File

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

View File

@ -27,4 +27,4 @@ DEPENDENCIES:
SPEC CHECKSUMS: SPEC CHECKSUMS:
AFNetworking: 8bee59492a6ff15d69130efa4d0dc67e0094a52a 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 -(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 -(NSNumber*) findPetsByStatusWithCompletionBlock: (NSArray*) status
@ -199,18 +239,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil; id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
[bodyDictionary addObject:formParams];
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath]; SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// response is in a container
// array container response type // array container response type
return [client dictionary: requestUrl return [client dictionary: requestUrl
method: @"GET" method: @"GET"
@ -225,9 +265,25 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
return; 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 -(NSNumber*) findPetsByTagsWithCompletionBlock: (NSArray*) tags
@ -256,18 +312,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil; id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
[bodyDictionary addObject:formParams];
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath]; SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// response is in a container
// array container response type // array container response type
return [client dictionary: requestUrl return [client dictionary: requestUrl
method: @"GET" method: @"GET"
@ -282,9 +338,25 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
return; 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 -(NSNumber*) getPetByIdWithCompletionBlock: (NSNumber*) petId
@ -312,12 +384,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil; id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary 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 // comples response type
return [client dictionary: requestUrl return [client dictionary: requestUrl
@ -342,16 +418,17 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
return; return;
} }
SWGPet* result = nil;
SWGPet *result = nil;
if (data) { if (data) {
result = [[SWGPet alloc]initWithValues: data]; result = [[SWGPet alloc] initWithValues : data];
} }
completionBlock(result , nil); completionBlock(result , nil);
}]; }];
} }
-(NSNumber*) updatePetWithFormWithCompletionBlock: (NSString*) petId -(NSNumber*) updatePetWithFormWithCompletionBlock: (NSString*) petId
@ -381,24 +458,54 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil; id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
formParams[@"name"] = name; formParams[@"name"] = name;
if(bodyDictionary == nil) {
bodyDictionary = [[NSMutableArray alloc] init];
}
[bodyDictionary addObject:formParams];
formParams[@"status"] = status; formParams[@"status"] = status;
if(bodyDictionary == nil) {
bodyDictionary = [[NSMutableArray alloc] init];
}
[bodyDictionary addObject:formParams]; [bodyDictionary addObject:formParams];
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath]; 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 -(NSNumber*) deletePetWithCompletionBlock: (NSString*) api_key
@ -429,12 +536,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil; id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary 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 -(NSNumber*) uploadFileWithCompletionBlock: (NSNumber*) petId
@ -472,31 +597,44 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil; id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
formParams[@"additionalMetadata"] = additionalMetadata; formParams[@"additionalMetadata"] = additionalMetadata;
if(bodyDictionary == nil) {
bodyDictionary = [[NSMutableArray alloc] init];
}
[bodyDictionary addObject:formParams];
requestContentType = @"multipart/form-data"; requestContentType = @"multipart/form-data";
if(bodyDictionary == nil) {
bodyDictionary = [[NSMutableArray alloc] init];
}
[bodyDictionary addObject:file]; [bodyDictionary addObject:file];
file.paramName = @"file"; file.paramName = @"file";
if(bodyDictionary == nil) {
bodyDictionary = [[NSMutableArray alloc] init];
}
[bodyDictionary addObject:formParams]; [bodyDictionary addObject:formParams];
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath]; 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" method: @"POST"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
@ -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; id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
[bodyDictionary addObject:formParams];
SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath]; SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath];
// response is in a container
// map container response type // map container response type
return [client dictionary: requestUrl return [client dictionary: requestUrl
method: @"GET" method: @"GET"
@ -108,6 +108,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}]; }];
} }
-(NSNumber*) placeOrderWithCompletionBlock: (SWGOrder*) body -(NSNumber*) placeOrderWithCompletionBlock: (SWGOrder*) body
@ -170,6 +173,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// non container response
// complex response
// comples response type // comples response type
return [client dictionary: requestUrl return [client dictionary: requestUrl
@ -185,16 +194,17 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
return; return;
} }
SWGOrder* result = nil;
SWGOrder *result = nil;
if (data) { if (data) {
result = [[SWGOrder alloc]initWithValues: data]; result = [[SWGOrder alloc] initWithValues : data];
} }
completionBlock(result , nil); completionBlock(result , nil);
}]; }];
} }
-(NSNumber*) getOrderByIdWithCompletionBlock: (NSString*) orderId -(NSNumber*) getOrderByIdWithCompletionBlock: (NSString*) orderId
@ -222,12 +232,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil; id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary 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 // comples response type
return [client dictionary: requestUrl return [client dictionary: requestUrl
@ -252,16 +266,17 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
return; return;
} }
SWGOrder* result = nil;
SWGOrder *result = nil;
if (data) { if (data) {
result = [[SWGOrder alloc]initWithValues: data]; result = [[SWGOrder alloc] initWithValues : data];
} }
completionBlock(result , nil); completionBlock(result , nil);
}]; }];
} }
-(NSNumber*) deleteOrderWithCompletionBlock: (NSString*) orderId -(NSNumber*) deleteOrderWithCompletionBlock: (NSString*) orderId
@ -289,12 +304,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil; id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary 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,11 +109,11 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// primitive response type
// no return base type
return [client stringWithCompletionBlock: requestUrl // it's void
return [client stringWithCompletionBlock: requestUrl
method: @"POST" method: @"POST"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
@ -129,8 +129,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}]; }];
} }
-(NSNumber*) createUsersWithArrayInputWithCompletionBlock: (NSArray*) body -(NSNumber*) createUsersWithArrayInputWithCompletionBlock: (NSArray*) body
@ -192,11 +190,11 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// primitive response type
// no return base type
return [client stringWithCompletionBlock: requestUrl // it's void
return [client stringWithCompletionBlock: requestUrl
method: @"POST" method: @"POST"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
@ -212,8 +210,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}]; }];
} }
-(NSNumber*) createUsersWithListInputWithCompletionBlock: (NSArray*) body -(NSNumber*) createUsersWithListInputWithCompletionBlock: (NSArray*) body
@ -275,11 +271,11 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// primitive response type
// no return base type
return [client stringWithCompletionBlock: requestUrl // it's void
return [client stringWithCompletionBlock: requestUrl
method: @"POST" method: @"POST"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
@ -295,8 +291,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}]; }];
} }
-(NSNumber*) loginUserWithCompletionBlock: (NSString*) username -(NSNumber*) loginUserWithCompletionBlock: (NSString*) username
@ -328,12 +322,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil; id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary 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 // primitive response type
return [client stringWithCompletionBlock: requestUrl return [client stringWithCompletionBlock: requestUrl
method: @"GET" method: @"GET"
@ -363,6 +360,11 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// complex response
} }
-(NSNumber*) logoutUserWithCompletionBlock: -(NSNumber*) logoutUserWithCompletionBlock:
@ -388,12 +390,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil; id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
[bodyDictionary addObject:formParams];
@ -402,11 +402,11 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
// primitive response type
// no return base type
return [client stringWithCompletionBlock: requestUrl // it's void
return [client stringWithCompletionBlock: requestUrl
method: @"GET" method: @"GET"
queryParams: queryParams queryParams: queryParams
body: bodyDictionary body: bodyDictionary
@ -422,8 +422,6 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
}]; }];
} }
-(NSNumber*) getUserByNameWithCompletionBlock: (NSString*) username -(NSNumber*) getUserByNameWithCompletionBlock: (NSString*) username
@ -451,12 +449,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil; id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary 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 // comples response type
return [client dictionary: requestUrl return [client dictionary: requestUrl
@ -481,16 +483,17 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
return; return;
} }
SWGUser* result = nil;
SWGUser *result = nil;
if (data) { if (data) {
result = [[SWGUser alloc]initWithValues: data]; result = [[SWGUser alloc] initWithValues : data];
} }
completionBlock(result , nil); completionBlock(result , nil);
}]; }];
} }
-(NSNumber*) updateUserWithCompletionBlock: (NSString*) username -(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 -(NSNumber*) deleteUserWithCompletionBlock: (NSString*) username
@ -581,12 +604,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
id bodyDictionary = nil; id bodyDictionary = nil;
bodyDictionary = [[NSMutableArray alloc] init];
NSMutableDictionary * formParams = [[NSMutableDictionary 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);
}];
} }