forked from loafle/openapi-generator-original
Merge pull request #644 from hyeghiazaryan/develop_2.0
Adding defaultHeaders dictionary to generated API classes.
This commit is contained in:
commit
39602c4b2b
@ -7,6 +7,9 @@
|
|||||||
{{/imports}}
|
{{/imports}}
|
||||||
{{newline}}
|
{{newline}}
|
||||||
|
|
||||||
|
@interface {{classname}} ()
|
||||||
|
@property (readwrite, nonatomic, strong) NSMutableDictionary *defaultHeaders;
|
||||||
|
@end
|
||||||
|
|
||||||
@implementation {{classname}}
|
@implementation {{classname}}
|
||||||
static NSString * basePath = @"{{basePath}}";
|
static NSString * basePath = @"{{basePath}}";
|
||||||
@ -34,18 +37,19 @@ static NSString * basePath = @"{{basePath}}";
|
|||||||
}
|
}
|
||||||
|
|
||||||
-(void) addHeader:(NSString*)value forKey:(NSString*)key {
|
-(void) addHeader:(NSString*)value forKey:(NSString*)key {
|
||||||
[[self apiClient] setHeaderValue:value forKey:key];
|
[self.defaultHeaders setValue:value forKey:key];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(id) init {
|
-(id) init {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
|
self.defaultHeaders = [NSMutableDictionary dictionary];
|
||||||
[self apiClient];
|
[self apiClient];
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
-(void) setHeaderValue:(NSString*) value
|
-(void) setHeaderValue:(NSString*) value
|
||||||
forKey:(NSString*)key {
|
forKey:(NSString*)key {
|
||||||
[[self apiClient] setHeaderValue:value forKey:key];
|
[self.defaultHeaders setValue:value forKey:key];
|
||||||
}
|
}
|
||||||
|
|
||||||
-(unsigned long) requestQueueSize {
|
-(unsigned long) requestQueueSize {
|
||||||
@ -82,7 +86,8 @@ static NSString * basePath = @"{{basePath}}";
|
|||||||
{{^collectionFormat}}queryParams[@"{{baseName}}"] = {{paramName}};{{/collectionFormat}}
|
{{^collectionFormat}}queryParams[@"{{baseName}}"] = {{paramName}};{{/collectionFormat}}
|
||||||
}
|
}
|
||||||
{{/queryParams}}
|
{{/queryParams}}
|
||||||
NSMutableDictionary* headerParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
{{#headerParams}}if({{paramName}} != nil)
|
{{#headerParams}}if({{paramName}} != nil)
|
||||||
headerParams[@"{{baseName}}"] = {{paramName}};
|
headerParams[@"{{baseName}}"] = {{paramName}};
|
||||||
{{/headerParams}}
|
{{/headerParams}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user