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 d1e227ce744..9020a5f8170 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 @@ -122,6 +122,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("SWGFile.m", sourceFolder, "SWGFile.m")); supportingFiles.add(new SupportingFile("JSONValueTransformer+ISO8601.m", sourceFolder, "JSONValueTransformer+ISO8601.m")); supportingFiles.add(new SupportingFile("JSONValueTransformer+ISO8601.h", sourceFolder, "JSONValueTransformer+ISO8601.h")); + supportingFiles.add(new SupportingFile("SWGConfiguration-body.mustache", sourceFolder, "SWGConfiguration.m")); + supportingFiles.add(new SupportingFile("SWGConfiguration-header.mustache", sourceFolder, "SWGConfiguration.h")); supportingFiles.add(new SupportingFile("Podfile.mustache", "", "Podfile")); } diff --git a/modules/swagger-codegen/src/main/resources/objc/SWGApiClient.h b/modules/swagger-codegen/src/main/resources/objc/SWGApiClient.h index cd6f52db5c6..d1f9203f180 100644 --- a/modules/swagger-codegen/src/main/resources/objc/SWGApiClient.h +++ b/modules/swagger-codegen/src/main/resources/objc/SWGApiClient.h @@ -54,11 +54,16 @@ extern NSString *const SWGResponseObjectErrorKey; -(void)setHeaderValue:(NSString*) value forKey:(NSString*) forKey; +- (void) updateHeaderParams:(NSDictionary **)headers + queryParams:(NSDictionary **)querys + WithAuthSettings:(NSArray *)authSettings; + -(NSNumber*) dictionary:(NSString*) path method:(NSString*) method queryParams:(NSDictionary*) queryParams body:(id) body headerParams:(NSDictionary*) headerParams + authSettings: (NSArray *) authSettings requestContentType:(NSString*) requestContentType responseContentType:(NSString*) responseContentType completionBlock:(void (^)(NSDictionary*, NSError *))completionBlock; @@ -68,8 +73,18 @@ extern NSString *const SWGResponseObjectErrorKey; queryParams:(NSDictionary*) queryParams body:(id) body headerParams:(NSDictionary*) headerParams + authSettings: (NSArray *) authSettings requestContentType:(NSString*) requestContentType responseContentType:(NSString*) responseContentType completionBlock:(void (^)(NSString*, NSError *))completionBlock; @end + + + + + + + + + diff --git a/modules/swagger-codegen/src/main/resources/objc/SWGApiClient.m b/modules/swagger-codegen/src/main/resources/objc/SWGApiClient.m index b38b02e0e03..5e2985bbe79 100644 --- a/modules/swagger-codegen/src/main/resources/objc/SWGApiClient.m +++ b/modules/swagger-codegen/src/main/resources/objc/SWGApiClient.m @@ -1,6 +1,7 @@ #import "SWGApiClient.h" #import "SWGFile.h" #import "SWGQueryParamCollection.h" +#import "SWGConfiguration.h" @implementation SWGApiClient @@ -15,10 +16,22 @@ static NSOperationQueue* sharedQueue; static void (^reachabilityChangeBlock)(int); static bool loggingEnabled = true; +#pragma mark - Log Methods + +(void)setLoggingEnabled:(bool) state { loggingEnabled = state; } +- (void)logRequest:(NSURLRequest*)request { + NSLog(@"request: %@", [self descriptionForRequest:request]); +} + +- (void)logResponse:(id)data forRequest:(NSURLRequest*)request error:(NSError*)error { + NSLog(@"request: %@ response: %@ ", [self descriptionForRequest:request], data ); +} + +#pragma mark - + +(void)clearCache { [[NSURLCache sharedURLCache] removeAllCachedResponses]; } @@ -305,19 +318,47 @@ static bool loggingEnabled = true; return [[request URL] absoluteString]; } -- (void)logRequest:(NSURLRequest*)request { - NSLog(@"request: %@", [self descriptionForRequest:request]); + +/** + * Update header and query params based on authentication settings + */ +- (void) updateHeaderParams:(NSDictionary *__autoreleasing *)headers + queryParams:(NSDictionary *__autoreleasing *)querys + WithAuthSettings:(NSArray *)authSettings { + + if (!authSettings || [authSettings count] == 0) { + return; + } + + NSMutableDictionary *headersWithAuth = [NSMutableDictionary dictionaryWithDictionary:*headers]; + NSMutableDictionary *querysWithAuth = [NSMutableDictionary dictionaryWithDictionary:*querys]; + + SWGConfiguration *config = [SWGConfiguration sharedConfig]; + for (NSString *auth in authSettings) { + NSDictionary *authSetting = [[config authSettings] objectForKey:auth]; + + if (authSetting) { + if ([authSetting[@"in"] isEqualToString:@"header"]) { + [headersWithAuth setObject:authSetting[@"value"] forKey:authSetting[@"key"]]; + } + else if ([authSetting[@"in"] isEqualToString:@"query"]) { + [querysWithAuth setObject:authSetting[@"value"] forKey:authSetting[@"key"]]; + } + } + } + + *headers = [NSDictionary dictionaryWithDictionary:headersWithAuth]; + *querys = [NSDictionary dictionaryWithDictionary:querysWithAuth]; } -- (void)logResponse:(id)data forRequest:(NSURLRequest*)request error:(NSError*)error { - NSLog(@"request: %@ response: %@ ", [self descriptionForRequest:request], data ); -} +#pragma mark - Perform Request Methods -(NSNumber*) dictionary: (NSString*) path method: (NSString*) method queryParams: (NSDictionary*) queryParams body: (id) body headerParams: (NSDictionary*) headerParams + authSettings: (NSArray *) authSettings requestContentType: (NSString*) requestContentType responseContentType: (NSString*) responseContentType completionBlock: (void (^)(NSDictionary*, NSError *))completionBlock { @@ -342,6 +383,9 @@ static bool loggingEnabled = true; else { self.responseSerializer = [AFHTTPResponseSerializer serializer]; } + + // auth setting + [self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings]; NSMutableURLRequest * request = nil; if (body != nil && [body isKindOfClass:[NSArray class]]){ @@ -476,6 +520,7 @@ static bool loggingEnabled = true; queryParams: (NSDictionary*) queryParams body: (id) body headerParams: (NSDictionary*) headerParams + authSettings: (NSArray *) authSettings requestContentType: (NSString*) requestContentType responseContentType: (NSString*) responseContentType completionBlock: (void (^)(NSString*, NSError *))completionBlock { @@ -500,6 +545,9 @@ static bool loggingEnabled = true; else { self.responseSerializer = [AFHTTPResponseSerializer serializer]; } + + // auth setting + [self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings]; NSMutableURLRequest * request = nil; if (body != nil && [body isKindOfClass:[NSArray class]]){ diff --git a/modules/swagger-codegen/src/main/resources/objc/SWGConfiguration-body.mustache b/modules/swagger-codegen/src/main/resources/objc/SWGConfiguration-body.mustache new file mode 100644 index 00000000000..b326244fe0a --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/objc/SWGConfiguration-body.mustache @@ -0,0 +1,91 @@ +#import "SWGConfiguration.h" + +@interface SWGConfiguration () + +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableApiKey; +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableApiKeyPrefix; + +@end + +@implementation SWGConfiguration + +#pragma mark - Singletion Methods + ++ (instancetype) sharedConfig { + static SWGConfiguration *shardConfig = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + shardConfig = [[self alloc] init]; + }); + return shardConfig; +} + +#pragma mark - Initialize Methods + +- (instancetype) init { + self = [super init]; + if (self) { + self.username = @""; + self.password = @""; + self.mutableApiKey = [NSMutableDictionary dictionary]; + self.mutableApiKeyPrefix = [NSMutableDictionary dictionary]; + } + return self; +} + +#pragma mark - Instance Methods + +- (NSString *) getApiKeyWithPrefix:(NSString *)key { + if ([self.apiKeyPrefix objectForKey:key] && [self.apiKey objectForKey:key]) { + return [NSString stringWithFormat:@"%@ %@", [self.apiKeyPrefix objectForKey:key], [self.apiKey objectForKey:key]]; + } + else if ([self.apiKey objectForKey:key]) { + return [NSString stringWithFormat:@"%@", [self.apiKey objectForKey:key]]; + } + else { + return @""; + } +} + +#pragma mark - Setter Methods + +- (void) setValue:(NSString *)value forApiKeyField:(NSString *)field { + [self.mutableApiKey setValue:value forKey:field]; +} + +- (void) setValue:(NSString *)value forApiKeyPrefixField:(NSString *)field { + [self.mutableApiKeyPrefix setValue:value forKey:field]; +} + +#pragma mark - Getter Methods + +- (NSDictionary *) apiKey { + return [NSDictionary dictionaryWithDictionary:self.mutableApiKey]; +} + +- (NSDictionary *) apiKeyPrefix { + return [NSDictionary dictionaryWithDictionary:self.mutableApiKeyPrefix]; +} + +#pragma mark - + +- (NSDictionary *) authSettings { + return @{ {{#authMethods}}{{#isApiKey}} + @"{{name}}": @{ + @"type": @"api_key", + @"in": {{#isKeyInHeader}}@"header"{{/isKeyInHeader}}{{#isKeyInQuery}}@"query"{{/isKeyInQuery}}, + @"key": @"{{keyParamName}}", + @"value": [self getApiKeyWithPrefix:@"{{keyParamName}}"] + }, + {{/isApiKey}}{{#isBasic}} + @"{{name}}": @{ + @"type": @"basic", + @"in": @"header", + @"key": @"Authorization", + @"value": [self getBasicAuthToken] + }, + {{/isBasic}}{{/authMethods}} + }; +} + +@end diff --git a/modules/swagger-codegen/src/main/resources/objc/SWGConfiguration-header.mustache b/modules/swagger-codegen/src/main/resources/objc/SWGConfiguration-header.mustache new file mode 100644 index 00000000000..0ddac56acdf --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/objc/SWGConfiguration-header.mustache @@ -0,0 +1,51 @@ +#import + +@interface SWGConfiguration : NSObject + + +/** + * Api key values for Api Key type Authentication + * + * To add or remove api key, use `setValue:forApiKeyField:`. + */ +@property (readonly, nonatomic, strong) NSDictionary *apiKey; + +/** + * Api key prefix values to be prepend to the respective api key + * + * To add or remove prefix, use `setValue:forApiKeyPrefixField:`. + */ +@property (readonly, nonatomic, strong) NSDictionary *apiKeyPrefix; + +/** + * Usename and Password for Basic type Authentication + */ +@property (nonatomic) NSString *username; +@property (nonatomic) NSString *password; + +/** + * Get configuration singleton instance + */ ++ (instancetype) sharedConfig; + +/** + * Sets field in `apiKey` + */ +- (void) setValue:(NSString *)value forApiKeyField:(NSString*)field; + +/** + * Sets field in `apiKeyPrefix` + */ +- (void) setValue:(NSString *)value forApiKeyPrefixField:(NSString *)field; + +/** + * Get API key (with prefix if set) + */ +- (NSString *) getApiKeyWithPrefix:(NSString *) key; + +/** + * Get Authentication Setings + */ +- (NSDictionary *) authSettings; + +@end diff --git a/modules/swagger-codegen/src/main/resources/objc/SWGQueryParamCollection.m b/modules/swagger-codegen/src/main/resources/objc/SWGQueryParamCollection.m index 9ce319940dd..83303045185 100644 --- a/modules/swagger-codegen/src/main/resources/objc/SWGQueryParamCollection.m +++ b/modules/swagger-codegen/src/main/resources/objc/SWGQueryParamCollection.m @@ -13,4 +13,4 @@ return self; } -@end \ No newline at end of file +@end 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 abe4376d1ac..40d75bd806b 100644 --- a/modules/swagger-codegen/src/main/resources/objc/api-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/api-body.mustache @@ -39,6 +39,8 @@ static NSString * basePath = @"{{basePath}}"; return self; } +#pragma mark - + +({{classname}}*) apiWithHeader:(NSString*)headerValue key:(NSString*)key { static {{classname}}* singletonAPI = nil; @@ -129,6 +131,9 @@ static NSString * basePath = @"{{basePath}}"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[{{#consumes}}@"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}]]; + // Authentication setting + NSArray *authSettings = @[{{#authMethods}}@"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}}]; + id bodyDictionary = nil; {{#bodyParam}} id __body = {{paramName}}; diff --git a/modules/swagger-codegen/src/main/resources/objc/api-header.mustache b/modules/swagger-codegen/src/main/resources/objc/api-header.mustache index 4d571f756ce..65f4c39e0b3 100644 --- a/modules/swagger-codegen/src/main/resources/objc/api-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/api-header.mustache @@ -10,6 +10,7 @@ @property(nonatomic, assign)SWGApiClient *apiClient; +-(instancetype) initWithApiClient:(SWGApiClient *)apiClient; -(void) addHeader:(NSString*)value forKey:(NSString*)key; -(unsigned long) requestQueueSize; +({{classname}}*) apiWithHeader:(NSString*)headerValue key:(NSString*)key; diff --git a/modules/swagger-codegen/src/main/resources/objc/apiBodyResponseWithContainer.mustache b/modules/swagger-codegen/src/main/resources/objc/apiBodyResponseWithContainer.mustache index 5aabef86841..acaeaf2ddf5 100644 --- a/modules/swagger-codegen/src/main/resources/objc/apiBodyResponseWithContainer.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/apiBodyResponseWithContainer.mustache @@ -4,6 +4,7 @@ queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSDictionary *data, NSError *error) { diff --git a/modules/swagger-codegen/src/main/resources/objc/apiNonPrimitiveResponse.mustache b/modules/swagger-codegen/src/main/resources/objc/apiNonPrimitiveResponse.mustache index 81cf1343e53..da8ea063bfb 100644 --- a/modules/swagger-codegen/src/main/resources/objc/apiNonPrimitiveResponse.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/apiNonPrimitiveResponse.mustache @@ -5,6 +5,7 @@ queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSDictionary *data, NSError *error) { diff --git a/modules/swagger-codegen/src/main/resources/objc/apiPrimitiveResponse.mustache b/modules/swagger-codegen/src/main/resources/objc/apiPrimitiveResponse.mustache index 3d6b105f227..d44d356526d 100644 --- a/modules/swagger-codegen/src/main/resources/objc/apiPrimitiveResponse.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/apiPrimitiveResponse.mustache @@ -4,6 +4,7 @@ queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSString *data, NSError *error) { diff --git a/modules/swagger-codegen/src/main/resources/objc/voidResponse.mustache b/modules/swagger-codegen/src/main/resources/objc/voidResponse.mustache index ab4062a6dbe..7bbbc14c066 100644 --- a/modules/swagger-codegen/src/main/resources/objc/voidResponse.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/voidResponse.mustache @@ -3,6 +3,7 @@ queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSString *data, NSError *error) { diff --git a/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.pbxproj b/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.pbxproj index 723caec2cdb..5c1bfabf608 100644 --- a/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.pbxproj +++ b/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ BA525648922D4C0E9F44D4F1 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 73DA4F1067C343C3962F1542 /* libPods.a */; }; + CF0560EB1B1855CF00C0D4EC /* SWGConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = CF0560EA1B1855CF00C0D4EC /* SWGConfiguration.m */; }; CF31D0991B105E4B00509935 /* SWGApiClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CF31D0981B105E4B00509935 /* SWGApiClientTest.m */; }; CFD1B6701B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m in Sources */ = {isa = PBXBuildFile; fileRef = CFD1B66F1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m */; }; CFD1B6711B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m in Sources */ = {isa = PBXBuildFile; fileRef = CFD1B66F1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m */; }; @@ -56,6 +57,8 @@ /* Begin PBXFileReference section */ 73DA4F1067C343C3962F1542 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; A425648B5C0A4849C7668069 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "../Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; + CF0560E91B1855CF00C0D4EC /* SWGConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWGConfiguration.h; sourceTree = ""; }; + CF0560EA1B1855CF00C0D4EC /* SWGConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGConfiguration.m; sourceTree = ""; }; CF31D0981B105E4B00509935 /* SWGApiClientTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGApiClientTest.m; sourceTree = ""; }; CFD1B66E1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "JSONValueTransformer+ISO8601.h"; sourceTree = ""; }; CFD1B66F1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "JSONValueTransformer+ISO8601.m"; sourceTree = ""; }; @@ -234,6 +237,8 @@ EA8B8AA31AC6683700638FBB /* SWGQueryParamCollection.m */, EAEA85CC1811D3AE00F06E69 /* SWGApiClient.h */, EAEA85CD1811D3AE00F06E69 /* SWGApiClient.m */, + CF0560E91B1855CF00C0D4EC /* SWGConfiguration.h */, + CF0560EA1B1855CF00C0D4EC /* SWGConfiguration.m */, EAEA85CE1811D3AE00F06E69 /* SWGCategory.h */, EAEA85CF1811D3AE00F06E69 /* SWGCategory.m */, EAEA85D21811D3AE00F06E69 /* SWGFile.h */, @@ -395,6 +400,7 @@ buildActionMask = 2147483647; files = ( EAEA85E51811D3AE00F06E69 /* SWGCategory.m in Sources */, + CF0560EB1B1855CF00C0D4EC /* SWGConfiguration.m in Sources */, EAEA85ED1811D3AE00F06E69 /* SWGTag.m in Sources */, EA6699B31811D2FA00A70D03 /* ViewController.m in Sources */, EA6699AA1811D2FA00A70D03 /* AppDelegate.m in Sources */, diff --git a/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/xcuserdata/geekerzp.xcuserdatad/xcschemes/PetstoreClient.xcscheme b/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/xcuserdata/geekerzp.xcuserdatad/xcschemes/PetstoreClient.xcscheme new file mode 100644 index 00000000000..1a2a738abea --- /dev/null +++ b/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/xcuserdata/geekerzp.xcuserdatad/xcschemes/PetstoreClient.xcscheme @@ -0,0 +1,112 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/xcuserdata/geekerzp.xcuserdatad/xcschemes/xcschememanagement.plist b/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/xcuserdata/geekerzp.xcuserdatad/xcschemes/xcschememanagement.plist new file mode 100644 index 00000000000..912710bdccc --- /dev/null +++ b/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/xcuserdata/geekerzp.xcuserdatad/xcschemes/xcschememanagement.plist @@ -0,0 +1,27 @@ + + + + + SchemeUserState + + PetstoreClient.xcscheme + + orderHint + 4 + + + SuppressBuildableAutocreation + + EA6699951811D2FA00A70D03 + + primary + + + EA6699B91811D2FB00A70D03 + + primary + + + + + diff --git a/samples/client/petstore/objc/PetstoreClient/PetstoreClient/ViewController.m b/samples/client/petstore/objc/PetstoreClient/PetstoreClient/ViewController.m index 7c47bb1f271..d56bc037206 100644 --- a/samples/client/petstore/objc/PetstoreClient/PetstoreClient/ViewController.m +++ b/samples/client/petstore/objc/PetstoreClient/PetstoreClient/ViewController.m @@ -8,6 +8,7 @@ #import "ViewController.h" #import "SWGPetApi.h" +#import "SWGConfiguration.h" @interface ViewController () @@ -53,6 +54,14 @@ // } ]; */ + SWGConfiguration *config = [SWGConfiguration sharedConfig]; + config.username = @"foo"; + config.password = @"bar"; + SWGPetApi *api = [[SWGPetApi alloc] init]; + [api addPetWithCompletionBlock:nil + completionHandler:^(NSError *error) { + + }]; } - (void)didReceiveMemoryWarning diff --git a/samples/client/petstore/objc/PetstoreClient/PetstoreClientTests/SWGApiClientTest.m b/samples/client/petstore/objc/PetstoreClient/PetstoreClientTests/SWGApiClientTest.m index 0464bf569e9..61925b16960 100644 --- a/samples/client/petstore/objc/PetstoreClient/PetstoreClientTests/SWGApiClientTest.m +++ b/samples/client/petstore/objc/PetstoreClient/PetstoreClientTests/SWGApiClientTest.m @@ -1,16 +1,19 @@ #import #import #import "SWGApiClient.h" +#import "SWGConfiguration.h" @interface SWGApiClientTest : XCTestCase +@property (nonatomic) SWGApiClient *apiClient; + @end @implementation SWGApiClientTest - (void)setUp { [super setUp]; - // Put setup code here. This method is called before the invocation of each test method in the class. + self.apiClient = [[SWGApiClient alloc] init]; } - (void)tearDown { @@ -56,4 +59,43 @@ XCTAssertEqualObjects([SWGApiClient selectHeaderContentType:contentTypes], @"application/json"); } +- (void)testConfiguration { + SWGConfiguration *config = [SWGConfiguration sharedConfig]; + [config setValue:@"123456" forApiKeyField:@"api_key"]; + [config setValue:@"PREFIX" forApiKeyPrefixField:@"api_key"]; + config.username = @"test_username"; + config.password = @"test_password"; + + NSDictionary *headerParams = @{@"test1": @"value1"}; + NSDictionary *queryParams = @{@"test2": @"value2"}; + NSArray *authSettings = @[@"api_key", @"unknown"]; + + // test prefix + XCTAssertEqualObjects(@"PREFIX", config.apiKeyPrefix[@"api_key"]); + [self.apiClient updateHeaderParams:&headerParams + queryParams:&queryParams + WithAuthSettings:authSettings]; + + // test api key auth + XCTAssertEqualObjects(headerParams[@"test1"], @"value1"); + XCTAssertEqualObjects(headerParams[@"api_key"], @"PREFIX 123456"); + XCTAssertEqualObjects(queryParams[@"test2"], @"value2"); + + // test basic auth + XCTAssertEqualObjects(@"test_username", config.username); + XCTAssertEqualObjects(@"test_password", config.password); +} + +- (void)testGetBasicAuthToken { + SWGConfiguration *config = [SWGConfiguration sharedConfig]; + config.username = @"test_username"; + config.password = @"test_password"; + + NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", config.username, config.password]; + NSData *data = [basicAuthCredentials dataUsingEncoding:NSUTF8StringEncoding]; + basicAuthCredentials = [NSString stringWithFormat:@"Basic %@", [data base64EncodedStringWithOptions:0]]; + + XCTAssertEqualObjects(basicAuthCredentials, [config getBasicAuthToken]); +} + @end diff --git a/samples/client/petstore/objc/Podfile.lock b/samples/client/petstore/objc/Podfile.lock index 6ac776ab37a..48b1f809658 100644 --- a/samples/client/petstore/objc/Podfile.lock +++ b/samples/client/petstore/objc/Podfile.lock @@ -20,7 +20,7 @@ PODS: - AFNetworking/UIKit (2.5.4): - AFNetworking/NSURLConnection - AFNetworking/NSURLSession - - ISO8601 (0.2.0) + - ISO8601 (0.3.0) - JSONModel (1.1.0) DEPENDENCIES: @@ -30,7 +30,7 @@ DEPENDENCIES: SPEC CHECKSUMS: AFNetworking: 05edc0ac4c4c8cf57bcf4b84be5b0744b6d8e71e - ISO8601: 962282de75074c38bbfaa7b133b0e743ed6deb8d + ISO8601: 8d8a22d5edf0554a1cf75bac028c76c1dc0ffaef JSONModel: ec77e9865236a7a09d9cf7668df6b4b328d9ec1d COCOAPODS: 0.37.1 diff --git a/samples/client/petstore/objc/client/SWGApiClient.h b/samples/client/petstore/objc/client/SWGApiClient.h index cd6f52db5c6..d1f9203f180 100644 --- a/samples/client/petstore/objc/client/SWGApiClient.h +++ b/samples/client/petstore/objc/client/SWGApiClient.h @@ -54,11 +54,16 @@ extern NSString *const SWGResponseObjectErrorKey; -(void)setHeaderValue:(NSString*) value forKey:(NSString*) forKey; +- (void) updateHeaderParams:(NSDictionary **)headers + queryParams:(NSDictionary **)querys + WithAuthSettings:(NSArray *)authSettings; + -(NSNumber*) dictionary:(NSString*) path method:(NSString*) method queryParams:(NSDictionary*) queryParams body:(id) body headerParams:(NSDictionary*) headerParams + authSettings: (NSArray *) authSettings requestContentType:(NSString*) requestContentType responseContentType:(NSString*) responseContentType completionBlock:(void (^)(NSDictionary*, NSError *))completionBlock; @@ -68,8 +73,18 @@ extern NSString *const SWGResponseObjectErrorKey; queryParams:(NSDictionary*) queryParams body:(id) body headerParams:(NSDictionary*) headerParams + authSettings: (NSArray *) authSettings requestContentType:(NSString*) requestContentType responseContentType:(NSString*) responseContentType completionBlock:(void (^)(NSString*, NSError *))completionBlock; @end + + + + + + + + + diff --git a/samples/client/petstore/objc/client/SWGApiClient.m b/samples/client/petstore/objc/client/SWGApiClient.m index b38b02e0e03..5e2985bbe79 100644 --- a/samples/client/petstore/objc/client/SWGApiClient.m +++ b/samples/client/petstore/objc/client/SWGApiClient.m @@ -1,6 +1,7 @@ #import "SWGApiClient.h" #import "SWGFile.h" #import "SWGQueryParamCollection.h" +#import "SWGConfiguration.h" @implementation SWGApiClient @@ -15,10 +16,22 @@ static NSOperationQueue* sharedQueue; static void (^reachabilityChangeBlock)(int); static bool loggingEnabled = true; +#pragma mark - Log Methods + +(void)setLoggingEnabled:(bool) state { loggingEnabled = state; } +- (void)logRequest:(NSURLRequest*)request { + NSLog(@"request: %@", [self descriptionForRequest:request]); +} + +- (void)logResponse:(id)data forRequest:(NSURLRequest*)request error:(NSError*)error { + NSLog(@"request: %@ response: %@ ", [self descriptionForRequest:request], data ); +} + +#pragma mark - + +(void)clearCache { [[NSURLCache sharedURLCache] removeAllCachedResponses]; } @@ -305,19 +318,47 @@ static bool loggingEnabled = true; return [[request URL] absoluteString]; } -- (void)logRequest:(NSURLRequest*)request { - NSLog(@"request: %@", [self descriptionForRequest:request]); + +/** + * Update header and query params based on authentication settings + */ +- (void) updateHeaderParams:(NSDictionary *__autoreleasing *)headers + queryParams:(NSDictionary *__autoreleasing *)querys + WithAuthSettings:(NSArray *)authSettings { + + if (!authSettings || [authSettings count] == 0) { + return; + } + + NSMutableDictionary *headersWithAuth = [NSMutableDictionary dictionaryWithDictionary:*headers]; + NSMutableDictionary *querysWithAuth = [NSMutableDictionary dictionaryWithDictionary:*querys]; + + SWGConfiguration *config = [SWGConfiguration sharedConfig]; + for (NSString *auth in authSettings) { + NSDictionary *authSetting = [[config authSettings] objectForKey:auth]; + + if (authSetting) { + if ([authSetting[@"in"] isEqualToString:@"header"]) { + [headersWithAuth setObject:authSetting[@"value"] forKey:authSetting[@"key"]]; + } + else if ([authSetting[@"in"] isEqualToString:@"query"]) { + [querysWithAuth setObject:authSetting[@"value"] forKey:authSetting[@"key"]]; + } + } + } + + *headers = [NSDictionary dictionaryWithDictionary:headersWithAuth]; + *querys = [NSDictionary dictionaryWithDictionary:querysWithAuth]; } -- (void)logResponse:(id)data forRequest:(NSURLRequest*)request error:(NSError*)error { - NSLog(@"request: %@ response: %@ ", [self descriptionForRequest:request], data ); -} +#pragma mark - Perform Request Methods -(NSNumber*) dictionary: (NSString*) path method: (NSString*) method queryParams: (NSDictionary*) queryParams body: (id) body headerParams: (NSDictionary*) headerParams + authSettings: (NSArray *) authSettings requestContentType: (NSString*) requestContentType responseContentType: (NSString*) responseContentType completionBlock: (void (^)(NSDictionary*, NSError *))completionBlock { @@ -342,6 +383,9 @@ static bool loggingEnabled = true; else { self.responseSerializer = [AFHTTPResponseSerializer serializer]; } + + // auth setting + [self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings]; NSMutableURLRequest * request = nil; if (body != nil && [body isKindOfClass:[NSArray class]]){ @@ -476,6 +520,7 @@ static bool loggingEnabled = true; queryParams: (NSDictionary*) queryParams body: (id) body headerParams: (NSDictionary*) headerParams + authSettings: (NSArray *) authSettings requestContentType: (NSString*) requestContentType responseContentType: (NSString*) responseContentType completionBlock: (void (^)(NSString*, NSError *))completionBlock { @@ -500,6 +545,9 @@ static bool loggingEnabled = true; else { self.responseSerializer = [AFHTTPResponseSerializer serializer]; } + + // auth setting + [self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings]; NSMutableURLRequest * request = nil; if (body != nil && [body isKindOfClass:[NSArray class]]){ diff --git a/samples/client/petstore/objc/client/SWGConfiguration.h b/samples/client/petstore/objc/client/SWGConfiguration.h new file mode 100644 index 00000000000..0ddac56acdf --- /dev/null +++ b/samples/client/petstore/objc/client/SWGConfiguration.h @@ -0,0 +1,51 @@ +#import + +@interface SWGConfiguration : NSObject + + +/** + * Api key values for Api Key type Authentication + * + * To add or remove api key, use `setValue:forApiKeyField:`. + */ +@property (readonly, nonatomic, strong) NSDictionary *apiKey; + +/** + * Api key prefix values to be prepend to the respective api key + * + * To add or remove prefix, use `setValue:forApiKeyPrefixField:`. + */ +@property (readonly, nonatomic, strong) NSDictionary *apiKeyPrefix; + +/** + * Usename and Password for Basic type Authentication + */ +@property (nonatomic) NSString *username; +@property (nonatomic) NSString *password; + +/** + * Get configuration singleton instance + */ ++ (instancetype) sharedConfig; + +/** + * Sets field in `apiKey` + */ +- (void) setValue:(NSString *)value forApiKeyField:(NSString*)field; + +/** + * Sets field in `apiKeyPrefix` + */ +- (void) setValue:(NSString *)value forApiKeyPrefixField:(NSString *)field; + +/** + * Get API key (with prefix if set) + */ +- (NSString *) getApiKeyWithPrefix:(NSString *) key; + +/** + * Get Authentication Setings + */ +- (NSDictionary *) authSettings; + +@end diff --git a/samples/client/petstore/objc/client/SWGConfiguration.m b/samples/client/petstore/objc/client/SWGConfiguration.m new file mode 100644 index 00000000000..f98c5f081de --- /dev/null +++ b/samples/client/petstore/objc/client/SWGConfiguration.m @@ -0,0 +1,91 @@ +#import "SWGConfiguration.h" + +@interface SWGConfiguration () + +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableApiKey; +@property (readwrite, nonatomic, strong) NSMutableDictionary *mutableApiKeyPrefix; + +@end + +@implementation SWGConfiguration + +#pragma mark - Singletion Methods + ++ (instancetype) sharedConfig { + static SWGConfiguration *shardConfig = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + shardConfig = [[self alloc] init]; + }); + return shardConfig; +} + +#pragma mark - Initialize Methods + +- (instancetype) init { + self = [super init]; + if (self) { + self.username = @""; + self.password = @""; + self.mutableApiKey = [NSMutableDictionary dictionary]; + self.mutableApiKeyPrefix = [NSMutableDictionary dictionary]; + } + return self; +} + +#pragma mark - Instance Methods + +- (NSString *) getApiKeyWithPrefix:(NSString *)key { + if ([self.apiKeyPrefix objectForKey:key] && [self.apiKey objectForKey:key]) { + return [NSString stringWithFormat:@"%@ %@", [self.apiKeyPrefix objectForKey:key], [self.apiKey objectForKey:key]]; + } + else if ([self.apiKey objectForKey:key]) { + return [NSString stringWithFormat:@"%@", [self.apiKey objectForKey:key]]; + } + else { + return @""; + } +} + +#pragma mark - Setter Methods + +- (void) setValue:(NSString *)value forApiKeyField:(NSString *)field { + [self.mutableApiKey setValue:value forKey:field]; +} + +- (void) setValue:(NSString *)value forApiKeyPrefixField:(NSString *)field { + [self.mutableApiKeyPrefix setValue:value forKey:field]; +} + +#pragma mark - Getter Methods + +- (NSDictionary *) apiKey { + return [NSDictionary dictionaryWithDictionary:self.mutableApiKey]; +} + +- (NSDictionary *) apiKeyPrefix { + return [NSDictionary dictionaryWithDictionary:self.mutableApiKeyPrefix]; +} + +#pragma mark - + +- (NSDictionary *) authSettings { + return @{ + @"api_key": @{ + @"type": @"api_key", + @"in": @"header", + @"key": @"api_key", + @"value": [self getApiKeyWithPrefix:@"api_key"] + }, + + @"basic_auth": @{ + @"type": @"basic", + @"in": @"header", + @"key": @"Authorization", + @"value": [self getBasicAuthToken] + }, + + }; +} + +@end diff --git a/samples/client/petstore/objc/client/SWGPetApi.m b/samples/client/petstore/objc/client/SWGPetApi.m index 9487713984b..0b2c059fb3b 100644 --- a/samples/client/petstore/objc/client/SWGPetApi.m +++ b/samples/client/petstore/objc/client/SWGPetApi.m @@ -38,6 +38,8 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; return self; } +#pragma mark - + +(SWGPetApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key { static SWGPetApi* singletonAPI = nil; @@ -115,6 +117,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; + id bodyDictionary = nil; id __body = body; @@ -160,6 +165,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSString *data, NSError *error) { @@ -218,6 +224,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; + // Authentication setting + NSArray *authSettings = @[@"basic_auth"]; + id bodyDictionary = nil; id __body = body; @@ -263,6 +272,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSString *data, NSError *error) { @@ -327,6 +337,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; + id bodyDictionary = nil; @@ -346,6 +359,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSDictionary *data, NSError *error) { @@ -427,6 +441,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; + id bodyDictionary = nil; @@ -446,6 +463,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSDictionary *data, NSError *error) { @@ -525,6 +543,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // Authentication setting + NSArray *authSettings = @[@"api_key", @"petstore_auth"]; + id bodyDictionary = nil; @@ -552,6 +573,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSDictionary *data, NSError *error) { @@ -627,6 +649,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/x-www-form-urlencoded"]]; + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; + id bodyDictionary = nil; @@ -665,6 +690,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSString *data, NSError *error) { @@ -731,6 +757,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; + id bodyDictionary = nil; @@ -753,6 +782,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSString *data, NSError *error) { @@ -819,6 +849,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"multipart/form-data"]]; + // Authentication setting + NSArray *authSettings = @[@"petstore_auth"]; + id bodyDictionary = nil; @@ -864,6 +897,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSString *data, NSError *error) { diff --git a/samples/client/petstore/objc/client/SWGQueryParamCollection.m b/samples/client/petstore/objc/client/SWGQueryParamCollection.m index 9ce319940dd..83303045185 100644 --- a/samples/client/petstore/objc/client/SWGQueryParamCollection.m +++ b/samples/client/petstore/objc/client/SWGQueryParamCollection.m @@ -13,4 +13,4 @@ return self; } -@end \ No newline at end of file +@end diff --git a/samples/client/petstore/objc/client/SWGStoreApi.h b/samples/client/petstore/objc/client/SWGStoreApi.h index c2d0dd6b36b..49d8db806c8 100644 --- a/samples/client/petstore/objc/client/SWGStoreApi.h +++ b/samples/client/petstore/objc/client/SWGStoreApi.h @@ -8,6 +8,7 @@ @property(nonatomic, assign)SWGApiClient *apiClient; +-(instancetype) initWithApiClient:(SWGApiClient *)apiClient; -(void) addHeader:(NSString*)value forKey:(NSString*)key; -(unsigned long) requestQueueSize; +(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key; diff --git a/samples/client/petstore/objc/client/SWGStoreApi.m b/samples/client/petstore/objc/client/SWGStoreApi.m index 98b9d9a4eec..a112db6d639 100644 --- a/samples/client/petstore/objc/client/SWGStoreApi.m +++ b/samples/client/petstore/objc/client/SWGStoreApi.m @@ -37,6 +37,8 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; return self; } +#pragma mark - + +(SWGStoreApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key { static SWGStoreApi* singletonAPI = nil; @@ -112,6 +114,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // Authentication setting + NSArray *authSettings = @[@"api_key"]; + id bodyDictionary = nil; @@ -131,6 +136,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSDictionary *data, NSError *error) { @@ -199,6 +205,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // Authentication setting + NSArray *authSettings = @[]; + id bodyDictionary = nil; id __body = body; @@ -249,6 +258,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSDictionary *data, NSError *error) { @@ -320,6 +330,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // Authentication setting + NSArray *authSettings = @[]; + id bodyDictionary = nil; @@ -347,6 +360,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSDictionary *data, NSError *error) { @@ -418,6 +432,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // Authentication setting + NSArray *authSettings = @[]; + id bodyDictionary = nil; @@ -440,6 +457,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSString *data, NSError *error) { diff --git a/samples/client/petstore/objc/client/SWGUserApi.h b/samples/client/petstore/objc/client/SWGUserApi.h index d9d5a8abc18..e6e73ddfba6 100644 --- a/samples/client/petstore/objc/client/SWGUserApi.h +++ b/samples/client/petstore/objc/client/SWGUserApi.h @@ -8,6 +8,7 @@ @property(nonatomic, assign)SWGApiClient *apiClient; +-(instancetype) initWithApiClient:(SWGApiClient *)apiClient; -(void) addHeader:(NSString*)value forKey:(NSString*)key; -(unsigned long) requestQueueSize; +(SWGUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key; diff --git a/samples/client/petstore/objc/client/SWGUserApi.m b/samples/client/petstore/objc/client/SWGUserApi.m index 97a79f01b6d..e2fe69aca8d 100644 --- a/samples/client/petstore/objc/client/SWGUserApi.m +++ b/samples/client/petstore/objc/client/SWGUserApi.m @@ -37,6 +37,8 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; return self; } +#pragma mark - + +(SWGUserApi*) apiWithHeader:(NSString*)headerValue key:(NSString*)key { static SWGUserApi* singletonAPI = nil; @@ -114,6 +116,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // Authentication setting + NSArray *authSettings = @[]; + id bodyDictionary = nil; id __body = body; @@ -159,6 +164,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSString *data, NSError *error) { @@ -217,6 +223,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // Authentication setting + NSArray *authSettings = @[]; + id bodyDictionary = nil; id __body = body; @@ -262,6 +271,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSString *data, NSError *error) { @@ -320,6 +330,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // Authentication setting + NSArray *authSettings = @[]; + id bodyDictionary = nil; id __body = body; @@ -365,6 +378,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSString *data, NSError *error) { @@ -433,6 +447,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // Authentication setting + NSArray *authSettings = @[]; + id bodyDictionary = nil; @@ -457,6 +474,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSString *data, NSError *error) { @@ -524,6 +542,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // Authentication setting + NSArray *authSettings = @[]; + id bodyDictionary = nil; @@ -546,6 +567,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSString *data, NSError *error) { @@ -608,6 +630,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // Authentication setting + NSArray *authSettings = @[]; + id bodyDictionary = nil; @@ -635,6 +660,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSDictionary *data, NSError *error) { @@ -708,6 +734,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // Authentication setting + NSArray *authSettings = @[]; + id bodyDictionary = nil; id __body = body; @@ -753,6 +782,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSString *data, NSError *error) { @@ -815,6 +845,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; // request content type NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; + // Authentication setting + NSArray *authSettings = @[]; + id bodyDictionary = nil; @@ -837,6 +870,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2"; queryParams: queryParams body: bodyDictionary headerParams: headerParams + authSettings: authSettings requestContentType: requestContentType responseContentType: responseContentType completionBlock: ^(NSString *data, NSError *error) {