forked from loafle/openapi-generator-original
Update objc client.
Replace SWGFile with NSURL.
This commit is contained in:
@@ -36,6 +36,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
defaultIncludes.add("bool");
|
||||
defaultIncludes.add("BOOL");
|
||||
defaultIncludes.add("int");
|
||||
defaultIncludes.add("NSURL");
|
||||
defaultIncludes.add("NSString");
|
||||
defaultIncludes.add("NSObject");
|
||||
defaultIncludes.add("NSArray");
|
||||
@@ -50,6 +51,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
languageSpecificPrimitives.add("NSString");
|
||||
languageSpecificPrimitives.add("NSObject");
|
||||
languageSpecificPrimitives.add("NSDate");
|
||||
languageSpecificPrimitives.add("NSURL");
|
||||
languageSpecificPrimitives.add("bool");
|
||||
languageSpecificPrimitives.add("BOOL");
|
||||
|
||||
@@ -69,7 +71,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("number", "NSNumber");
|
||||
typeMapping.put("List", "NSArray");
|
||||
typeMapping.put("object", "NSObject");
|
||||
typeMapping.put("file", "File");
|
||||
typeMapping.put("file", "NSURL");
|
||||
|
||||
// ref: http://www.tutorialspoint.com/objective_c/objective_c_basic_syntax.htm
|
||||
reservedWords = new HashSet<String>(
|
||||
@@ -97,6 +99,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
"NSObject",
|
||||
"NSString",
|
||||
"NSDate",
|
||||
"NSURL",
|
||||
"NSDictionary")
|
||||
);
|
||||
|
||||
@@ -156,8 +159,6 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
supportingFiles.add(new SupportingFile("JSONResponseSerializer-body.mustache", swaggerFolder, classPrefix + "JSONResponseSerializer.m"));
|
||||
supportingFiles.add(new SupportingFile("JSONRequestSerializer-body.mustache", swaggerFolder, classPrefix + "JSONRequestSerializer.m"));
|
||||
supportingFiles.add(new SupportingFile("JSONRequestSerializer-header.mustache", swaggerFolder, classPrefix + "JSONRequestSerializer.h"));
|
||||
supportingFiles.add(new SupportingFile("File-header.mustache", swaggerFolder, classPrefix + "File.h"));
|
||||
supportingFiles.add(new SupportingFile("File-body.mustache", swaggerFolder, classPrefix + "File.m"));
|
||||
supportingFiles.add(new SupportingFile("JSONValueTransformer+ISO8601.m", swaggerFolder, "JSONValueTransformer+ISO8601.m"));
|
||||
supportingFiles.add(new SupportingFile("JSONValueTransformer+ISO8601.h", swaggerFolder, "JSONValueTransformer+ISO8601.h"));
|
||||
supportingFiles.add(new SupportingFile("Configuration-body.mustache", swaggerFolder, classPrefix + "Configuration.m"));
|
||||
|
||||
@@ -348,16 +348,6 @@ static bool loggingEnabled = true;
|
||||
*querys = [NSDictionary dictionaryWithDictionary:querysWithAuth];
|
||||
}
|
||||
|
||||
#pragma mark - Predicate methods
|
||||
|
||||
- (BOOL) isDownloadFile:(NSString *)responseType {
|
||||
if ([responseType isEqualToString:@"{{classPrefix}}File*"]) {
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Deserialize methods
|
||||
|
||||
- (id) deserialize:(id) data class:(NSString *) class {
|
||||
@@ -542,10 +532,11 @@ static bool loggingEnabled = true;
|
||||
else {
|
||||
filename = [NSString stringWithFormat:@"%@", [[NSProcessInfo processInfo] globallyUniqueString]];
|
||||
}
|
||||
|
||||
|
||||
NSString *filepath = [directory stringByAppendingPathComponent:filename];
|
||||
NSURL *file = [NSURL fileURLWithPath:filepath];
|
||||
|
||||
{{classPrefix}}File *file = [[{{classPrefix}}File alloc] initWithPath:filepath data:operation.responseData name:filename];
|
||||
[operation.responseData writeToURL:file atomically:YES];
|
||||
completionBlock(file, nil);
|
||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||
|
||||
@@ -573,6 +564,8 @@ static bool loggingEnabled = true;
|
||||
-(NSNumber*) requestWithCompletionBlock: (NSString*) path
|
||||
method: (NSString*) method
|
||||
queryParams: (NSDictionary*) queryParams
|
||||
formParams: (NSDictionary *) formParams
|
||||
files: (NSDictionary *) files
|
||||
body: (id) body
|
||||
headerParams: (NSDictionary*) headerParams
|
||||
authSettings: (NSArray *) authSettings
|
||||
@@ -606,66 +599,38 @@ static bool loggingEnabled = true;
|
||||
[self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings];
|
||||
|
||||
NSMutableURLRequest * request = nil;
|
||||
if (body != nil && [body isKindOfClass:[NSArray class]]){
|
||||
{{classPrefix}}File * file;
|
||||
NSMutableDictionary * params = [[NSMutableDictionary alloc] init];
|
||||
for(id obj in body) {
|
||||
if([obj isKindOfClass:[{{classPrefix}}File class]]) {
|
||||
file = ({{classPrefix}}File*) obj;
|
||||
requestContentType = @"multipart/form-data";
|
||||
}
|
||||
else if([obj isKindOfClass:[NSDictionary class]]) {
|
||||
for(NSString * key in obj) {
|
||||
params[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
NSString * urlString = [[NSURL URLWithString:path relativeToURL:self.baseURL] absoluteString];
|
||||
|
||||
// request with multipart form
|
||||
if([requestContentType isEqualToString:@"multipart/form-data"]) {
|
||||
request = [self.requestSerializer multipartFormRequestWithMethod: @"POST"
|
||||
URLString: urlString
|
||||
parameters: nil
|
||||
constructingBodyWithBlock: ^(id<AFMultipartFormData> formData) {
|
||||
|
||||
for(NSString * key in params) {
|
||||
NSData* data = [params[key] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[formData appendPartWithFormData: data name: key];
|
||||
}
|
||||
|
||||
if (file) {
|
||||
[formData appendPartWithFileData: [file data]
|
||||
name: [file paramName]
|
||||
fileName: [file name]
|
||||
mimeType: [file mimeType]];
|
||||
}
|
||||
|
||||
}
|
||||
error:nil];
|
||||
}
|
||||
// request with form parameters or json
|
||||
else {
|
||||
NSString* pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams];
|
||||
NSString* urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString];
|
||||
|
||||
request = [self.requestSerializer requestWithMethod:method
|
||||
URLString:urlString
|
||||
parameters:params
|
||||
error:nil];
|
||||
}
|
||||
|
||||
NSString* pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams];
|
||||
NSString* urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString];
|
||||
if (files.count > 0) {
|
||||
request = [self.requestSerializer multipartFormRequestWithMethod:@"POST"
|
||||
URLString:urlString
|
||||
parameters:nil
|
||||
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
|
||||
[formParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||
NSData *data = [obj dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[formData appendPartWithFormData:data name:key];
|
||||
}];
|
||||
[files enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||
NSURL *filePath = (NSURL *)obj;
|
||||
[formData appendPartWithFileURL:filePath name:key error:nil];
|
||||
}];
|
||||
} error:nil];
|
||||
}
|
||||
else {
|
||||
NSString * pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams];
|
||||
NSString * urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString];
|
||||
|
||||
request = [self.requestSerializer requestWithMethod: method
|
||||
URLString: urlString
|
||||
parameters: body
|
||||
error: nil];
|
||||
if (formParams) {
|
||||
request = [self.requestSerializer requestWithMethod:method
|
||||
URLString:urlString
|
||||
parameters:formParams
|
||||
error:nil];
|
||||
}
|
||||
if (body) {
|
||||
request = [self.requestSerializer requestWithMethod:method
|
||||
URLString:urlString
|
||||
parameters:body
|
||||
error:nil];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOL hasHeaderParams = false;
|
||||
if(headerParams != nil && [headerParams count] > 0) {
|
||||
hasHeaderParams = true;
|
||||
@@ -695,7 +660,7 @@ static bool loggingEnabled = true;
|
||||
[request setHTTPShouldHandleCookies:NO];
|
||||
|
||||
NSNumber* requestId = [{{classPrefix}}ApiClient queueRequest];
|
||||
if ([self isDownloadFile:responseType]) {
|
||||
if ([responseType isEqualToString:@"NSURL*"]) {
|
||||
[self downloadOperationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) {
|
||||
completionBlock(data, error);
|
||||
}];
|
||||
@@ -709,3 +674,7 @@ static bool loggingEnabled = true;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#import <AFNetworking/AFHTTPRequestOperationManager.h>
|
||||
#import "{{classPrefix}}JSONResponseSerializer.h"
|
||||
#import "{{classPrefix}}JSONRequestSerializer.h"
|
||||
#import "{{classPrefix}}File.h"
|
||||
#import "{{classPrefix}}QueryParamCollection.h"
|
||||
#import "{{classPrefix}}Configuration.h"
|
||||
|
||||
@@ -194,6 +193,8 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
|
||||
-(NSNumber*) requestWithCompletionBlock:(NSString*) path
|
||||
method:(NSString*) method
|
||||
queryParams:(NSDictionary*) queryParams
|
||||
formParams:(NSDictionary *) formParams
|
||||
files:(NSDictionary *) files
|
||||
body:(id) body
|
||||
headerParams:(NSDictionary*) headerParams
|
||||
authSettings: (NSArray *) authSettings
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
#import "{{classPrefix}}File.h"
|
||||
|
||||
@implementation {{classPrefix}}File
|
||||
|
||||
- (id) init {
|
||||
self = [super init];
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithNameData: (NSString*) filename
|
||||
mimeType: (NSString*) fileMimeType
|
||||
data: (NSData*) data {
|
||||
self = [super init];
|
||||
if(self) {
|
||||
_name = filename;
|
||||
_mimeType = fileMimeType;
|
||||
_data = data;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) initWithPath:(NSString *)filepath data:(NSData *)data name:(NSString *)filename {
|
||||
self = [super init];
|
||||
|
||||
if (self) {
|
||||
_name = filename;
|
||||
_data = data;
|
||||
_path = filepath;
|
||||
[data writeToFile:_path atomically:YES];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,45 +0,0 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface {{classPrefix}}File : NSObject
|
||||
|
||||
/**
|
||||
* File name
|
||||
*/
|
||||
@property(nonatomic, readonly) NSString* name;
|
||||
|
||||
/**
|
||||
* File mimeType, for `multipart/form` post
|
||||
*/
|
||||
@property(nonatomic, readonly) NSString* mimeType;
|
||||
|
||||
/**
|
||||
* File data
|
||||
*/
|
||||
@property(nonatomic, readonly) NSData* data;
|
||||
|
||||
/**
|
||||
* File field parameter name, for `multipart/form` post
|
||||
*/
|
||||
@property(nonatomic) NSString* paramName;
|
||||
|
||||
/**
|
||||
* File path
|
||||
*/
|
||||
@property(nonatomic, readonly) NSString *path;
|
||||
|
||||
/**
|
||||
* Initialize with `filename`, `mimeType`, `filedata`.
|
||||
*/
|
||||
- (id) initWithNameData: (NSString*) filename
|
||||
mimeType: (NSString*) mimeType
|
||||
data: (NSData*) data;
|
||||
|
||||
/**
|
||||
* Initialize with `filepath`, `filedata`, `filename`
|
||||
* and write file data into file path.
|
||||
*/
|
||||
- (id) initWithPath: (NSString *) filepath
|
||||
data: (NSData *) data
|
||||
name: (NSString *) filename;
|
||||
|
||||
@end
|
||||
@@ -139,6 +139,8 @@ static NSString * basePath = @"{{basePath}}";
|
||||
NSArray *authSettings = @[{{#authMethods}}@"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}}];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
{{#bodyParam}}
|
||||
bodyParam = {{paramName}};
|
||||
|
||||
@@ -157,28 +159,13 @@ static NSString * basePath = @"{{basePath}}";
|
||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyParam = [({{classPrefix}}Object*)bodyParam toDictionary];
|
||||
}
|
||||
{{/bodyParam}}
|
||||
{{^bodyParam}}
|
||||
|
||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||
|
||||
{{/bodyParam}}{{^bodyParam}}
|
||||
{{#formParams}}
|
||||
{{#notFile}}
|
||||
formParams[@"{{paramName}}"] = {{paramName}};
|
||||
{{/notFile}}{{#isFile}}
|
||||
requestContentType = @"multipart/form-data";
|
||||
if(bodyParam == nil) {
|
||||
bodyParam = [[NSMutableArray alloc] init];
|
||||
}
|
||||
if({{paramName}} != nil) {
|
||||
[bodyParam addObject:{{paramName}}];
|
||||
{{paramName}}.paramName = @"{{baseName}}";
|
||||
}
|
||||
files[@"{{paramName}}"] = {{paramName}};
|
||||
{{/isFile}}
|
||||
if(bodyParam == nil) {
|
||||
bodyParam = [[NSMutableArray alloc] init];
|
||||
}
|
||||
[bodyParam addObject:formParams];
|
||||
{{/formParams}}
|
||||
{{/bodyParam}}
|
||||
|
||||
@@ -192,6 +179,8 @@ static NSString * basePath = @"{{basePath}}";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"{{httpMethod}}"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#import <AFNetworking/AFHTTPRequestOperationManager.h>
|
||||
#import "SWGJSONResponseSerializer.h"
|
||||
#import "SWGJSONRequestSerializer.h"
|
||||
#import "SWGFile.h"
|
||||
#import "SWGQueryParamCollection.h"
|
||||
#import "SWGConfiguration.h"
|
||||
|
||||
@@ -198,6 +197,8 @@ extern NSString *const SWGResponseObjectErrorKey;
|
||||
-(NSNumber*) requestWithCompletionBlock:(NSString*) path
|
||||
method:(NSString*) method
|
||||
queryParams:(NSDictionary*) queryParams
|
||||
formParams:(NSDictionary *) formParams
|
||||
files:(NSDictionary *) files
|
||||
body:(id) body
|
||||
headerParams:(NSDictionary*) headerParams
|
||||
authSettings: (NSArray *) authSettings
|
||||
|
||||
@@ -348,16 +348,6 @@ static bool loggingEnabled = true;
|
||||
*querys = [NSDictionary dictionaryWithDictionary:querysWithAuth];
|
||||
}
|
||||
|
||||
#pragma mark - Predicate methods
|
||||
|
||||
- (BOOL) isDownloadFile:(NSString *)responseType {
|
||||
if ([responseType isEqualToString:@"SWGFile*"]) {
|
||||
return YES;
|
||||
} else {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Deserialize methods
|
||||
|
||||
- (id) deserialize:(id) data class:(NSString *) class {
|
||||
@@ -542,10 +532,11 @@ static bool loggingEnabled = true;
|
||||
else {
|
||||
filename = [NSString stringWithFormat:@"%@", [[NSProcessInfo processInfo] globallyUniqueString]];
|
||||
}
|
||||
|
||||
|
||||
NSString *filepath = [directory stringByAppendingPathComponent:filename];
|
||||
NSURL *file = [NSURL fileURLWithPath:filepath];
|
||||
|
||||
SWGFile *file = [[SWGFile alloc] initWithPath:filepath data:operation.responseData name:filename];
|
||||
[operation.responseData writeToURL:file atomically:YES];
|
||||
completionBlock(file, nil);
|
||||
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
|
||||
|
||||
@@ -573,6 +564,8 @@ static bool loggingEnabled = true;
|
||||
-(NSNumber*) requestWithCompletionBlock: (NSString*) path
|
||||
method: (NSString*) method
|
||||
queryParams: (NSDictionary*) queryParams
|
||||
formParams: (NSDictionary *) formParams
|
||||
files: (NSDictionary *) files
|
||||
body: (id) body
|
||||
headerParams: (NSDictionary*) headerParams
|
||||
authSettings: (NSArray *) authSettings
|
||||
@@ -606,66 +599,38 @@ static bool loggingEnabled = true;
|
||||
[self updateHeaderParams:&headerParams queryParams:&queryParams WithAuthSettings:authSettings];
|
||||
|
||||
NSMutableURLRequest * request = nil;
|
||||
if (body != nil && [body isKindOfClass:[NSArray class]]){
|
||||
SWGFile * file;
|
||||
NSMutableDictionary * params = [[NSMutableDictionary alloc] init];
|
||||
for(id obj in body) {
|
||||
if([obj isKindOfClass:[SWGFile class]]) {
|
||||
file = (SWGFile*) obj;
|
||||
requestContentType = @"multipart/form-data";
|
||||
}
|
||||
else if([obj isKindOfClass:[NSDictionary class]]) {
|
||||
for(NSString * key in obj) {
|
||||
params[key] = obj[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
NSString * urlString = [[NSURL URLWithString:path relativeToURL:self.baseURL] absoluteString];
|
||||
|
||||
// request with multipart form
|
||||
if([requestContentType isEqualToString:@"multipart/form-data"]) {
|
||||
request = [self.requestSerializer multipartFormRequestWithMethod: @"POST"
|
||||
URLString: urlString
|
||||
parameters: nil
|
||||
constructingBodyWithBlock: ^(id<AFMultipartFormData> formData) {
|
||||
|
||||
for(NSString * key in params) {
|
||||
NSData* data = [params[key] dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[formData appendPartWithFormData: data name: key];
|
||||
}
|
||||
|
||||
if (file) {
|
||||
[formData appendPartWithFileData: [file data]
|
||||
name: [file paramName]
|
||||
fileName: [file name]
|
||||
mimeType: [file mimeType]];
|
||||
}
|
||||
|
||||
}
|
||||
error:nil];
|
||||
}
|
||||
// request with form parameters or json
|
||||
else {
|
||||
NSString* pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams];
|
||||
NSString* urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString];
|
||||
|
||||
request = [self.requestSerializer requestWithMethod:method
|
||||
URLString:urlString
|
||||
parameters:params
|
||||
error:nil];
|
||||
}
|
||||
|
||||
NSString* pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams];
|
||||
NSString* urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString];
|
||||
if (files.count > 0) {
|
||||
request = [self.requestSerializer multipartFormRequestWithMethod:@"POST"
|
||||
URLString:urlString
|
||||
parameters:nil
|
||||
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
|
||||
[formParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||
NSData *data = [obj dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[formData appendPartWithFormData:data name:key];
|
||||
}];
|
||||
[files enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||
NSURL *filePath = (NSURL *)obj;
|
||||
[formData appendPartWithFileURL:filePath name:key error:nil];
|
||||
}];
|
||||
} error:nil];
|
||||
}
|
||||
else {
|
||||
NSString * pathWithQueryParams = [self pathWithQueryParamsToString:path queryParams:queryParams];
|
||||
NSString * urlString = [[NSURL URLWithString:pathWithQueryParams relativeToURL:self.baseURL] absoluteString];
|
||||
|
||||
request = [self.requestSerializer requestWithMethod: method
|
||||
URLString: urlString
|
||||
parameters: body
|
||||
error: nil];
|
||||
if (formParams) {
|
||||
request = [self.requestSerializer requestWithMethod:method
|
||||
URLString:urlString
|
||||
parameters:formParams
|
||||
error:nil];
|
||||
}
|
||||
if (body) {
|
||||
request = [self.requestSerializer requestWithMethod:method
|
||||
URLString:urlString
|
||||
parameters:body
|
||||
error:nil];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOL hasHeaderParams = false;
|
||||
if(headerParams != nil && [headerParams count] > 0) {
|
||||
hasHeaderParams = true;
|
||||
@@ -695,7 +660,7 @@ static bool loggingEnabled = true;
|
||||
[request setHTTPShouldHandleCookies:NO];
|
||||
|
||||
NSNumber* requestId = [SWGApiClient queueRequest];
|
||||
if ([self isDownloadFile:responseType]) {
|
||||
if ([responseType isEqualToString:@"NSURL*"]) {
|
||||
[self downloadOperationWithCompletionBlock:request requestId:requestId completionBlock:^(id data, NSError *error) {
|
||||
completionBlock(data, error);
|
||||
}];
|
||||
@@ -709,3 +674,7 @@ static bool loggingEnabled = true;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SWGPet.h"
|
||||
#import "SWGFile.h"
|
||||
#import "SWGObject.h"
|
||||
#import "SWGApiClient.h"
|
||||
|
||||
@@ -139,7 +138,7 @@
|
||||
/// @return
|
||||
-(NSNumber*) uploadFileWithCompletionBlock :(NSNumber*) petId
|
||||
additionalMetadata:(NSString*) additionalMetadata
|
||||
file:(SWGFile*) file
|
||||
file:(NSURL*) file
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#import "SWGFile.h"
|
||||
#import "SWGQueryParamCollection.h"
|
||||
#import "SWGPet.h"
|
||||
#import "SWGFile.h"
|
||||
|
||||
|
||||
@interface SWGPetApi ()
|
||||
@@ -123,6 +122,8 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[@"petstore_auth"];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
bodyParam = body;
|
||||
|
||||
@@ -142,12 +143,13 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"PUT"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -211,6 +213,8 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[@"petstore_auth"];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
bodyParam = body;
|
||||
|
||||
@@ -230,12 +234,13 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -305,18 +310,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[@"petstore_auth"];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
|
||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -386,18 +391,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[@"petstore_auth"];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
|
||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -467,18 +472,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[@"api_key", @"petstore_auth"];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
|
||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -554,27 +559,17 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[@"petstore_auth"];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
|
||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||
|
||||
|
||||
|
||||
formParams[@"name"] = name;
|
||||
|
||||
if(bodyParam == nil) {
|
||||
bodyParam = [[NSMutableArray alloc] init];
|
||||
}
|
||||
[bodyParam addObject:formParams];
|
||||
|
||||
|
||||
formParams[@"status"] = status;
|
||||
|
||||
if(bodyParam == nil) {
|
||||
bodyParam = [[NSMutableArray alloc] init];
|
||||
}
|
||||
[bodyParam addObject:formParams];
|
||||
|
||||
|
||||
|
||||
@@ -582,6 +577,8 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -656,18 +653,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[@"petstore_auth"];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
|
||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -694,7 +691,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
///
|
||||
-(NSNumber*) uploadFileWithCompletionBlock: (NSNumber*) petId
|
||||
additionalMetadata: (NSString*) additionalMetadata
|
||||
file: (SWGFile*) file
|
||||
file: (NSURL*) file
|
||||
|
||||
|
||||
completionHandler: (void (^)(NSError* error))completionBlock {
|
||||
@@ -743,34 +740,17 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[@"petstore_auth"];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
|
||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||
|
||||
|
||||
|
||||
formParams[@"additionalMetadata"] = additionalMetadata;
|
||||
|
||||
if(bodyParam == nil) {
|
||||
bodyParam = [[NSMutableArray alloc] init];
|
||||
}
|
||||
[bodyParam addObject:formParams];
|
||||
|
||||
|
||||
requestContentType = @"multipart/form-data";
|
||||
if(bodyParam == nil) {
|
||||
bodyParam = [[NSMutableArray alloc] init];
|
||||
}
|
||||
if(file != nil) {
|
||||
[bodyParam addObject:file];
|
||||
file.paramName = @"file";
|
||||
}
|
||||
files[@"file"] = file;
|
||||
|
||||
if(bodyParam == nil) {
|
||||
bodyParam = [[NSMutableArray alloc] init];
|
||||
}
|
||||
[bodyParam addObject:formParams];
|
||||
|
||||
|
||||
|
||||
@@ -778,6 +758,8 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
|
||||
@@ -119,18 +119,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[@"api_key"];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
|
||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -194,6 +194,8 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
bodyParam = body;
|
||||
|
||||
@@ -213,12 +215,13 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -288,18 +291,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
|
||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -369,18 +372,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
|
||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
|
||||
@@ -122,6 +122,8 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
bodyParam = body;
|
||||
|
||||
@@ -141,12 +143,13 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -210,6 +213,8 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
bodyParam = body;
|
||||
|
||||
@@ -229,12 +234,13 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -298,6 +304,8 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
bodyParam = body;
|
||||
|
||||
@@ -317,12 +325,13 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -397,18 +406,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
|
||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -469,18 +478,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
|
||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -550,18 +559,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
|
||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -634,6 +643,8 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
bodyParam = body;
|
||||
|
||||
@@ -653,12 +664,13 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"PUT"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
@@ -728,18 +740,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyParam = nil;
|
||||
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
|
||||
NSMutableDictionary *files = [[NSMutableDictionary alloc] init];
|
||||
|
||||
|
||||
|
||||
NSMutableDictionary * formParams = [[NSMutableDictionary alloc]init];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
formParams: formParams
|
||||
files: files
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
|
||||
<false/>
|
||||
<key>IDESourceControlProjectIdentifier</key>
|
||||
<string>303FE0A9-4715-4C57-8D01-F604EF82CF6D</string>
|
||||
<key>IDESourceControlProjectName</key>
|
||||
<string>SwaggerClient</string>
|
||||
<key>IDESourceControlProjectOriginsDictionary</key>
|
||||
<dict>
|
||||
<key>E5BBF0AA85077C865C95437976D06D819733A208</key>
|
||||
<string>https://github.com/geekerzp/swagger-codegen.git</string>
|
||||
</dict>
|
||||
<key>IDESourceControlProjectPath</key>
|
||||
<string>samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj</string>
|
||||
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
|
||||
<dict>
|
||||
<key>E5BBF0AA85077C865C95437976D06D819733A208</key>
|
||||
<string>../../../../../../..</string>
|
||||
</dict>
|
||||
<key>IDESourceControlProjectURL</key>
|
||||
<string>https://github.com/geekerzp/swagger-codegen.git</string>
|
||||
<key>IDESourceControlProjectVersion</key>
|
||||
<integer>111</integer>
|
||||
<key>IDESourceControlProjectWCCIdentifier</key>
|
||||
<string>E5BBF0AA85077C865C95437976D06D819733A208</string>
|
||||
<key>IDESourceControlProjectWCConfigurations</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
|
||||
<string>public.vcs.git</string>
|
||||
<key>IDESourceControlWCCIdentifierKey</key>
|
||||
<string>E5BBF0AA85077C865C95437976D06D819733A208</string>
|
||||
<key>IDESourceControlWCCName</key>
|
||||
<string>swagger-codegen</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
Binary file not shown.
@@ -219,14 +219,11 @@
|
||||
}
|
||||
|
||||
- (void)testUploadFile {
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"testUploadFile"];
|
||||
|
||||
NSString* str = @"teststring";
|
||||
NSData* data = [str dataUsingEncoding:NSUTF8StringEncoding];
|
||||
XCTestExpectation *expectation = [self expectationWithDescription:@"testUploadWithFile"];
|
||||
|
||||
SWGFile * file = [[SWGFile alloc] initWithNameData: @"myFile.txt" mimeType:@"text/plain" data:data];
|
||||
NSURL *fileURL = [self createTempFile];
|
||||
|
||||
[api uploadFileWithCompletionBlock:@1 additionalMetadata:@"special-metadata" file:file completionHandler:^(NSError *error) {
|
||||
[api uploadFileWithCompletionBlock:@1 additionalMetadata:@"special-metadata" file:fileURL completionHandler:^(NSError *error) {
|
||||
if(error) {
|
||||
// good
|
||||
XCTFail(@"expected a failure");
|
||||
@@ -278,4 +275,12 @@
|
||||
pet.photoUrls = photos;
|
||||
return pet;
|
||||
}
|
||||
|
||||
- (NSURL *) createTempFile {
|
||||
NSString *filePath = [NSTemporaryDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"%@", [[NSProcessInfo processInfo] globallyUniqueString]]];
|
||||
NSData *data = [@"test string" dataUsingEncoding:NSUTF8StringEncoding];
|
||||
[data writeToFile:filePath atomically:YES];
|
||||
|
||||
return [NSURL fileURLWithPath:filePath];
|
||||
}
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user