forked from loafle/openapi-generator-original
Support for extended 'application/json' HeaderAccept types
This commit is contained in:
parent
258bb27f30
commit
a01dfb693b
@ -128,24 +128,22 @@ static void (^reachabilityChangeBlock)(int);
|
|||||||
/*
|
/*
|
||||||
* Detect `Accept` from accepts
|
* Detect `Accept` from accepts
|
||||||
*/
|
*/
|
||||||
+ (NSString *) selectHeaderAccept:(NSArray *)accepts
|
+ (NSString *) selectHeaderAccept:(NSArray *)accepts {
|
||||||
{
|
|
||||||
if (accepts == nil || [accepts count] == 0) {
|
if (accepts == nil || [accepts count] == 0) {
|
||||||
return @"";
|
return @"";
|
||||||
}
|
}
|
||||||
|
|
||||||
NSMutableArray *lowerAccepts = [[NSMutableArray alloc] initWithCapacity:[accepts count]];
|
NSMutableArray *lowerAccepts = [[NSMutableArray alloc] initWithCapacity:[accepts count]];
|
||||||
[accepts enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
for (NSString *string in accepts) {
|
||||||
[lowerAccepts addObject:[obj lowercaseString]];
|
NSString * lowerAccept = [string lowercaseString];
|
||||||
}];
|
if([lowerAccept containsString:@"application/json"]) {
|
||||||
|
return @"application/json";
|
||||||
|
}
|
||||||
if ([lowerAccepts containsObject:@"application/json"]) {
|
[lowerAccepts addObject:lowerAccept];
|
||||||
return @"application/json";
|
|
||||||
}
|
}
|
||||||
else {
|
if(lowerAccepts.count == 1){
|
||||||
return [lowerAccepts componentsJoinedByString:@", "];
|
return [lowerAccepts firstObject];
|
||||||
}
|
}
|
||||||
|
return [lowerAccepts componentsJoinedByString:@", "];
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user