diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/DefaultCodegen.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/DefaultCodegen.java index ac7db378602..f0664a72c72 100644 --- a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/DefaultCodegen.java +++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/DefaultCodegen.java @@ -745,6 +745,8 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation op.isMapContainer = Boolean.TRUE; else if ("list".equalsIgnoreCase(cm.containerType)) op.isListContainer = Boolean.TRUE; + else if ("array".equalsIgnoreCase(cm.containerType)) + op.isListContainer = Boolean.TRUE; } else op.returnSimpleType = true; diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/ObjcClientCodegen.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/ObjcClientCodegen.java index 47c34ad9031..2e91cafa992 100644 --- a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/ObjcClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/ObjcClientCodegen.java @@ -48,7 +48,6 @@ public ObjcClientCodegen() { "NSObject", "NSArray", "NSNumber", - "NSDate", "NSDictionary", "NSMutableArray", "NSMutableDictionary") @@ -57,7 +56,6 @@ public ObjcClientCodegen() { Arrays.asList( "NSNumber", "NSString", - "NSDate", "NSObject", "bool") ); @@ -72,8 +70,9 @@ public ObjcClientCodegen() { typeMapping = new HashMap(); typeMapping.put("enum", "NSString"); - typeMapping.put("Date", "NSDate"); - typeMapping.put("DateTime", "NSDate"); + typeMapping.put("Date", "SWGDate"); + typeMapping.put("DateTime", "SWGDate"); + // typeMapping.put("Date", "SWGDate"); typeMapping.put("boolean", "NSNumber"); typeMapping.put("string", "NSString"); typeMapping.put("integer", "NSNumber"); @@ -88,13 +87,13 @@ public ObjcClientCodegen() { typeMapping.put("object", "NSObject"); importMapping = new HashMap (); + importMapping.put("Date", "SWGDate"); foundationClasses = new HashSet ( Arrays.asList( "NSNumber", "NSObject", "NSString", - "NSDate", "NSDictionary") ); @@ -152,45 +151,11 @@ public String getSwaggerType(Property p) { @Override public String getTypeDeclaration(Property p) { - if (p instanceof ArrayProperty) { - ArrayProperty ap = (ArrayProperty) p; - Property inner = ap.getItems(); - String innerType = getSwaggerType(inner); - - // In this codition, type of property p is array of primitive, - // return container type with pointer, e.g. `NSArray*' - if (languageSpecificPrimitives.contains(innerType)) - return getSwaggerType(p) + "*"; - - // In this codition, type of property p is array of model, - // return container type combine inner type with pointer, e.g. `NSArray*' - String innerTypeDeclaration = getTypeDeclaration(inner); - - if (innerTypeDeclaration.endsWith("*")) - innerTypeDeclaration = innerTypeDeclaration.substring(0, innerTypeDeclaration.length() - 1); - - return getSwaggerType(p) + "<" + innerTypeDeclaration + ">*"; - } - else { - String swaggerType = getSwaggerType(p); - - // In this codition, type of p is objective-c primitive type, e.g. `NSSNumber', - // return type of p with pointer, e.g. `NSNumber*' - if (languageSpecificPrimitives.contains(swaggerType) && - foundationClasses.contains(swaggerType)) { - return swaggerType + "*"; - } - // In this codition, type of p is c primitive type, e.g. `bool', - // return type of p, e.g. `bool' - else if (languageSpecificPrimitives.contains(swaggerType)) { - return swaggerType; - } - // In this codition, type of p is objective-c object type, e.g. `SWGPet', - // return type of p with pointer, e.g. `' - else { - return swaggerType + "*"; - } - } + String swaggerType = getSwaggerType(p); + if(languageSpecificPrimitives.contains(swaggerType) && !foundationClasses.contains(swaggerType)) + return toModelName(swaggerType); + else + return swaggerType + "*"; } @Override diff --git a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache index 2998682cbad..ffead406a86 100644 --- a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache @@ -110,18 +110,25 @@ static NSString * basePath = @"{{basePath}}"; } {{/bodyParam}} {{^bodyParam}} - bodyDictionary = [[NSMutableArray alloc] init]; NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - {{#formParams}}{{#notFile}} + {{#formParams}} + {{#notFile}} formParams[@"{{paramName}}"] = {{paramName}}; {{/notFile}}{{#isFile}} requestContentType = @"multipart/form-data"; + if(bodyDictionary == nil) { + bodyDictionary = [[NSMutableArray alloc] init]; + } [bodyDictionary addObject:{{paramName}}]; {{paramName}}.paramName = @"{{baseName}}"; - {{/isFile}}{{/formParams}} + {{/isFile}} + if(bodyDictionary == nil) { + bodyDictionary = [[NSMutableArray alloc] init]; + } [bodyDictionary addObject:formParams]; + {{/formParams}} {{/bodyParam}} {{#requiredParamCount}} @@ -134,11 +141,26 @@ static NSString * basePath = @"{{basePath}}"; SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath]; - {{#returnContainer}}{{>apiBodyResponseWithContainer}}{{/returnContainer}} + {{#returnContainer}} + // response is in a container + {{>apiBodyResponseWithContainer}}{{/returnContainer}} + {{#returnSimpleType}} - {{#returnTypeIsPrimitive}}{{>apiPrimitiveResponse}}{{/returnTypeIsPrimitive}} - {{#returnBaseType}}{{>apiNonPrimitiveResponse}}{{/returnBaseType}} + // non container response + + {{#returnTypeIsPrimitive}} + // primitive response + {{>apiPrimitiveResponse}}{{/returnTypeIsPrimitive}} + + {{#returnBaseType}} + // complex response + {{>apiNonPrimitiveResponse}}{{/returnBaseType}} {{/returnSimpleType}} + + {{^returnSimpleType}}{{^returnContainer}} + // it's void + {{>voidResponse}} + {{/returnContainer}}{{/returnSimpleType}} } {{/operation}} diff --git a/modules/swagger-codegen/src/main/resources/objc/apiNonPrimitiveResponse.mustache b/modules/swagger-codegen/src/main/resources/objc/apiNonPrimitiveResponse.mustache index 1ab814c0589..d27a9f601ed 100644 --- a/modules/swagger-codegen/src/main/resources/objc/apiNonPrimitiveResponse.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/apiNonPrimitiveResponse.mustache @@ -13,12 +13,11 @@ {{^returnBaseType}}completionBlock(error);{{/returnBaseType}} return; } - {{#returnBaseType}} - {{returnBaseType}} *result = nil; + {{#returnType}}{{returnType}} result = nil; if (data) { - result = [[{{#instantiationType}}NSClassFromString(@"{{{instantiationType}}}") {{/instantiationType}}{{^instantiationType}}{{{returnBaseType}}} {{/instantiationType}} alloc]initWithValues: data]; + result = [[{{#instantiationType}}NSClassFromString(@"{{{instantiationType}}}") {{/instantiationType}}{{^instantiationType}}{{{returnBaseType}}} {{/instantiationType}} alloc] {{#returnContainer}}{{#isMapContainer}}initWithDictionary{{/isMapContainer}}{{#isListContainer}}initWithValues{{/isListContainer}}{{/returnContainer}}{{^returnContainer}}initWithValues {{/returnContainer}}: data]; } - {{#returnBaseType}}completionBlock(result , nil);{{/returnBaseType}} - {{/returnBaseType}} + {{#returnType}}completionBlock(result , nil);{{/returnType}} + {{/returnType}} }]; {{/returnTypeIsPrimitive}} \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/objc/voidResponse.mustache b/modules/swagger-codegen/src/main/resources/objc/voidResponse.mustache new file mode 100644 index 00000000000..b128bfd21cc --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/objc/voidResponse.mustache @@ -0,0 +1,14 @@ + return [client stringWithCompletionBlock: requestUrl + method: @"{{httpMethod}}" + queryParams: queryParams + body: bodyDictionary + headerParams: headerParams + requestContentType: requestContentType + responseContentType: responseContentType + completionBlock: ^(NSString *data, NSError *error) { + if (error) { + completionBlock(error); + return; + } + completionBlock(nil); + }]; diff --git a/samples/client/petstore/objc/PetstoreClient/PetstoreClient/ViewController.m b/samples/client/petstore/objc/PetstoreClient/PetstoreClient/ViewController.m index ebdb5a42e99..631a18f44e9 100644 --- a/samples/client/petstore/objc/PetstoreClient/PetstoreClient/ViewController.m +++ b/samples/client/petstore/objc/PetstoreClient/PetstoreClient/ViewController.m @@ -22,15 +22,15 @@ - (void)viewDidLoad 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!"); -// }]; - - // load data into file -// }]; + [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 + }]; NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test-1" ofType:@"png"]; NSData *myData = [NSData dataWithContentsOfFile:filePath]; diff --git a/samples/client/petstore/objc/Podfile b/samples/client/petstore/objc/Podfile index e6b8aab6518..08674feba4c 100644 --- a/samples/client/petstore/objc/Podfile +++ b/samples/client/petstore/objc/Podfile @@ -1,3 +1,3 @@ platform :ios, '6.0' -xcodeproj 'swaggerClient/swaggerClient.xcodeproj' +xcodeproj 'PetstoreClient/PetstoreClient.xcodeproj' pod 'AFNetworking', '~> 2.1' diff --git a/samples/client/petstore/objc/Podfile.lock b/samples/client/petstore/objc/Podfile.lock index a3466a08296..ed27b0f2376 100644 --- a/samples/client/petstore/objc/Podfile.lock +++ b/samples/client/petstore/objc/Podfile.lock @@ -27,4 +27,4 @@ DEPENDENCIES: SPEC CHECKSUMS: AFNetworking: 8bee59492a6ff15d69130efa4d0dc67e0094a52a -COCOAPODS: 0.35.0 +COCOAPODS: 0.36.0 diff --git a/samples/client/petstore/objc/client/SWGPetApi.m b/samples/client/petstore/objc/client/SWGPetApi.m index 1305f552c8d..5d134bb1f27 100644 --- a/samples/client/petstore/objc/client/SWGPetApi.m +++ b/samples/client/petstore/objc/client/SWGPetApi.m @@ -109,6 +109,26 @@ -(NSNumber*) updatePetWithCompletionBlock: (SWGPet*) body 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 @@ -(NSNumber*) addPetWithCompletionBlock: (SWGPet*) body 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 @@ -(NSNumber*) findPetsByStatusWithCompletionBlock: (NSArray*) status 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 @@ -(NSNumber*) findPetsByStatusWithCompletionBlock: (NSArray*) status 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 @@ -(NSNumber*) findPetsByTagsWithCompletionBlock: (NSArray*) tags 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 @@ -(NSNumber*) findPetsByTagsWithCompletionBlock: (NSArray*) tags 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 @@ -(NSNumber*) getPetByIdWithCompletionBlock: (NSNumber*) petId id bodyDictionary = nil; - bodyDictionary = [[NSMutableArray alloc] init]; NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - [bodyDictionary addObject:formParams]; @@ -325,8 +395,14 @@ -(NSNumber*) getPetByIdWithCompletionBlock: (NSNumber*) petId SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath]; + + + // non container response + + + // complex response // comples response type return [client dictionary: requestUrl @@ -342,16 +418,17 @@ -(NSNumber*) getPetByIdWithCompletionBlock: (NSNumber*) petId 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 @@ -(NSNumber*) updatePetWithFormWithCompletionBlock: (NSString*) petId 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 @@ -(NSNumber*) deletePetWithCompletionBlock: (NSString*) api_key id bodyDictionary = nil; - bodyDictionary = [[NSMutableArray alloc] init]; NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - [bodyDictionary addObject:formParams]; @@ -442,6 +547,26 @@ -(NSNumber*) deletePetWithCompletionBlock: (NSString*) api_key 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 @@ -(NSNumber*) uploadFileWithCompletionBlock: (NSNumber*) petId 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 @@ -(NSNumber*) uploadFileWithCompletionBlock: (NSNumber*) petId } completionBlock(nil); }]; - - - + } diff --git a/samples/client/petstore/objc/client/SWGStoreApi.m b/samples/client/petstore/objc/client/SWGStoreApi.m index b0c42e7d982..3eb015ebc0a 100644 --- a/samples/client/petstore/objc/client/SWGStoreApi.m +++ b/samples/client/petstore/objc/client/SWGStoreApi.m @@ -73,18 +73,18 @@ -(NSNumber*) getInventoryWithCompletionBlock: 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 @@ -(NSNumber*) getInventoryWithCompletionBlock: }]; + + + } @@ -168,8 +171,14 @@ -(NSNumber*) placeOrderWithCompletionBlock: (SWGOrder*) body SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath]; + + // non container response + + + + // complex response // comples response type return [client dictionary: requestUrl @@ -185,16 +194,17 @@ -(NSNumber*) placeOrderWithCompletionBlock: (SWGOrder*) body 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 @@ -(NSNumber*) getOrderByIdWithCompletionBlock: (NSString*) orderId id bodyDictionary = nil; - bodyDictionary = [[NSMutableArray alloc] init]; NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - [bodyDictionary addObject:formParams]; @@ -235,8 +243,14 @@ -(NSNumber*) getOrderByIdWithCompletionBlock: (NSString*) orderId SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath]; + + + // non container response + + + // complex response // comples response type return [client dictionary: requestUrl @@ -252,16 +266,17 @@ -(NSNumber*) getOrderByIdWithCompletionBlock: (NSString*) orderId 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 @@ -(NSNumber*) deleteOrderWithCompletionBlock: (NSString*) orderId id bodyDictionary = nil; - bodyDictionary = [[NSMutableArray alloc] init]; NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - [bodyDictionary addObject:formParams]; @@ -302,6 +315,26 @@ -(NSNumber*) deleteOrderWithCompletionBlock: (NSString*) orderId 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); + }]; + } diff --git a/samples/client/petstore/objc/client/SWGUserApi.m b/samples/client/petstore/objc/client/SWGUserApi.m index fbaafa76fa5..6e33862d111 100644 --- a/samples/client/petstore/objc/client/SWGUserApi.m +++ b/samples/client/petstore/objc/client/SWGUserApi.m @@ -108,12 +108,12 @@ -(NSNumber*) createUserWithCompletionBlock: (SWGUser*) body 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 @@ -(NSNumber*) createUserWithCompletionBlock: (SWGUser*) body } completionBlock(nil); }]; - - - + } @@ -191,12 +189,12 @@ -(NSNumber*) createUsersWithArrayInputWithCompletionBlock: (NSArray*) body 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 @@ -(NSNumber*) createUsersWithArrayInputWithCompletionBlock: (NSArray*) body } completionBlock(nil); }]; - - - + } @@ -274,12 +270,12 @@ -(NSNumber*) createUsersWithListInputWithCompletionBlock: (NSArray*) body 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 @@ -(NSNumber*) createUsersWithListInputWithCompletionBlock: (NSArray*) body } completionBlock(nil); }]; - - - + } @@ -328,12 +322,10 @@ -(NSNumber*) loginUserWithCompletionBlock: (NSString*) username id bodyDictionary = nil; - bodyDictionary = [[NSMutableArray alloc] init]; NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - [bodyDictionary addObject:formParams]; @@ -341,7 +333,12 @@ -(NSNumber*) loginUserWithCompletionBlock: (NSString*) username SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath]; + + + // non container response + + // primitive response // primitive response type return [client stringWithCompletionBlock: requestUrl method: @"GET" @@ -361,8 +358,13 @@ -(NSNumber*) loginUserWithCompletionBlock: (NSString*) username + + + // complex response + + } -(NSNumber*) logoutUserWithCompletionBlock: @@ -388,12 +390,10 @@ -(NSNumber*) logoutUserWithCompletionBlock: id bodyDictionary = nil; - bodyDictionary = [[NSMutableArray alloc] init]; NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - [bodyDictionary addObject:formParams]; @@ -401,12 +401,12 @@ -(NSNumber*) logoutUserWithCompletionBlock: 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 @@ -(NSNumber*) logoutUserWithCompletionBlock: } completionBlock(nil); }]; - - - + } @@ -451,12 +449,10 @@ -(NSNumber*) getUserByNameWithCompletionBlock: (NSString*) username id bodyDictionary = nil; - bodyDictionary = [[NSMutableArray alloc] init]; NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - [bodyDictionary addObject:formParams]; @@ -464,8 +460,14 @@ -(NSNumber*) getUserByNameWithCompletionBlock: (NSString*) username SWGApiClient* client = [SWGApiClient sharedClientFromPool:basePath]; + + + // non container response + + + // complex response // comples response type return [client dictionary: requestUrl @@ -481,16 +483,17 @@ -(NSNumber*) getUserByNameWithCompletionBlock: (NSString*) username 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 @@ -(NSNumber*) updateUserWithCompletionBlock: (NSString*) username 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 @@ -(NSNumber*) deleteUserWithCompletionBlock: (NSString*) username id bodyDictionary = nil; - bodyDictionary = [[NSMutableArray alloc] init]; NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init]; - [bodyDictionary addObject:formParams]; @@ -594,6 +615,26 @@ -(NSNumber*) deleteUserWithCompletionBlock: (NSString*) username 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); + }]; + }