[Objc] Add customizable user-agent #2715

This commit is contained in:
Mateusz Mackowiak 2016-06-01 15:51:52 +02:00
parent 7b6747e6f3
commit 2ead00c96d
2 changed files with 4 additions and 2 deletions

View File

@ -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;

View File

@ -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;