Skip to content

Commit 8555028

Browse files
committed
Merge pull request #3017 from mateuszmackowiak/objc/user_agent
[Objc] Add customizable user-agent #2715
2 parents 36a8ed2 + 2ead00c commit 8555028

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
@implementation {{classPrefix}}Configuration
1212

13-
#pragma mark - Singletion Methods
13+
#pragma mark - Singleton Methods
1414

1515
+ (instancetype) sharedConfig {
1616
static {{classPrefix}}Configuration *shardConfig = nil;
@@ -35,6 +35,7 @@
3535
self.mutableApiKey = [NSMutableDictionary dictionary];
3636
self.mutableApiKeyPrefix = [NSMutableDictionary dictionary];
3737
self.mutableDefaultHeaders = [NSMutableDictionary dictionary];
38+
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}};
3839
self.logger = [{{classPrefix}}Logger sharedLogger];
3940
}
4041
return self;

samples/client/petstore/objc/SwaggerClient/Core/SWGConfiguration.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ @interface SWGConfiguration ()
1010

1111
@implementation SWGConfiguration
1212

13-
#pragma mark - Singletion Methods
13+
#pragma mark - Singleton Methods
1414

1515
+ (instancetype) sharedConfig {
1616
static SWGConfiguration *shardConfig = nil;
@@ -35,6 +35,7 @@ - (instancetype) init {
3535
self.mutableApiKey = [NSMutableDictionary dictionary];
3636
self.mutableApiKeyPrefix = [NSMutableDictionary dictionary];
3737
self.mutableDefaultHeaders = [NSMutableDictionary dictionary];
38+
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]];
3839
self.logger = [SWGLogger sharedLogger];
3940
}
4041
return self;

0 commit comments

Comments
 (0)