mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 19:33:55 +00:00
Adding defaultHeaders dictionary to generated API classes. defaultHeaders will be merged with headerParams before sending the request.
fix for https://github.com/swagger-api/swagger-codegen/issues/638
This commit is contained in:
parent
21fcbc7acb
commit
33dfcd247d
@ -7,6 +7,9 @@
|
||||
{{/imports}}
|
||||
{{newline}}
|
||||
|
||||
@interface {{classname}} ()
|
||||
@property (readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders;
|
||||
@end
|
||||
|
||||
@implementation {{classname}}
|
||||
static NSString * basePath = @"{{basePath}}";
|
||||
@ -34,18 +37,19 @@ static NSString * basePath = @"{{basePath}}";
|
||||
}
|
||||
|
||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key {
|
||||
[[self apiClient] setHeaderValue:value forKey:key];
|
||||
[self.defaultHeaders setValue:value forKey:key];
|
||||
}
|
||||
|
||||
-(id) init {
|
||||
self = [super init];
|
||||
self.defaultHeaders = [NSMutableDictionary dictionary];
|
||||
[self apiClient];
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void) setHeaderValue:(NSString*) value
|
||||
forKey:(NSString*)key {
|
||||
[[self apiClient] setHeaderValue:value forKey:key];
|
||||
[self.defaultHeaders setValue:value forKey:key];
|
||||
}
|
||||
|
||||
-(unsigned long) requestQueueSize {
|
||||
@ -82,7 +86,8 @@ static NSString * basePath = @"{{basePath}}";
|
||||
{{^collectionFormat}}queryParams[@"{{baseName}}"] = {{paramName}};{{/collectionFormat}}
|
||||
}
|
||||
{{/queryParams}}
|
||||
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||
|
||||
{{#headerParams}}if({{paramName}} != nil)
|
||||
headerParams[@"{{baseName}}"] = {{paramName}};
|
||||
{{/headerParams}}
|
||||
|
Loading…
Reference in New Issue
Block a user