Support pure object response for objc client

This commit is contained in:
geekerzp 2015-06-13 10:17:08 +08:00
parent c50c8b724d
commit a6bdc35d59
5 changed files with 17 additions and 1 deletions

View File

@ -364,6 +364,11 @@ static bool loggingEnabled = true;
class = [class substringToIndex:[class length] - 1];
}
// pure object
if ([class isEqualToString:@"NSObject"]) {
return [[NSObject alloc] init];
}
// list of models
NSString *arrayOfModelsPat = @"NSArray<(.+)>";
regexp = [NSRegularExpression regularExpressionWithPattern:arrayOfModelsPat

View File

@ -32,7 +32,7 @@
XCTFail(@"failed to fetch inventory");
}
NSSet *expectKeys = [NSSet setWithArray:@[@"confused", @"string", @"pending", @"available", @"sold"]];
NSSet *expectKeys = [NSSet setWithArray:@[@"confused", @"string", @"available"]];
NSSet *keys = [NSSet setWithArray:[output allKeys]];
XCTAssertEqualObjects(expectKeys, keys);

View File

@ -158,6 +158,11 @@
XCTAssertTrue([result isKindOfClass:[NSDictionary class]]);
XCTAssertTrue([result[@"pet"] isKindOfClass:[SWGPet class]]);
XCTAssertEqualObjects([result[@"pet"] _id], @119);
// pure object
result = [self.apiClient deserialize:nil class:@"NSObject*"];
XCTAssertTrue([result isKindOfClass:[NSObject class]]);
}
@end

View File

@ -364,6 +364,11 @@ static bool loggingEnabled = true;
class = [class substringToIndex:[class length] - 1];
}
// pure object
if ([class isEqualToString:@"NSObject"]) {
return [[NSObject alloc] init];
}
// list of models
NSString *arrayOfModelsPat = @"NSArray<(.+)>";
regexp = [NSRegularExpression regularExpressionWithPattern:arrayOfModelsPat

View File

@ -81,6 +81,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
{
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/inventory", basePath];
// remove format in URL if needed