diff --git a/samples/client/petstore/objc/ObjcPetstoreCodegen.scala b/samples/client/petstore/objc/ObjcPetstoreCodegen.scala index 1451bd45b2d3..43b82ff25683 100644 --- a/samples/client/petstore/objc/ObjcPetstoreCodegen.scala +++ b/samples/client/petstore/objc/ObjcPetstoreCodegen.scala @@ -1,3 +1,19 @@ +/** + * Copyright 2012 Wordnik, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + import com.wordnik.swagger.codegen.BasicObjcGenerator import com.wordnik.swagger.core._ @@ -8,6 +24,9 @@ object ObjcPetstoreCodegen extends BasicObjcGenerator { // where to write generated code override def destinationDir = "samples/client/petstore/objc/client" + // to avoid recompiling ... + override def templateDir = "src/main/resources/objc" + // supporting classes override def supportingFiles = List( diff --git a/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.pbxproj b/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.pbxproj index 0e9c949b7145..acf6e2dbb90b 100644 --- a/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.pbxproj +++ b/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.pbxproj @@ -45,6 +45,7 @@ EA07F54816135916006A2112 /* NIKUser.m in Sources */ = {isa = PBXBuildFile; fileRef = EA07F51F1613569A006A2112 /* NIKUser.m */; }; EA07F54916135916006A2112 /* NIKUserApi.h in Sources */ = {isa = PBXBuildFile; fileRef = EA07F5201613569A006A2112 /* NIKUserApi.h */; }; EA07F54A16135916006A2112 /* NIKUserApi.m in Sources */ = {isa = PBXBuildFile; fileRef = EA07F5211613569A006A2112 /* NIKUserApi.m */; }; + EA5A034416141443003B3E41 /* UserApiTest.m in Sources */ = {isa = PBXBuildFile; fileRef = EA5A034316141443003B3E41 /* UserApiTest.m */; }; EAE96DE616138695004AB97C /* PetApiTest.m in Sources */ = {isa = PBXBuildFile; fileRef = EA81837816137FD500341A6E /* PetApiTest.m */; }; EAE96DE716138695004AB97C /* PetApiTest.h in Sources */ = {isa = PBXBuildFile; fileRef = EA81837916137FD500341A6E /* PetApiTest.h */; }; /* End PBXBuildFile section */ @@ -103,6 +104,8 @@ EA07F5211613569A006A2112 /* NIKUserApi.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = NIKUserApi.m; path = ../client/NIKUserApi.m; sourceTree = ""; }; EA07F5301613580E006A2112 /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; EA07F53216135819006A2112 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; }; + EA5A034216141443003B3E41 /* UserApiTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UserApiTest.h; path = ../tests/UserApiTest.h; sourceTree = ""; }; + EA5A034316141443003B3E41 /* UserApiTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = UserApiTest.m; path = ../tests/UserApiTest.m; sourceTree = ""; }; EA81837816137FD500341A6E /* PetApiTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = PetApiTest.m; path = ../tests/PetApiTest.m; sourceTree = ""; }; EA81837916137FD500341A6E /* PetApiTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PetApiTest.h; path = ../tests/PetApiTest.h; sourceTree = ""; }; /* End PBXFileReference section */ @@ -218,6 +221,8 @@ children = ( EA81837816137FD500341A6E /* PetApiTest.m */, EA81837916137FD500341A6E /* PetApiTest.h */, + EA5A034216141443003B3E41 /* UserApiTest.h */, + EA5A034316141443003B3E41 /* UserApiTest.m */, ); name = Tests; sourceTree = ""; @@ -362,6 +367,7 @@ EA07F54816135916006A2112 /* NIKUser.m in Sources */, EA07F54916135916006A2112 /* NIKUserApi.h in Sources */, EA07F54A16135916006A2112 /* NIKUserApi.m in Sources */, + EA5A034416141443003B3E41 /* UserApiTest.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.xcworkspace/xcuserdata/tony.xcuserdatad/UserInterfaceState.xcuserstate b/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.xcworkspace/xcuserdata/tony.xcuserdatad/UserInterfaceState.xcuserstate index 358e03d05df4..1aa7adcf1d71 100644 Binary files a/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.xcworkspace/xcuserdata/tony.xcuserdatad/UserInterfaceState.xcuserstate and b/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.xcworkspace/xcuserdata/tony.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist b/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist index b9ac11fb120f..aba405e3f0a5 100644 --- a/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist +++ b/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/xcuserdata/tony.xcuserdatad/xcdebugger/Breakpoints.xcbkptlist @@ -237,5 +237,18 @@ landmarkName = "-testGetPetByTags" landmarkType = "5"> + + diff --git a/samples/client/petstore/objc/client/NIKCategory.h b/samples/client/petstore/objc/client/NIKCategory.h index 7c66bd1aced0..376287775182 100644 --- a/samples/client/petstore/objc/client/NIKCategory.h +++ b/samples/client/petstore/objc/client/NIKCategory.h @@ -3,12 +3,10 @@ @interface NIKCategory : NIKSwaggerObject { @private - NSDictionary* raw; NSNumber* __id; //NSNumber NSString* _name; //NSString } -@property(nonatomic) NSDictionary* raw; @property(nonatomic) NSNumber* _id; @@ -18,7 +16,6 @@ - (id) initWithValues: (NSDictionary*)dict; - (NSDictionary*) asDictionary; -- (NSDictionary*) asRaw; @end diff --git a/samples/client/petstore/objc/client/NIKCategory.m b/samples/client/petstore/objc/client/NIKCategory.m index b0ca3f239a95..52c7990391ae 100644 --- a/samples/client/petstore/objc/client/NIKCategory.m +++ b/samples/client/petstore/objc/client/NIKCategory.m @@ -3,8 +3,6 @@ @implementation NIKCategory -@synthesize raw = _raw; - @synthesize _id = __id; @synthesize name = _name; - (id) _id: (NSNumber*) _id @@ -17,9 +15,10 @@ - (id) initWithValues: (NSDictionary*)dict { + /* isContainer: , baseType: NSNumber, complexType: */ __id = [dict objectForKey:@"id"]; + /* isContainer: , baseType: NSString, complexType: */ _name = [dict objectForKey:@"name"]; - self.raw = [[NSDictionary alloc] initWithDictionary:dict]; return self; } @@ -31,8 +30,5 @@ return output; } --(NSDictionary*) asRaw { - return _raw; -} @end diff --git a/samples/client/petstore/objc/client/NIKOrder.h b/samples/client/petstore/objc/client/NIKOrder.h index d3f9d23fcce0..085dcb9c083d 100644 --- a/samples/client/petstore/objc/client/NIKOrder.h +++ b/samples/client/petstore/objc/client/NIKOrder.h @@ -4,7 +4,6 @@ @interface NIKOrder : NIKSwaggerObject { @private - NSDictionary* raw; NSNumber* __id; //NSNumber NSNumber* _petId; //NSNumber NSString* _status; //NSString @@ -12,7 +11,6 @@ NIKDate* _shipDate; //NIKDate } -@property(nonatomic) NSDictionary* raw; @property(nonatomic) NSNumber* _id; @@ -28,7 +26,6 @@ - (id) initWithValues: (NSDictionary*)dict; - (NSDictionary*) asDictionary; -- (NSDictionary*) asRaw; @end diff --git a/samples/client/petstore/objc/client/NIKOrder.m b/samples/client/petstore/objc/client/NIKOrder.m index be0ff590c50b..8024915e3b79 100644 --- a/samples/client/petstore/objc/client/NIKOrder.m +++ b/samples/client/petstore/objc/client/NIKOrder.m @@ -3,8 +3,6 @@ @implementation NIKOrder -@synthesize raw = _raw; - @synthesize _id = __id; @synthesize petId = _petId; @synthesize status = _status; @@ -26,13 +24,17 @@ - (id) initWithValues: (NSDictionary*)dict { + /* isContainer: , baseType: NSNumber, complexType: */ __id = [dict objectForKey:@"id"]; + /* isContainer: , baseType: NSNumber, complexType: */ _petId = [dict objectForKey:@"petId"]; + /* isContainer: , baseType: NSString, complexType: */ _status = [dict objectForKey:@"status"]; + /* isContainer: , baseType: NSNumber, complexType: */ _quantity = [dict objectForKey:@"quantity"]; + /* isContainer: , baseType: NIKDate, complexType: NIKDate */ id shipDate_dict = [dict objectForKey:@"shipDate"]; _shipDate = [[NIKDate alloc]initWithValues:shipDate_dict]; - self.raw = [[NSDictionary alloc] initWithDictionary:dict]; return self; } @@ -64,8 +66,5 @@ return output; } --(NSDictionary*) asRaw { - return _raw; -} @end diff --git a/samples/client/petstore/objc/client/NIKPet.h b/samples/client/petstore/objc/client/NIKPet.h index 6d1e649f06e8..c6f0683f7309 100644 --- a/samples/client/petstore/objc/client/NIKPet.h +++ b/samples/client/petstore/objc/client/NIKPet.h @@ -5,7 +5,6 @@ @interface NIKPet : NIKSwaggerObject { @private - NSDictionary* raw; NSNumber* __id; //NSNumber NSArray* _tags; //Tag NIKCategory* _category; //Category @@ -14,7 +13,6 @@ NSArray* _photoUrls; //NSString } -@property(nonatomic) NSDictionary* raw; @property(nonatomic) NSNumber* _id; @@ -32,7 +30,6 @@ - (id) initWithValues: (NSDictionary*)dict; - (NSDictionary*) asDictionary; -- (NSDictionary*) asRaw; @end diff --git a/samples/client/petstore/objc/client/NIKPet.m b/samples/client/petstore/objc/client/NIKPet.m index 3af9f9e9a893..2d8fb47ff046 100644 --- a/samples/client/petstore/objc/client/NIKPet.m +++ b/samples/client/petstore/objc/client/NIKPet.m @@ -3,8 +3,6 @@ @implementation NIKPet -@synthesize raw = _raw; - @synthesize _id = __id; @synthesize tags = _tags; @synthesize category = _category; @@ -29,7 +27,9 @@ - (id) initWithValues: (NSDictionary*)dict { + /* isContainer: , baseType: NSNumber, complexType: */ __id = [dict objectForKey:@"id"]; + /* isContainer: true, baseType: Tag, complexType: NIKTag */ id tags_dict = [dict objectForKey:@"tags"]; if([tags_dict isKindOfClass:[NSArray class]]) { if([(NSArray*)tags_dict count] > 0) { @@ -40,16 +40,16 @@ } _tags = [[NSArray alloc] initWithArray:objs]; } - } - else if([tags_dict isKindOfClass:[NSDictionary class]] && [(NSDictionary*)tags_dict count] > 0) { - _tags = [[NIKTag alloc]initWithValues:(NSDictionary*)tags_dict]; } + /* isContainer: , baseType: Category, complexType: NIKCategory */ id category_dict = [dict objectForKey:@"category"]; _category = [[NIKCategory alloc]initWithValues:category_dict]; + /* isContainer: , baseType: NSString, complexType: */ _status = [dict objectForKey:@"status"]; + /* isContainer: , baseType: NSString, complexType: */ _name = [dict objectForKey:@"name"]; + /* isContainer: true, baseType: NSString, complexType: */ _photoUrls = [dict objectForKey:@"photoUrls"]; - self.raw = [[NSDictionary alloc] initWithDictionary:dict]; return self; } @@ -99,8 +99,5 @@ return output; } --(NSDictionary*) asRaw { - return _raw; -} @end diff --git a/samples/client/petstore/objc/client/NIKPetApi.m b/samples/client/petstore/objc/client/NIKPetApi.m index c92bd9ab3369..3a0a760f6805 100644 --- a/samples/client/petstore/objc/client/NIKPetApi.m +++ b/samples/client/petstore/objc/client/NIKPetApi.m @@ -22,6 +22,13 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; [_api addHeader:value forKey:key]; } +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKPet + * returnContainer: + * + **/ -(void) getPetByIdWithCompletionBlock :(NSString*) petId completionHandler:(void (^)(NIKPet*, NSError *))completionBlock{ @@ -38,21 +45,28 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; if(petId == nil) { // error } + // not a return container [_api dictionaryWithCompletionBlock: requestUrl method: @"GET" queryParams: queryParams body: bodyDictionary headerParams: headerParams completionHandler: ^(NSDictionary *data, NSError *error) { - if (error) { + if (error) { completionBlock(nil, error);return; } - completionBlock( [[NIKPet alloc]initWithValues: data], nil); - }]; - + completionBlock( [[NIKPet alloc]initWithValues: data], nil);}]; + } +/** + * + * returnTypeIsPrimitive: true + * returnBaseType: + * returnContainer: + * + **/ -(void) addPetWithCompletionBlock :(NIKPet*) body completionHandler:(void (^)(NSError *))completionBlock{ @@ -90,21 +104,29 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; if(body == nil) { // error } + // not a return container [_api stringWithCompletionBlock: requestUrl method: @"POST" queryParams: queryParams body: bodyDictionary headerParams: headerParams completionHandler: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error);return; + if (error) { + completionBlock(error); + return; } - completionBlock(nil); }]; - + } +/** + * + * returnTypeIsPrimitive: true + * returnBaseType: + * returnContainer: + * + **/ -(void) updatePetWithCompletionBlock :(NIKPet*) body completionHandler:(void (^)(NSError *))completionBlock{ @@ -142,21 +164,29 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; if(body == nil) { // error } + // not a return container [_api stringWithCompletionBlock: requestUrl method: @"PUT" queryParams: queryParams body: bodyDictionary headerParams: headerParams completionHandler: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error);return; + if (error) { + completionBlock(error); + return; } - completionBlock(nil); }]; - + } +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKPet + * returnContainer: List + * + **/ -(void) findPetsByStatusWithCompletionBlock :(NSString*) status completionHandler:(void (^)(NSArray*, NSError *))completionBlock{ @@ -174,13 +204,14 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; if(status == nil) { // error } + // it's a returnContainer [_api dictionaryWithCompletionBlock: requestUrl method: @"GET" queryParams: queryParams body: bodyDictionary headerParams: headerParams completionHandler: ^(NSDictionary *data, NSError *error) { - if (error) { + if (error) { completionBlock(nil, error);return; } @@ -192,11 +223,17 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; } completionBlock(objs, nil); } - - }]; - + }]; + } +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKPet + * returnContainer: List + * + **/ -(void) findPetsByTagsWithCompletionBlock :(NSString*) tags completionHandler:(void (^)(NSArray*, NSError *))completionBlock{ @@ -214,13 +251,14 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; if(tags == nil) { // error } + // it's a returnContainer [_api dictionaryWithCompletionBlock: requestUrl method: @"GET" queryParams: queryParams body: bodyDictionary headerParams: headerParams completionHandler: ^(NSDictionary *data, NSError *error) { - if (error) { + if (error) { completionBlock(nil, error);return; } @@ -232,9 +270,8 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; } completionBlock(objs, nil); } - - }]; - + }]; + } -(void) getPetByIdAsJsonWithCompletionBlock :(NSString*) petId diff --git a/samples/client/petstore/objc/client/NIKStoreApi.m b/samples/client/petstore/objc/client/NIKStoreApi.m index 70c89413658b..4fdfdcca1da2 100644 --- a/samples/client/petstore/objc/client/NIKStoreApi.m +++ b/samples/client/petstore/objc/client/NIKStoreApi.m @@ -22,6 +22,13 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; [_api addHeader:value forKey:key]; } +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKOrder + * returnContainer: + * + **/ -(void) getOrderByIdWithCompletionBlock :(NSString*) orderId completionHandler:(void (^)(NIKOrder*, NSError *))completionBlock{ @@ -38,21 +45,28 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; if(orderId == nil) { // error } + // not a return container [_api dictionaryWithCompletionBlock: requestUrl method: @"GET" queryParams: queryParams body: bodyDictionary headerParams: headerParams completionHandler: ^(NSDictionary *data, NSError *error) { - if (error) { + if (error) { completionBlock(nil, error);return; } - completionBlock( [[NIKOrder alloc]initWithValues: data], nil); - }]; - + completionBlock( [[NIKOrder alloc]initWithValues: data], nil);}]; + } +/** + * + * returnTypeIsPrimitive: true + * returnBaseType: + * returnContainer: + * + **/ -(void) deleteOrderWithCompletionBlock :(NSString*) orderId completionHandler:(void (^)(NSError *))completionBlock{ @@ -69,21 +83,29 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; if(orderId == nil) { // error } + // not a return container [_api stringWithCompletionBlock: requestUrl method: @"DELETE" queryParams: queryParams body: bodyDictionary headerParams: headerParams completionHandler: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error);return; + if (error) { + completionBlock(error); + return; } - completionBlock(nil); }]; - + } +/** + * + * returnTypeIsPrimitive: true + * returnBaseType: + * returnContainer: + * + **/ -(void) placeOrderWithCompletionBlock :(NIKOrder*) body completionHandler:(void (^)(NSError *))completionBlock{ @@ -121,19 +143,20 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; if(body == nil) { // error } + // not a return container [_api stringWithCompletionBlock: requestUrl method: @"POST" queryParams: queryParams body: bodyDictionary headerParams: headerParams completionHandler: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error);return; + if (error) { + completionBlock(error); + return; } - completionBlock(nil); }]; - + } -(void) getOrderByIdAsJsonWithCompletionBlock :(NSString*) orderId diff --git a/samples/client/petstore/objc/client/NIKTag.h b/samples/client/petstore/objc/client/NIKTag.h index e7043f7a350c..86a4100da577 100644 --- a/samples/client/petstore/objc/client/NIKTag.h +++ b/samples/client/petstore/objc/client/NIKTag.h @@ -3,12 +3,10 @@ @interface NIKTag : NIKSwaggerObject { @private - NSDictionary* raw; NSNumber* __id; //NSNumber NSString* _name; //NSString } -@property(nonatomic) NSDictionary* raw; @property(nonatomic) NSNumber* _id; @@ -18,7 +16,6 @@ - (id) initWithValues: (NSDictionary*)dict; - (NSDictionary*) asDictionary; -- (NSDictionary*) asRaw; @end diff --git a/samples/client/petstore/objc/client/NIKTag.m b/samples/client/petstore/objc/client/NIKTag.m index ba5dfca98494..51b38a786441 100644 --- a/samples/client/petstore/objc/client/NIKTag.m +++ b/samples/client/petstore/objc/client/NIKTag.m @@ -3,8 +3,6 @@ @implementation NIKTag -@synthesize raw = _raw; - @synthesize _id = __id; @synthesize name = _name; - (id) _id: (NSNumber*) _id @@ -17,9 +15,10 @@ - (id) initWithValues: (NSDictionary*)dict { + /* isContainer: , baseType: NSNumber, complexType: */ __id = [dict objectForKey:@"id"]; + /* isContainer: , baseType: NSString, complexType: */ _name = [dict objectForKey:@"name"]; - self.raw = [[NSDictionary alloc] initWithDictionary:dict]; return self; } @@ -31,8 +30,5 @@ return output; } --(NSDictionary*) asRaw { - return _raw; -} @end diff --git a/samples/client/petstore/objc/client/NIKUser.h b/samples/client/petstore/objc/client/NIKUser.h index d6cd60bb5274..3b061d73cdf0 100644 --- a/samples/client/petstore/objc/client/NIKUser.h +++ b/samples/client/petstore/objc/client/NIKUser.h @@ -3,7 +3,6 @@ @interface NIKUser : NIKSwaggerObject { @private - NSDictionary* raw; NSNumber* __id; //NSNumber NSString* _lastName; //NSString NSString* _username; //NSString @@ -14,7 +13,6 @@ NSString* _password; //NSString } -@property(nonatomic) NSDictionary* raw; @property(nonatomic) NSNumber* _id; @@ -36,7 +34,6 @@ - (id) initWithValues: (NSDictionary*)dict; - (NSDictionary*) asDictionary; -- (NSDictionary*) asRaw; @end diff --git a/samples/client/petstore/objc/client/NIKUser.m b/samples/client/petstore/objc/client/NIKUser.m index cf51906457fb..5e6a393e0a44 100644 --- a/samples/client/petstore/objc/client/NIKUser.m +++ b/samples/client/petstore/objc/client/NIKUser.m @@ -3,8 +3,6 @@ @implementation NIKUser -@synthesize raw = _raw; - @synthesize _id = __id; @synthesize lastName = _lastName; @synthesize username = _username; @@ -35,15 +33,22 @@ - (id) initWithValues: (NSDictionary*)dict { + /* isContainer: , baseType: NSNumber, complexType: */ __id = [dict objectForKey:@"id"]; + /* isContainer: , baseType: NSString, complexType: */ _lastName = [dict objectForKey:@"lastName"]; + /* isContainer: , baseType: NSString, complexType: */ _username = [dict objectForKey:@"username"]; + /* isContainer: , baseType: NSString, complexType: */ _phone = [dict objectForKey:@"phone"]; + /* isContainer: , baseType: NSString, complexType: */ _email = [dict objectForKey:@"email"]; + /* isContainer: , baseType: NSNumber, complexType: */ _userStatus = [dict objectForKey:@"userStatus"]; + /* isContainer: , baseType: NSString, complexType: */ _firstName = [dict objectForKey:@"firstName"]; + /* isContainer: , baseType: NSString, complexType: */ _password = [dict objectForKey:@"password"]; - self.raw = [[NSDictionary alloc] initWithDictionary:dict]; return self; } @@ -61,8 +66,5 @@ return output; } --(NSDictionary*) asRaw { - return _raw; -} @end diff --git a/samples/client/petstore/objc/client/NIKUserApi.m b/samples/client/petstore/objc/client/NIKUserApi.m index aaed562d80ab..98ac2a772899 100644 --- a/samples/client/petstore/objc/client/NIKUserApi.m +++ b/samples/client/petstore/objc/client/NIKUserApi.m @@ -22,6 +22,13 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; [_api addHeader:value forKey:key]; } +/** + * + * returnTypeIsPrimitive: true + * returnBaseType: + * returnContainer: + * + **/ -(void) createUsersWithArrayInputWithCompletionBlock :(NSArray*) body completionHandler:(void (^)(NSError *))completionBlock{ @@ -59,21 +66,29 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; if(body == nil) { // error } + // not a return container [_api stringWithCompletionBlock: requestUrl method: @"POST" queryParams: queryParams body: bodyDictionary headerParams: headerParams completionHandler: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error);return; + if (error) { + completionBlock(error); + return; } - completionBlock(nil); }]; - + } +/** + * + * returnTypeIsPrimitive: true + * returnBaseType: + * returnContainer: + * + **/ -(void) createUserWithCompletionBlock :(NIKUser*) body completionHandler:(void (^)(NSError *))completionBlock{ @@ -111,21 +126,29 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; if(body == nil) { // error } + // not a return container [_api stringWithCompletionBlock: requestUrl method: @"POST" queryParams: queryParams body: bodyDictionary headerParams: headerParams completionHandler: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error);return; + if (error) { + completionBlock(error); + return; } - completionBlock(nil); }]; - + } +/** + * + * returnTypeIsPrimitive: true + * returnBaseType: + * returnContainer: + * + **/ -(void) createUsersWithListInputWithCompletionBlock :(NSArray*) body completionHandler:(void (^)(NSError *))completionBlock{ @@ -163,21 +186,29 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; if(body == nil) { // error } + // not a return container [_api stringWithCompletionBlock: requestUrl method: @"POST" queryParams: queryParams body: bodyDictionary headerParams: headerParams completionHandler: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error);return; + if (error) { + completionBlock(error); + return; } - completionBlock(nil); }]; - + } +/** + * + * returnTypeIsPrimitive: true + * returnBaseType: + * returnContainer: + * + **/ -(void) updateUserWithCompletionBlock :(NSString*) username body:(NIKUser*) body completionHandler:(void (^)(NSError *))completionBlock{ @@ -219,21 +250,29 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; if(body == nil) { // error } + // not a return container [_api stringWithCompletionBlock: requestUrl method: @"PUT" queryParams: queryParams body: bodyDictionary headerParams: headerParams completionHandler: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error);return; + if (error) { + completionBlock(error); + return; } - completionBlock(nil); }]; - + } +/** + * + * returnTypeIsPrimitive: true + * returnBaseType: + * returnContainer: + * + **/ -(void) deleteUserWithCompletionBlock :(NSString*) username completionHandler:(void (^)(NSError *))completionBlock{ @@ -250,21 +289,29 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; if(username == nil) { // error } + // not a return container [_api stringWithCompletionBlock: requestUrl method: @"DELETE" queryParams: queryParams body: bodyDictionary headerParams: headerParams completionHandler: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error);return; + if (error) { + completionBlock(error); + return; } - completionBlock(nil); }]; - + } +/** + * + * returnTypeIsPrimitive: + * returnBaseType: NIKUser + * returnContainer: + * + **/ -(void) getUserByNameWithCompletionBlock :(NSString*) username completionHandler:(void (^)(NIKUser*, NSError *))completionBlock{ @@ -281,21 +328,28 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; if(username == nil) { // error } + // not a return container [_api dictionaryWithCompletionBlock: requestUrl method: @"GET" queryParams: queryParams body: bodyDictionary headerParams: headerParams completionHandler: ^(NSDictionary *data, NSError *error) { - if (error) { + if (error) { completionBlock(nil, error);return; } - completionBlock( [[NIKUser alloc]initWithValues: data], nil); - }]; - + completionBlock( [[NIKUser alloc]initWithValues: data], nil);}]; + } +/** + * + * returnTypeIsPrimitive: true + * returnBaseType: NSString + * returnContainer: + * + **/ -(void) loginUserWithCompletionBlock :(NSString*) username password:(NSString*) password completionHandler:(void (^)(NSString*, NSError *))completionBlock{ @@ -318,21 +372,42 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; if(password == nil) { // error } + // not a return container + // not an array, need to get json string as response [_api stringWithCompletionBlock: requestUrl method: @"GET" queryParams: queryParams body: bodyDictionary headerParams: headerParams completionHandler: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(nil, error);return; + if (error) { + completionBlock(nil, error); + return; } completionBlock( [[NSString alloc]initWithString: data], nil); }]; - + [_api dictionaryWithCompletionBlock: requestUrl + method: @"GET" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + completionHandler: ^(NSDictionary *data, NSError *error) { + if (error) { + completionBlock(nil, error);return; + } + + completionBlock( [[NSString alloc]initWithString: data], nil);}]; + } +/** + * + * returnTypeIsPrimitive: true + * returnBaseType: + * returnContainer: + * + **/ -(void) logoutUserWithCompletionBlock : completionHandler:(void (^)(NSError *))completionBlock{ @@ -345,19 +420,20 @@ static NSString * basePath = @"http://petstore.swagger.wordnik.com/api"; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; id bodyDictionary = nil; - [_api stringWithCompletionBlock: requestUrl + // not a return container + [_api stringWithCompletionBlock: requestUrl method: @"GET" queryParams: queryParams body: bodyDictionary headerParams: headerParams completionHandler: ^(NSString *data, NSError *error) { - if (error) { - completionBlock(error);return; + if (error) { + completionBlock(error); + return; } - completionBlock(nil); }]; - + } -(void) createUsersWithArrayInputAsJsonWithCompletionBlock :(NSArray*) body diff --git a/samples/client/petstore/objc/tests/UserApiTest.h b/samples/client/petstore/objc/tests/UserApiTest.h new file mode 100644 index 000000000000..0b13ca037910 --- /dev/null +++ b/samples/client/petstore/objc/tests/UserApiTest.h @@ -0,0 +1,9 @@ +#import +#import "NIKUserApi.h" + +@interface UserApiTest : SenTestCase { +@private + NIKUserApi * api; +} + +@end diff --git a/samples/client/petstore/objc/tests/UserApiTest.m b/samples/client/petstore/objc/tests/UserApiTest.m new file mode 100644 index 000000000000..8631692aabb8 --- /dev/null +++ b/samples/client/petstore/objc/tests/UserApiTest.m @@ -0,0 +1,47 @@ +#import "UserApiTest.h" + +@implementation UserApiTest + +- (void)setUp { + [super setUp]; + api = [[NIKUserApi alloc ]init]; +} + +- (void)tearDown { + [super tearDown]; +} + +- (void)testLoginUser { + bool done = false; + static NSString* authString = nil; + static NSError * gError = nil; + + [api loginUserWithCompletionBlock:@"foo" + password:@"bar" + completionHandler:^(NSString *output, NSError *error) { + if(error) { + gError = error; + } + if(output == nil){ + NSLog(@"failed to login"); + } + else { + authString = [NSString stringWithString:output]; + } + }]; + + NSDate * loopUntil = [NSDate dateWithTimeIntervalSinceNow:10]; + while(!done && [loopUntil timeIntervalSinceNow] > 0){ + if(gError){ + STFail(@"got error %@", gError); + done = true; + } + if(authString){ + done = true; + } + } + STAssertTrue([authString length] > 0, @"string was zero chars"); + NSLog(@"got login %@", authString); +} + +@end