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
|
||||
*/
|
||||
+ (NSString *) selectHeaderAccept:(NSArray *)accepts
|
||||
{
|
||||
+ (NSString *) selectHeaderAccept:(NSArray *)accepts {
|
||||
if (accepts == nil || [accepts count] == 0) {
|
||||
return @"";
|
||||
}
|
||||
|
||||
NSMutableArray *lowerAccepts = [[NSMutableArray alloc] initWithCapacity:[accepts count]];
|
||||
[accepts enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||
[lowerAccepts addObject:[obj lowercaseString]];
|
||||
}];
|
||||
|
||||
|
||||
if ([lowerAccepts containsObject:@"application/json"]) {
|
||||
for (NSString *string in accepts) {
|
||||
NSString * lowerAccept = [string lowercaseString];
|
||||
if([lowerAccept containsString:@"application/json"]) {
|
||||
return @"application/json";
|
||||
}
|
||||
else {
|
||||
return [lowerAccepts componentsJoinedByString:@", "];
|
||||
[lowerAccepts addObject:lowerAccept];
|
||||
}
|
||||
if(lowerAccepts.count == 1){
|
||||
return [lowerAccepts firstObject];
|
||||
}
|
||||
return [lowerAccepts componentsJoinedByString:@", "];
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
x
Reference in New Issue
Block a user