From 732a9eb64d371bed6f1c97ecaf6515e64bac92a4 Mon Sep 17 00:00:00 2001 From: geekerzp Date: Fri, 7 Aug 2015 18:31:07 +0800 Subject: [PATCH] Fix issue in Configuration-body.mustache in objc client --- .../objc/Configuration-body.mustache | 35 +++++++++++++------ .../objc/SwaggerClient/SWGConfiguration.m | 22 ++++++------ 2 files changed, 35 insertions(+), 22 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache b/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache index 75d73d6e414..838d7e49561 100644 --- a/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache @@ -54,7 +54,7 @@ NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", self.username, self.password]; NSData *data = [basicAuthCredentials dataUsingEncoding:NSUTF8StringEncoding]; basicAuthCredentials = [NSString stringWithFormat:@"Basic %@", [data base64EncodedStringWithOptions:0]]; - + return basicAuthCredentials; } @@ -81,7 +81,7 @@ if ([self.loggingFileHanlder isKindOfClass:[NSFileHandle class]]) { [self.loggingFileHanlder closeFile]; } - + _loggingFile = loggingFile; _loggingFileHanlder = [NSFileHandle fileHandleForWritingAtPath:_loggingFile]; if (_loggingFileHanlder == nil) { @@ -103,15 +103,28 @@ #pragma mark - - (NSDictionary *) authSettings { - return @{ - @"api_key": @{ - @"type": @"api_key", - @"in": @"header", - @"key": @"api_key", - @"value": [self getApiKeyWithPrefix:@"api_key"] - }, - - }; + 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/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m index 0e0e70e27ea..b1dabf52f01 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m @@ -54,7 +54,7 @@ NSString *basicAuthCredentials = [NSString stringWithFormat:@"%@:%@", self.username, self.password]; NSData *data = [basicAuthCredentials dataUsingEncoding:NSUTF8StringEncoding]; basicAuthCredentials = [NSString stringWithFormat:@"Basic %@", [data base64EncodedStringWithOptions:0]]; - + return basicAuthCredentials; } @@ -81,7 +81,7 @@ if ([self.loggingFileHanlder isKindOfClass:[NSFileHandle class]]) { [self.loggingFileHanlder closeFile]; } - + _loggingFile = loggingFile; _loggingFileHanlder = [NSFileHandle fileHandleForWritingAtPath:_loggingFile]; if (_loggingFileHanlder == nil) { @@ -103,15 +103,15 @@ #pragma mark - - (NSDictionary *) authSettings { - return @{ - @"api_key": @{ - @"type": @"api_key", - @"in": @"header", - @"key": @"api_key", - @"value": [self getApiKeyWithPrefix:@"api_key"] - }, - - }; + return @{ + @"api_key": + @{ + @"type": @"api_key", + @"in": @"header", + @"key": @"api_key", + @"value": [self getApiKeyWithPrefix:@"api_key"] + }, + }; } @end