From c9a2a14da51679ba2d9bf0625a4cc11606af98fe Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Fri, 27 Mar 2015 22:17:50 -0700 Subject: [PATCH] added queryParamCollection --- bin/objc-petstore.sh | 2 +- .../codegen/languages/ObjcClientCodegen.java | 2 + .../resources/objc/SWGQueryParamCollection.h | 9 + .../resources/objc/SWGQueryParamCollection.m | 16 ++ .../src/main/resources/objc/api-body.mustache | 9 +- .../PetstoreClient.xcodeproj/project.pbxproj | 6 + .../PetstoreClientTests/PetApiTest.m | 162 ++++++++---------- .../petstore/objc/client/SWGApiClient.m | 35 +++- .../client/petstore/objc/client/SWGPetApi.m | 17 +- .../objc/client/SWGQueryParamCollection.h | 9 + .../objc/client/SWGQueryParamCollection.m | 16 ++ .../client/petstore/objc/client/SWGStoreApi.m | 1 + .../client/petstore/objc/client/SWGUserApi.m | 9 +- 13 files changed, 194 insertions(+), 99 deletions(-) create mode 100644 modules/swagger-codegen/src/main/resources/objc/SWGQueryParamCollection.h create mode 100644 modules/swagger-codegen/src/main/resources/objc/SWGQueryParamCollection.m create mode 100644 samples/client/petstore/objc/client/SWGQueryParamCollection.h create mode 100644 samples/client/petstore/objc/client/SWGQueryParamCollection.m diff --git a/bin/objc-petstore.sh b/bin/objc-petstore.sh index feefc99a28c..513b7535786 100755 --- a/bin/objc-petstore.sh +++ b/bin/objc-petstore.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l objc -o samples/client/petstore/objc" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/objc -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l objc -o samples/client/petstore/objc" java -DappName=PetstoreClient $JAVA_OPTS -jar $executable $ags 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 2e91cafa992..76d9e419359 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 @@ -102,6 +102,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("SWGObject.h", sourceFolder, "SWGObject.h")); supportingFiles.add(new SupportingFile("SWGObject.m", sourceFolder, "SWGObject.m")); + supportingFiles.add(new SupportingFile("SWGQueryParamCollection.h", sourceFolder, "SWGQueryParamCollection.h")); + supportingFiles.add(new SupportingFile("SWGQueryParamCollection.m", sourceFolder, "SWGQueryParamCollection.m")); supportingFiles.add(new SupportingFile("SWGApiClient.h", sourceFolder, "SWGApiClient.h")); supportingFiles.add(new SupportingFile("SWGApiClient.m", sourceFolder, "SWGApiClient.m")); supportingFiles.add(new SupportingFile("SWGFile.h", sourceFolder, "SWGFile.h")); diff --git a/modules/swagger-codegen/src/main/resources/objc/SWGQueryParamCollection.h b/modules/swagger-codegen/src/main/resources/objc/SWGQueryParamCollection.h new file mode 100644 index 00000000000..26b830875f0 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/objc/SWGQueryParamCollection.h @@ -0,0 +1,9 @@ +@interface SWGQueryParamCollection : NSObject + +@property(nonatomic, readonly) NSArray* values; +@property(nonatomic, readonly) NSString* format; + +- (id) initWithValuesAndFormat: (NSArray*) values + format: (NSString*) format; + +@end diff --git a/modules/swagger-codegen/src/main/resources/objc/SWGQueryParamCollection.m b/modules/swagger-codegen/src/main/resources/objc/SWGQueryParamCollection.m new file mode 100644 index 00000000000..9ce319940dd --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/objc/SWGQueryParamCollection.m @@ -0,0 +1,16 @@ +#import "SWGQueryParamCollection.h" + +@implementation SWGQueryParamCollection + +@synthesize values = _values; +@synthesize format = _format; + +- (id) initWithValuesAndFormat: (NSArray*) values + format: (NSString*) format { + _values = values; + _format = format; + + return self; +} + +@end \ No newline at end of file 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 ffead406a86..e079df918ac 100644 --- a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache @@ -1,6 +1,7 @@ {{#operations}} #import "{{classname}}.h" #import "SWGFile.h" +#import "SWGQueryParamCollection.h" #import "SWGApiClient.h" {{#imports}}#import "{{import}}.h" {{/imports}} @@ -71,8 +72,12 @@ static NSString * basePath = @"{{basePath}}"; NSString* responseContentType = @"application/json"; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - {{#queryParams}}if({{paramName}} != nil) - queryParams[@"{{baseName}}"] = {{paramName}}; + {{#queryParams}}if({{paramName}} != nil) { + {{#collectionFormat}} + queryParams[@"{{baseName}}"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: {{baseName}} format: @"{{collectionFormat}}"]; + {{/collectionFormat}} + {{^collectionFormat}}queryParams[@"{{baseName}}"] = {{paramName}};{{/collectionFormat}} + } {{/queryParams}} NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; {{#headerParams}}if({{paramName}} != nil) diff --git a/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.pbxproj b/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.pbxproj index 66a244ebf3a..bf04a276caa 100644 --- a/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.pbxproj +++ b/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.pbxproj @@ -23,6 +23,7 @@ EA6699BE1811D2FB00A70D03 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA66999D1811D2FA00A70D03 /* UIKit.framework */; }; EA6699C61811D2FB00A70D03 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = EA6699C41811D2FB00A70D03 /* InfoPlist.strings */; }; EA6699C81811D2FB00A70D03 /* PetApiTest.m in Sources */ = {isa = PBXBuildFile; fileRef = EA6699C71811D2FB00A70D03 /* PetApiTest.m */; }; + EA8B8AA41AC6683700638FBB /* SWGQueryParamCollection.m in Sources */ = {isa = PBXBuildFile; fileRef = EA8B8AA31AC6683700638FBB /* SWGQueryParamCollection.m */; }; EA8CD3ED1AC2763600C47D0B /* SenTestingKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA8CD3EC1AC2763600C47D0B /* SenTestingKit.framework */; }; EAEA85E41811D3AE00F06E69 /* SWGApiClient.m in Sources */ = {isa = PBXBuildFile; fileRef = EAEA85CD1811D3AE00F06E69 /* SWGApiClient.m */; }; EAEA85E51811D3AE00F06E69 /* SWGCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = EAEA85CF1811D3AE00F06E69 /* SWGCategory.m */; }; @@ -75,6 +76,8 @@ EA6699C31811D2FB00A70D03 /* PetstoreClientTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "PetstoreClientTests-Info.plist"; sourceTree = ""; }; EA6699C51811D2FB00A70D03 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; EA6699C71811D2FB00A70D03 /* PetApiTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PetApiTest.m; sourceTree = ""; }; + EA8B8AA21AC6683700638FBB /* SWGQueryParamCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWGQueryParamCollection.h; sourceTree = ""; }; + EA8B8AA31AC6683700638FBB /* SWGQueryParamCollection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGQueryParamCollection.m; sourceTree = ""; }; EA8CD3EB1AC274BE00C47D0B /* PetApiTest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PetApiTest.h; sourceTree = ""; }; EA8CD3EC1AC2763600C47D0B /* SenTestingKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SenTestingKit.framework; path = Library/Frameworks/SenTestingKit.framework; sourceTree = DEVELOPER_DIR; }; EAEA85CC1811D3AE00F06E69 /* SWGApiClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWGApiClient.h; sourceTree = ""; }; @@ -227,6 +230,8 @@ EAEA85CB1811D3AE00F06E69 /* client */ = { isa = PBXGroup; children = ( + EA8B8AA21AC6683700638FBB /* SWGQueryParamCollection.h */, + EA8B8AA31AC6683700638FBB /* SWGQueryParamCollection.m */, EAFBEABC1A92C42700A27431 /* SWGApiResponse.h */, EAFBEABD1A92C42700A27431 /* SWGApiResponse.m */, EAEA85CC1811D3AE00F06E69 /* SWGApiClient.h */, @@ -407,6 +412,7 @@ EAEA85EC1811D3AE00F06E69 /* SWGStoreApi.m in Sources */, EAEA85E91811D3AE00F06E69 /* SWGOrder.m in Sources */, EAEA85E81811D3AE00F06E69 /* SWGObject.m in Sources */, + EA8B8AA41AC6683700638FBB /* SWGQueryParamCollection.m in Sources */, EAEA85E71811D3AE00F06E69 /* SWGFile.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/samples/client/petstore/objc/PetstoreClient/PetstoreClientTests/PetApiTest.m b/samples/client/petstore/objc/PetstoreClient/PetstoreClientTests/PetApiTest.m index f21e8fc5162..8c5d597748c 100644 --- a/samples/client/petstore/objc/PetstoreClient/PetstoreClientTests/PetApiTest.m +++ b/samples/client/petstore/objc/PetstoreClient/PetstoreClientTests/PetApiTest.m @@ -6,96 +6,45 @@ - (void)setUp { [super setUp]; api = [[SWGPetApi alloc ]init]; - [SWGPetApi setBasePath:@"http://localhost:8080/api"]; } - (void)tearDown { [super tearDown]; } -- (void)testGetPetById { +- (void)testCreateAndGetPet { XCTestExpectation *expectation = [self expectationWithDescription:@"testGetPetById"]; - [api getPetByIdWithCompletionBlock:@1 completionHandler:^(SWGPet *output, NSError *error) { - if(error){ - XCTFail(@"got error %@", error); - } - if(output){ - XCTAssertNotNil([output _id], @"token was nil"); - } - [expectation fulfill]; - }]; - [self waitForExpectationsWithTimeout:2.0 handler:nil]; -} -- (void) testAddPet { - XCTestExpectation *expectation = [self expectationWithDescription:@"testAddPet"]; + SWGPet* pet = [self createPet]; - SWGPet * petToAdd = [[SWGPet alloc] init]; - [petToAdd set_id:@1000]; - NSMutableArray* tags = [[NSMutableArray alloc] init]; - for(int i = 0; i < 5; i++){ - SWGTag * tag = [[SWGTag alloc] init]; - [tag set_id:[NSNumber numberWithInt:i]]; - [tag setName:[NSString stringWithFormat:@"tag-%d", i]]; - [tags addObject:tag]; - } - [petToAdd setTags:tags]; - [petToAdd setStatus:@"lost"]; - - SWGCategory * category = [[SWGCategory alloc] init]; - [category setName:@"sold"]; - [petToAdd setCategory:category]; - [petToAdd setName:@"dragon"]; - - NSMutableArray* photos = [[NSMutableArray alloc] init]; - for(int i = 0; i < 10; i++){ - NSString * url = [NSString stringWithFormat:@"http://foo.com/photo/%d", i]; - [photos addObject:url]; - } - [petToAdd setPhotoUrls:photos]; - - [api addPetWithCompletionBlock:petToAdd completionHandler:^(NSError *error) { + [api addPetWithCompletionBlock:pet completionHandler:^(NSError *error) { if(error){ XCTFail(@"got error %@", error); } - [expectation fulfill]; + NSLog(@"%@", [pet _id]); + [api getPetByIdWithCompletionBlock:[pet _id] completionHandler:^(SWGPet *output, NSError *error) { + if(error){ + XCTFail(@"got error %@", error); + } + if(output){ + XCTAssertNotNil([output _id], @"token was nil"); + } + [expectation fulfill]; + }]; }]; - [self waitForExpectationsWithTimeout:2.0 handler:nil]; } - (void) testUpdatePet { XCTestExpectation *expectation = [self expectationWithDescription:@"testUpdatePet"]; - SWGPet * petToAdd = [[SWGPet alloc] init]; - [petToAdd set_id:[NSNumber numberWithInt:1000]]; - NSMutableArray* tags = [[NSMutableArray alloc] init]; - for(int i = 0; i < 5; i++){ - SWGTag * tag = [[SWGTag alloc] init]; - [tag set_id:[NSNumber numberWithInt:i]]; - [tag setName:[NSString stringWithFormat:@"tag-%d", i]]; - [tags addObject:tag]; - } - [petToAdd setTags:tags]; - [petToAdd setStatus:@"lost"]; + SWGPet* pet = [self createPet]; - SWGCategory * category = [[SWGCategory alloc] init]; - [category setName:@"sold"]; - [petToAdd setCategory:category]; - [petToAdd setName:@"dragon"]; - - NSMutableArray* photos = [[NSMutableArray alloc] init]; - for(int i = 0; i < 10; i++){ - NSString * url = [NSString stringWithFormat:@"http://foo.com/photo/%d", i]; - [photos addObject:url]; - } - [petToAdd setPhotoUrls:photos]; - - [api addPetWithCompletionBlock:petToAdd completionHandler:^(NSError *error) { + [api addPetWithCompletionBlock:pet completionHandler:^(NSError *error) { if(error) { XCTFail(@"got error %@", error); } else { - [api getPetByIdWithCompletionBlock:[NSString stringWithFormat:@"%@",[petToAdd _id]] completionHandler:^(SWGPet *output, NSError *error) { + [api getPetByIdWithCompletionBlock:[NSString stringWithFormat:@"%@",[pet _id]] completionHandler:^(SWGPet *output, NSError *error) { if(error) { XCTFail(@"got error %@", error); } @@ -140,39 +89,78 @@ - (void)testGetPetByStatus { XCTestExpectation *expectation = [self expectationWithDescription:@"testGetPetByStatus"]; - [api findPetsByStatusWithCompletionBlock:@"available" completionHandler:^(NSArray *output, NSError *error) { + SWGPet* pet = [self createPet]; + + [api addPetWithCompletionBlock:pet completionHandler:^(NSError *error) { if(error) { XCTFail(@"got error %@", error); } - if(output == nil){ - XCTFail(@"failed to fetch pets"); - } - else { - [expectation fulfill]; - } + NSArray* status = [[NSArray alloc] initWithObjects:@"available", nil]; + [api findPetsByStatusWithCompletionBlock:status completionHandler:^(NSArray *output, NSError *error) { + if(error) { + XCTFail(@"got error %@", error); + } + if(output == nil){ + XCTFail(@"failed to fetch pets"); + } + else { + for(SWGPet* fetched in output) { + if([pet _id] == [fetched _id]) { + [expectation fulfill]; + } + } + } + }]; }]; [self waitForExpectationsWithTimeout:2.0 handler:nil]; } - (void)testGetPetByTags { XCTestExpectation *expectation = [self expectationWithDescription:@"testGetPetByTags"]; - [api findPetsByTagsWithCompletionBlock:@"tag1,tag2" completionHandler:^(NSArray *output, NSError *error) { - if(error){ + SWGPet* pet = [self createPet]; + SWGTag* tag = [[SWGTag alloc] init]; + tag.name = @"tony"; + pet.tags = [[NSArray alloc] initWithObjects:tag, nil]; + + [api addPetWithCompletionBlock:pet completionHandler:^(NSError *error) { + if(error) { XCTFail(@"got error %@", error); } - if(output){ - for(SWGPet * pet in output) { - bool hasTag = false; - for(SWGTag * tag in [pet tags]){ - if([[tag name] isEqualToString:@"tag1"] || [[tag name] isEqualToString:@"tag2"]) - hasTag = true; - } - if(!hasTag) - XCTFail(@"failed to find tag in pet"); + NSArray* tags = [[NSArray alloc] initWithObjects:@"tony", nil]; + + [api findPetsByTagsWithCompletionBlock:tags completionHandler:^(NSArray *output, NSError *error) { + if(error){ + XCTFail(@"got error %@", error); } - } - [expectation fulfill]; + if(output){ + for(SWGPet * fetched in output) { + bool hasTag = false; + for(SWGTag * tag in [fetched tags]){ + if(fetched._id == pet._id && [[tag name] isEqualToString:@"tony"]) + hasTag = true; + } + if(!hasTag) + XCTFail(@"failed to find tag in pet"); + } + } + [expectation fulfill]; + }]; }]; [self waitForExpectationsWithTimeout:2.0 handler:nil]; } + +- (SWGPet*) createPet { + SWGPet * pet = [[SWGPet alloc] init]; + pet._id = [[NSNumber alloc] initWithLong:[[NSDate date] timeIntervalSince1970]]; + pet.name = @"monkey"; + SWGCategory * category = [[SWGCategory alloc] init]; + category.name = @"super-happy"; + + pet.category = category; + pet.status = @"available"; + + NSArray * photos = [[NSArray alloc] initWithObjects:@"http://foo.bar.com/3", @"http://foo.bar.com/4", nil]; + pet.photoUrls = photos; + return pet; +} @end \ No newline at end of file diff --git a/samples/client/petstore/objc/client/SWGApiClient.m b/samples/client/petstore/objc/client/SWGApiClient.m index ff454970cf0..36af6ea44c0 100644 --- a/samples/client/petstore/objc/client/SWGApiClient.m +++ b/samples/client/petstore/objc/client/SWGApiClient.m @@ -1,5 +1,6 @@ #import "SWGApiClient.h" #import "SWGFile.h" +#import "SWGQueryParamCollection.h" @implementation SWGApiClient @@ -208,14 +209,42 @@ static bool loggingEnabled = true; if(counter == 0) separator = @"?"; else separator = @"&"; NSString * value; - if([[queryParams valueForKey:key] isKindOfClass:[NSString class]]){ + id queryParamValue = [queryParams valueForKey:key]; + if([queryParamValue isKindOfClass:[NSString class]]){ value = [SWGApiClient escape:[queryParams valueForKey:key]]; + [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, + [SWGApiClient escape:key], value]]; + } + else if ([queryParamValue isKindOfClass:[SWGQueryParamCollection class]]) { + SWGQueryParamCollection* c = (SWGQueryParamCollection* ) queryParamValue; + NSString * format = [c format]; + NSArray * values = [c values]; + if([format isEqualToString:@"csv"]) { + [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, + [SWGApiClient escape:key], [values componentsJoinedByString:@","]]]; + } + else if([format isEqualToString:@"tsv"]) { + [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, + [SWGApiClient escape:key], [values componentsJoinedByString:@"\t"]]]; + } + else if ([format isEqualToString:@"pipes"]) { + [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, + [SWGApiClient escape:key], [values componentsJoinedByString:@"|"]]]; + } + else if([format isEqualToString:@"multi"]) { + for(id obj in values) { + + [requestUrl appendString: [NSString stringWithFormat:@"%@%@=%@", separator, [SWGApiClient escape:key], obj]]; + if(counter > 0) separator = @"&"; + } + } } else { value = [NSString stringWithFormat:@"%@", [queryParams valueForKey:key]]; + [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, + [SWGApiClient escape:key], value]]; } - [requestUrl appendString:[NSString stringWithFormat:@"%@%@=%@", separator, - [SWGApiClient escape:key], value]]; + counter += 1; } } diff --git a/samples/client/petstore/objc/client/SWGPetApi.m b/samples/client/petstore/objc/client/SWGPetApi.m index 5d134bb1f27..a52077eeab3 100644 --- a/samples/client/petstore/objc/client/SWGPetApi.m +++ b/samples/client/petstore/objc/client/SWGPetApi.m @@ -1,5 +1,6 @@ #import "SWGPetApi.h" #import "SWGFile.h" +#import "SWGQueryParamCollection.h" #import "SWGApiClient.h" #import "SWGPet.h" #import "SWGFile.h" @@ -230,8 +231,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; NSString* responseContentType = @"application/json"; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - if(status != nil) - queryParams[@"status"] = status; + if(status != nil) { + + queryParams[@"status"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: status format: @"multi"]; + + + } NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; @@ -303,8 +308,12 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; NSString* responseContentType = @"application/json"; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - if(tags != nil) - queryParams[@"tags"] = tags; + if(tags != nil) { + + queryParams[@"tags"] = [[SWGQueryParamCollection alloc] initWithValuesAndFormat: tags format: @"multi"]; + + + } NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init]; diff --git a/samples/client/petstore/objc/client/SWGQueryParamCollection.h b/samples/client/petstore/objc/client/SWGQueryParamCollection.h new file mode 100644 index 00000000000..26b830875f0 --- /dev/null +++ b/samples/client/petstore/objc/client/SWGQueryParamCollection.h @@ -0,0 +1,9 @@ +@interface SWGQueryParamCollection : NSObject + +@property(nonatomic, readonly) NSArray* values; +@property(nonatomic, readonly) NSString* format; + +- (id) initWithValuesAndFormat: (NSArray*) values + format: (NSString*) format; + +@end diff --git a/samples/client/petstore/objc/client/SWGQueryParamCollection.m b/samples/client/petstore/objc/client/SWGQueryParamCollection.m new file mode 100644 index 00000000000..9ce319940dd --- /dev/null +++ b/samples/client/petstore/objc/client/SWGQueryParamCollection.m @@ -0,0 +1,16 @@ +#import "SWGQueryParamCollection.h" + +@implementation SWGQueryParamCollection + +@synthesize values = _values; +@synthesize format = _format; + +- (id) initWithValuesAndFormat: (NSArray*) values + format: (NSString*) format { + _values = values; + _format = format; + + return self; +} + +@end \ No newline at end of file diff --git a/samples/client/petstore/objc/client/SWGStoreApi.m b/samples/client/petstore/objc/client/SWGStoreApi.m index 3eb015ebc0a..65d47519438 100644 --- a/samples/client/petstore/objc/client/SWGStoreApi.m +++ b/samples/client/petstore/objc/client/SWGStoreApi.m @@ -1,5 +1,6 @@ #import "SWGStoreApi.h" #import "SWGFile.h" +#import "SWGQueryParamCollection.h" #import "SWGApiClient.h" #import "SWGOrder.h" diff --git a/samples/client/petstore/objc/client/SWGUserApi.m b/samples/client/petstore/objc/client/SWGUserApi.m index 6e33862d111..85037247af7 100644 --- a/samples/client/petstore/objc/client/SWGUserApi.m +++ b/samples/client/petstore/objc/client/SWGUserApi.m @@ -1,5 +1,6 @@ #import "SWGUserApi.h" #import "SWGFile.h" +#import "SWGQueryParamCollection.h" #import "SWGApiClient.h" #import "SWGUser.h" @@ -311,10 +312,14 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; NSString* responseContentType = @"application/json"; NSMutableDictionary* queryParams = [[NSMutableDictionary alloc] init]; - if(username != nil) + if(username != nil) { + queryParams[@"username"] = username; - if(password != nil) + } + if(password != nil) { + queryParams[@"password"] = password; + } NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];