From 2ead00c96d9d24372e6b827c6f1e1e2a3414fd8c Mon Sep 17 00:00:00 2001 From: Mateusz Mackowiak Date: Wed, 1 Jun 2016 15:51:52 +0200 Subject: [PATCH] [Objc] Add customizable user-agent #2715 --- .../src/main/resources/objc/Configuration-body.mustache | 3 ++- .../client/petstore/objc/SwaggerClient/Core/SWGConfiguration.m | 3 ++- 2 files changed, 4 insertions(+), 2 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 e37551bf8a1..1aeca25dd3e 100644 --- a/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache @@ -10,7 +10,7 @@ @implementation {{classPrefix}}Configuration -#pragma mark - Singletion Methods +#pragma mark - Singleton Methods + (instancetype) sharedConfig { static {{classPrefix}}Configuration *shardConfig = nil; @@ -35,6 +35,7 @@ self.mutableApiKey = [NSMutableDictionary dictionary]; self.mutableApiKeyPrefix = [NSMutableDictionary dictionary]; self.mutableDefaultHeaders = [NSMutableDictionary dictionary]; + self.mutableDefaultHeaders[@"User-Agent"] = {{#httpUserAgent}}@"{{httpUserAgent}}"{{/httpUserAgent}}{{^httpUserAgent}}[NSString stringWithFormat:@"Swagger-Codegen/{{version}}/objc (%@; iOS %@; Scale/%0.2f)",[[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]]{{/httpUserAgent}}; self.logger = [{{classPrefix}}Logger sharedLogger]; } return self; diff --git a/samples/client/petstore/objc/SwaggerClient/Core/SWGConfiguration.m b/samples/client/petstore/objc/SwaggerClient/Core/SWGConfiguration.m index cd8d6e7aeef..24172638bba 100644 --- a/samples/client/petstore/objc/SwaggerClient/Core/SWGConfiguration.m +++ b/samples/client/petstore/objc/SwaggerClient/Core/SWGConfiguration.m @@ -10,7 +10,7 @@ @implementation SWGConfiguration -#pragma mark - Singletion Methods +#pragma mark - Singleton Methods + (instancetype) sharedConfig { static SWGConfiguration *shardConfig = nil; @@ -35,6 +35,7 @@ self.mutableApiKey = [NSMutableDictionary dictionary]; self.mutableApiKeyPrefix = [NSMutableDictionary dictionary]; self.mutableDefaultHeaders = [NSMutableDictionary dictionary]; + self.mutableDefaultHeaders[@"User-Agent"] = [NSString stringWithFormat:@"Swagger-Codegen/1.0.0/objc (%@; iOS %@; Scale/%0.2f)",[[UIDevice currentDevice] model], [[UIDevice currentDevice] systemVersion], [[UIScreen mainScreen] scale]]; self.logger = [SWGLogger sharedLogger]; } return self;