forked from loafle/openapi-generator-original
This commit is contained in:
parent
157b07e552
commit
0a652a3d13
@ -70,14 +70,15 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
"double", "protocol", "interface", "implementation",
|
||||
"NSObject", "NSInteger", "NSNumber", "CGFloat",
|
||||
"property", "nonatomic", "retain", "strong",
|
||||
"weak", "unsafe_unretained", "readwrite", "readonly"
|
||||
"weak", "unsafe_unretained", "readwrite", "readonly",
|
||||
"description"
|
||||
));
|
||||
|
||||
typeMapping = new HashMap<String, String>();
|
||||
typeMapping.put("enum", "NSString");
|
||||
typeMapping.put("Date", "NSDate");
|
||||
typeMapping.put("DateTime", "NSDate");
|
||||
typeMapping.put("boolean", "BOOL");
|
||||
typeMapping.put("boolean", "NSNumber");
|
||||
typeMapping.put("string", "NSString");
|
||||
typeMapping.put("integer", "NSNumber");
|
||||
typeMapping.put("int", "NSNumber");
|
||||
@ -147,6 +148,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
supportingFiles.add(new SupportingFile("SWGApiClient-body.mustache", sourceFolder, "SWGApiClient.m"));
|
||||
supportingFiles.add(new SupportingFile("SWGJSONResponseSerializer-header.mustache", sourceFolder, "SWGJSONResponseSerializer.h"));
|
||||
supportingFiles.add(new SupportingFile("SWGJSONResponseSerializer-body.mustache", sourceFolder, "SWGJSONResponseSerializer.m"));
|
||||
supportingFiles.add(new SupportingFile("SWGJSONRequestSerializer-body.mustache", sourceFolder, "SWGJSONRequestSerializer.m"));
|
||||
supportingFiles.add(new SupportingFile("SWGJSONRequestSerializer-header.mustache", sourceFolder, "SWGJSONRequestSerializer.h"));
|
||||
supportingFiles.add(new SupportingFile("SWGFile.h", sourceFolder, "SWGFile.h"));
|
||||
supportingFiles.add(new SupportingFile("SWGFile.m", sourceFolder, "SWGFile.m"));
|
||||
supportingFiles.add(new SupportingFile("JSONValueTransformer+ISO8601.m", sourceFolder, "JSONValueTransformer+ISO8601.m"));
|
||||
|
@ -486,7 +486,7 @@ static bool loggingEnabled = true;
|
||||
completionBlock: (void (^)(id, NSError *))completionBlock {
|
||||
// setting request serializer
|
||||
if ([requestContentType isEqualToString:@"application/json"]) {
|
||||
self.requestSerializer = [AFJSONRequestSerializer serializer];
|
||||
self.requestSerializer = [SWGJSONRequestSerializer serializer];
|
||||
}
|
||||
else if ([requestContentType isEqualToString:@"application/x-www-form-urlencoded"]) {
|
||||
self.requestSerializer = [AFHTTPRequestSerializer serializer];
|
||||
@ -569,9 +569,11 @@ static bool loggingEnabled = true;
|
||||
parameters: body
|
||||
error: nil];
|
||||
}
|
||||
|
||||
BOOL hasHeaderParams = false;
|
||||
if(headerParams != nil && [headerParams count] > 0)
|
||||
if(headerParams != nil && [headerParams count] > 0) {
|
||||
hasHeaderParams = true;
|
||||
}
|
||||
if(offlineState) {
|
||||
NSLog(@"%@ cache forced", path);
|
||||
[request setCachePolicy:NSURLRequestReturnCacheDataDontLoad];
|
||||
@ -585,17 +587,7 @@ static bool loggingEnabled = true;
|
||||
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
|
||||
}
|
||||
|
||||
|
||||
if(body != nil) {
|
||||
if([body isKindOfClass:[NSDictionary class]] || [body isKindOfClass:[NSArray class]]){
|
||||
[self.requestSerializer setValue:requestContentType forHTTPHeaderField:@"Content-Type"];
|
||||
}
|
||||
else if ([body isKindOfClass:[SWGFile class]]){}
|
||||
else {
|
||||
NSAssert(false, @"unsupported post type!");
|
||||
}
|
||||
}
|
||||
if(headerParams != nil){
|
||||
if(hasHeaderParams){
|
||||
for(NSString * key in [headerParams keyEnumerator]){
|
||||
[request setValue:[headerParams valueForKey:key] forHTTPHeaderField:key];
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#import <ISO8601/ISO8601.h>
|
||||
#import "AFHTTPRequestOperationManager.h"
|
||||
#import "SWGJSONResponseSerializer.h"
|
||||
#import "SWGJSONRequestSerializer.h"
|
||||
|
||||
{{#models}}{{#model}}#import "{{classname}}.h"
|
||||
{{/model}}{{/models}}
|
||||
|
@ -0,0 +1,35 @@
|
||||
#import "SWGJSONRequestSerializer.h"
|
||||
|
||||
@implementation SWGJSONRequestSerializer
|
||||
|
||||
///
|
||||
/// When customize a request serializer,
|
||||
/// the serializer must conform the protocol `AFURLRequestSerialization`
|
||||
/// and implements the protocol method `requestBySerializingRequest:withParameters:error:`
|
||||
///
|
||||
/// @param request The original request.
|
||||
/// @param parameters The parameters to be encoded.
|
||||
/// @param error The error that occurred while attempting to encode the request parameters.
|
||||
///
|
||||
/// @return A serialized request.
|
||||
///
|
||||
- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
|
||||
withParameters:(id)parameters
|
||||
error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
// If the body data which will be serialized isn't NSArray or NSDictionary
|
||||
// then put the data in the http request body directly.
|
||||
if ([parameters isKindOfClass:[NSArray class]] || [parameters isKindOfClass:[NSDictionary class]]) {
|
||||
return [super requestBySerializingRequest:request withParameters:parameters error:error];
|
||||
} else {
|
||||
NSMutableURLRequest *mutableRequest = [request mutableCopy];
|
||||
|
||||
if (parameters) {
|
||||
[mutableRequest setHTTPBody:[parameters dataUsingEncoding:self.stringEncoding]];
|
||||
}
|
||||
|
||||
return mutableRequest;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
@ -0,0 +1,5 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AFNetworking/AFURLRequestSerialization.h>
|
||||
|
||||
@interface SWGJSONRequestSerializer : AFJSONRequestSerializer
|
||||
@end
|
@ -89,7 +89,9 @@ static NSString * basePath = @"{{basePath}}";
|
||||
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
NSAssert({{paramName}} != nil, @"Missing the required parameter `{{paramName}}` when calling {{nickname}}");
|
||||
if ({{paramName}} == nil) {
|
||||
[NSException raise:@"Invalid parameter" format:@"Missing the required parameter `{{paramName}}` when calling `{{nickname}}`"];
|
||||
}
|
||||
{{/required}}{{/allParams}}
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@{{path}}", basePath];
|
||||
@ -136,13 +138,13 @@ static NSString * basePath = @"{{basePath}}";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[{{#authMethods}}@"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}}];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
{{#bodyParam}}
|
||||
id __body = {{paramName}};
|
||||
bodyParam = {{paramName}};
|
||||
|
||||
if(__body != nil && [__body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)__body) {
|
||||
if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)bodyParam) {
|
||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict toDictionary]];
|
||||
}
|
||||
@ -150,20 +152,10 @@ static NSString * basePath = @"{{basePath}}";
|
||||
[objs addObject:dict];
|
||||
}
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
bodyParam = objs;
|
||||
}
|
||||
else if([__body respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)__body toDictionary];
|
||||
}
|
||||
else if([__body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)__body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding: NSUTF8StringEncoding]
|
||||
options: NSJSONReadingMutableContainers
|
||||
error: &error];
|
||||
bodyDictionary = JSON;
|
||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
||||
}
|
||||
{{/bodyParam}}
|
||||
{{^bodyParam}}
|
||||
@ -175,18 +167,18 @@ static NSString * basePath = @"{{basePath}}";
|
||||
formParams[@"{{paramName}}"] = {{paramName}};
|
||||
{{/notFile}}{{#isFile}}
|
||||
requestContentType = @"multipart/form-data";
|
||||
if(bodyDictionary == nil) {
|
||||
bodyDictionary = [[NSMutableArray alloc] init];
|
||||
if(bodyParam == nil) {
|
||||
bodyParam = [[NSMutableArray alloc] init];
|
||||
}
|
||||
if({{paramName}} != nil) {
|
||||
[bodyDictionary addObject:{{paramName}}];
|
||||
[bodyParam addObject:{{paramName}}];
|
||||
{{paramName}}.paramName = @"{{baseName}}";
|
||||
}
|
||||
{{/isFile}}
|
||||
if(bodyDictionary == nil) {
|
||||
bodyDictionary = [[NSMutableArray alloc] init];
|
||||
if(bodyParam == nil) {
|
||||
bodyParam = [[NSMutableArray alloc] init];
|
||||
}
|
||||
[bodyDictionary addObject:formParams];
|
||||
[bodyParam addObject:formParams];
|
||||
{{/formParams}}
|
||||
{{/bodyParam}}
|
||||
|
||||
@ -200,7 +192,7 @@ static NSString * basePath = @"{{basePath}}";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"{{httpMethod}}"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
|
Binary file not shown.
@ -11,10 +11,13 @@
|
||||
CF0560EB1B1855CF00C0D4EC /* SWGConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = CF0560EA1B1855CF00C0D4EC /* SWGConfiguration.m */; };
|
||||
CF31D0991B105E4B00509935 /* SWGApiClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CF31D0981B105E4B00509935 /* SWGApiClientTest.m */; };
|
||||
CF5B6E2D1B2BD70800862A1C /* UserApiTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CF5B6E2C1B2BD70800862A1C /* UserApiTest.m */; };
|
||||
CF8F85811B3A4796000DE569 /* SWGMythingApi.m in Sources */ = {isa = PBXBuildFile; fileRef = CF8F85801B3A4796000DE569 /* SWGMythingApi.m */; };
|
||||
CF8F85841B3A4913000DE569 /* SWGMyresult.m in Sources */ = {isa = PBXBuildFile; fileRef = CF8F85831B3A4913000DE569 /* SWGMyresult.m */; };
|
||||
CFB37D061B2B11DD00D2E5F1 /* StoreApiTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CFB37D051B2B11DC00D2E5F1 /* StoreApiTest.m */; };
|
||||
CFCEFE511B2C1330006313BE /* SWGJSONResponseSerializer.m in Sources */ = {isa = PBXBuildFile; fileRef = CFCEFE501B2C1330006313BE /* SWGJSONResponseSerializer.m */; };
|
||||
CFD1B6701B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m in Sources */ = {isa = PBXBuildFile; fileRef = CFD1B66F1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m */; };
|
||||
CFD1B6711B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m in Sources */ = {isa = PBXBuildFile; fileRef = CFD1B66F1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m */; };
|
||||
CFE1E0391B3AA4EE0030FE7C /* SWGJSONRequestSerializer.m in Sources */ = {isa = PBXBuildFile; fileRef = CFE1E0381B3AA4EE0030FE7C /* SWGJSONRequestSerializer.m */; };
|
||||
EA66999A1811D2FA00A70D03 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA6699991811D2FA00A70D03 /* Foundation.framework */; };
|
||||
EA66999C1811D2FA00A70D03 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA66999B1811D2FA00A70D03 /* CoreGraphics.framework */; };
|
||||
EA66999E1811D2FA00A70D03 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA66999D1811D2FA00A70D03 /* UIKit.framework */; };
|
||||
@ -64,11 +67,17 @@
|
||||
CF0560EA1B1855CF00C0D4EC /* SWGConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGConfiguration.m; sourceTree = "<group>"; };
|
||||
CF31D0981B105E4B00509935 /* SWGApiClientTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGApiClientTest.m; sourceTree = "<group>"; };
|
||||
CF5B6E2C1B2BD70800862A1C /* UserApiTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UserApiTest.m; sourceTree = "<group>"; };
|
||||
CF8F857F1B3A4796000DE569 /* SWGMythingApi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWGMythingApi.h; sourceTree = "<group>"; };
|
||||
CF8F85801B3A4796000DE569 /* SWGMythingApi.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGMythingApi.m; sourceTree = "<group>"; };
|
||||
CF8F85821B3A4913000DE569 /* SWGMyresult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWGMyresult.h; sourceTree = "<group>"; };
|
||||
CF8F85831B3A4913000DE569 /* SWGMyresult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGMyresult.m; sourceTree = "<group>"; };
|
||||
CFB37D051B2B11DC00D2E5F1 /* StoreApiTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StoreApiTest.m; sourceTree = "<group>"; };
|
||||
CFCEFE4F1B2C1330006313BE /* SWGJSONResponseSerializer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWGJSONResponseSerializer.h; sourceTree = "<group>"; };
|
||||
CFCEFE501B2C1330006313BE /* SWGJSONResponseSerializer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGJSONResponseSerializer.m; sourceTree = "<group>"; };
|
||||
CFD1B66E1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "JSONValueTransformer+ISO8601.h"; sourceTree = "<group>"; };
|
||||
CFD1B66F1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "JSONValueTransformer+ISO8601.m"; sourceTree = "<group>"; };
|
||||
CFE1E0371B3AA4EE0030FE7C /* SWGJSONRequestSerializer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWGJSONRequestSerializer.h; sourceTree = "<group>"; };
|
||||
CFE1E0381B3AA4EE0030FE7C /* SWGJSONRequestSerializer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGJSONRequestSerializer.m; sourceTree = "<group>"; };
|
||||
E2B6DA00BE52336E23783686 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "../Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
EA6699961811D2FA00A70D03 /* SwaggerClient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwaggerClient.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
EA6699991811D2FA00A70D03 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
|
||||
@ -253,11 +262,17 @@
|
||||
EAEA85D21811D3AE00F06E69 /* SWGFile.h */,
|
||||
EAEA85D31811D3AE00F06E69 /* SWGFile.m */,
|
||||
EAEA85D41811D3AE00F06E69 /* SWGObject.h */,
|
||||
CF8F85821B3A4913000DE569 /* SWGMyresult.h */,
|
||||
CF8F85831B3A4913000DE569 /* SWGMyresult.m */,
|
||||
CF8F857F1B3A4796000DE569 /* SWGMythingApi.h */,
|
||||
CF8F85801B3A4796000DE569 /* SWGMythingApi.m */,
|
||||
EAEA85D51811D3AE00F06E69 /* SWGObject.m */,
|
||||
EAEA85D61811D3AE00F06E69 /* SWGOrder.h */,
|
||||
EAEA85D71811D3AE00F06E69 /* SWGOrder.m */,
|
||||
EAB26B0E1AC8E692002F5C7A /* SWGPet.h */,
|
||||
CFCEFE4F1B2C1330006313BE /* SWGJSONResponseSerializer.h */,
|
||||
CFE1E0371B3AA4EE0030FE7C /* SWGJSONRequestSerializer.h */,
|
||||
CFE1E0381B3AA4EE0030FE7C /* SWGJSONRequestSerializer.m */,
|
||||
CFCEFE501B2C1330006313BE /* SWGJSONResponseSerializer.m */,
|
||||
EAEA85D91811D3AE00F06E69 /* SWGPet.m */,
|
||||
EAEA85DA1811D3AE00F06E69 /* SWGPetApi.h */,
|
||||
@ -420,13 +435,16 @@
|
||||
EAEA85EB1811D3AE00F06E69 /* SWGPetApi.m in Sources */,
|
||||
EA6699A61811D2FA00A70D03 /* main.m in Sources */,
|
||||
CFD1B6701B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m in Sources */,
|
||||
CF8F85841B3A4913000DE569 /* SWGMyresult.m in Sources */,
|
||||
EAEA85EA1811D3AE00F06E69 /* SWGPet.m in Sources */,
|
||||
EAEA85E41811D3AE00F06E69 /* SWGApiClient.m in Sources */,
|
||||
EAEA85EC1811D3AE00F06E69 /* SWGStoreApi.m in Sources */,
|
||||
EAEA85E91811D3AE00F06E69 /* SWGOrder.m in Sources */,
|
||||
CF8F85811B3A4796000DE569 /* SWGMythingApi.m in Sources */,
|
||||
EAEA85E81811D3AE00F06E69 /* SWGObject.m in Sources */,
|
||||
EA8B8AA41AC6683700638FBB /* SWGQueryParamCollection.m in Sources */,
|
||||
CFCEFE511B2C1330006313BE /* SWGJSONResponseSerializer.m in Sources */,
|
||||
CFE1E0391B3AA4EE0030FE7C /* SWGJSONRequestSerializer.m in Sources */,
|
||||
EAEA85E71811D3AE00F06E69 /* SWGFile.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
@ -7,10 +7,14 @@
|
||||
//
|
||||
|
||||
#import "ViewController.h"
|
||||
#import "SWGPet.h"
|
||||
#import "SWGCategory.h"
|
||||
#import "SWGTag.h"
|
||||
#import "SWGPetApi.h"
|
||||
#import "SWGStoreApi.h"
|
||||
#import "SWGUserApi.h"
|
||||
#import "SWGConfiguration.h"
|
||||
#import "SWGMythingApi.h"
|
||||
|
||||
@interface ViewController ()
|
||||
|
||||
@ -21,49 +25,20 @@
|
||||
- (void)viewDidLoad
|
||||
{
|
||||
[super viewDidLoad];
|
||||
// Do any additional setup after loading the view, typically from a nib.
|
||||
|
||||
/*
|
||||
SWGPetApi * api = [[SWGPetApi alloc] init];
|
||||
[api getPetByIdWithCompletionBlock:@10 completionHandler:^(SWGPet *output, NSError *error) {
|
||||
NSLog(@"%@", [output asDictionary]);
|
||||
[output set_id:@101];
|
||||
[api addPetWithCompletionBlock:output completionHandler:^(NSError *error) {
|
||||
NSLog(@"Done!");
|
||||
}];
|
||||
/*
|
||||
NSDictionary *cateHash = @{ @"id": @123, @"name": @"test name" };
|
||||
NSDictionary *tagHash = @{ @"id": @123, @"name": @"test name" };
|
||||
NSDictionary *petHash = @{ @"id": @123, @"test": @(YES), @"name": @"test name", @"category": cateHash, @"tags": @[tagHash], @"photoUrls": @[@"test url"] };
|
||||
SWGPet *pet = [[SWGPet alloc] initWithDictionary:petHash
|
||||
error:nil];
|
||||
|
||||
// load data into file
|
||||
}];
|
||||
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"test-1" ofType:@"png"];
|
||||
NSData *myData = [NSData dataWithContentsOfFile:filePath];
|
||||
|
||||
SWGFile *file = [[SWGFile alloc] initWithNameData:@"test-2.png" mimeType:@"image/png" data:myData];
|
||||
[api uploadFileWithCompletionBlock:@1
|
||||
additionalMetadata:@"some metadata"
|
||||
file:file
|
||||
completionHandler:^(NSError *error) {
|
||||
if(error) {
|
||||
NSLog(@"%@", error);
|
||||
}
|
||||
}
|
||||
// completionHandler:^(SWGApiResponse *output, NSError *error) {
|
||||
// if(error) {
|
||||
// NSLog(@"%@", error);
|
||||
// }
|
||||
// else {
|
||||
// NSLog(@"%@", [output asDictionary]);
|
||||
// }
|
||||
// }
|
||||
];
|
||||
*/
|
||||
SWGPetApi *api = [[SWGPetApi alloc] init];
|
||||
[api deletePetWithCompletionBlock:@"hello"
|
||||
petId:@1434529787992
|
||||
completionHandler:^(NSError *error) {
|
||||
if (error) {
|
||||
NSLog(@"%@", error);
|
||||
}
|
||||
}];
|
||||
[api addPetWithCompletionBlock:pet completionHandler:^(NSError *error) {
|
||||
NSLog(@"%@", error);
|
||||
}];
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
- (void)didReceiveMemoryWarning
|
||||
|
@ -2,6 +2,7 @@
|
||||
#import <ISO8601/ISO8601.h>
|
||||
#import "AFHTTPRequestOperationManager.h"
|
||||
#import "SWGJSONResponseSerializer.h"
|
||||
#import "SWGJSONRequestSerializer.h"
|
||||
|
||||
#import "SWGUser.h"
|
||||
#import "SWGCategory.h"
|
||||
|
@ -486,7 +486,7 @@ static bool loggingEnabled = true;
|
||||
completionBlock: (void (^)(id, NSError *))completionBlock {
|
||||
// setting request serializer
|
||||
if ([requestContentType isEqualToString:@"application/json"]) {
|
||||
self.requestSerializer = [AFJSONRequestSerializer serializer];
|
||||
self.requestSerializer = [SWGJSONRequestSerializer serializer];
|
||||
}
|
||||
else if ([requestContentType isEqualToString:@"application/x-www-form-urlencoded"]) {
|
||||
self.requestSerializer = [AFHTTPRequestSerializer serializer];
|
||||
@ -569,9 +569,11 @@ static bool loggingEnabled = true;
|
||||
parameters: body
|
||||
error: nil];
|
||||
}
|
||||
|
||||
BOOL hasHeaderParams = false;
|
||||
if(headerParams != nil && [headerParams count] > 0)
|
||||
if(headerParams != nil && [headerParams count] > 0) {
|
||||
hasHeaderParams = true;
|
||||
}
|
||||
if(offlineState) {
|
||||
NSLog(@"%@ cache forced", path);
|
||||
[request setCachePolicy:NSURLRequestReturnCacheDataDontLoad];
|
||||
@ -585,17 +587,7 @@ static bool loggingEnabled = true;
|
||||
[request setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData];
|
||||
}
|
||||
|
||||
|
||||
if(body != nil) {
|
||||
if([body isKindOfClass:[NSDictionary class]] || [body isKindOfClass:[NSArray class]]){
|
||||
[self.requestSerializer setValue:requestContentType forHTTPHeaderField:@"Content-Type"];
|
||||
}
|
||||
else if ([body isKindOfClass:[SWGFile class]]){}
|
||||
else {
|
||||
NSAssert(false, @"unsupported post type!");
|
||||
}
|
||||
}
|
||||
if(headerParams != nil){
|
||||
if(hasHeaderParams){
|
||||
for(NSString * key in [headerParams keyEnumerator]){
|
||||
[request setValue:[headerParams valueForKey:key] forHTTPHeaderField:key];
|
||||
}
|
||||
|
@ -0,0 +1,5 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <AFNetworking/AFURLRequestSerialization.h>
|
||||
|
||||
@interface SWGJSONRequestSerializer : AFJSONRequestSerializer
|
||||
@end
|
@ -0,0 +1,35 @@
|
||||
#import "SWGJSONRequestSerializer.h"
|
||||
|
||||
@implementation SWGJSONRequestSerializer
|
||||
|
||||
///
|
||||
/// When customize a request serializer,
|
||||
/// the serializer must conform the protocol `AFURLRequestSerialization`
|
||||
/// and implements the protocol method `requestBySerializingRequest:withParameters:error:`
|
||||
///
|
||||
/// @param request The original request.
|
||||
/// @param parameters The parameters to be encoded.
|
||||
/// @param error The error that occurred while attempting to encode the request parameters.
|
||||
///
|
||||
/// @return A serialized request.
|
||||
///
|
||||
- (NSURLRequest *)requestBySerializingRequest:(NSURLRequest *)request
|
||||
withParameters:(id)parameters
|
||||
error:(NSError *__autoreleasing *)error
|
||||
{
|
||||
// If the body data which will be serialized isn't NSArray or NSDictionary
|
||||
// then put the data in the http request body directly.
|
||||
if ([parameters isKindOfClass:[NSArray class]] || [parameters isKindOfClass:[NSDictionary class]]) {
|
||||
return [super requestBySerializingRequest:request withParameters:parameters error:error];
|
||||
} else {
|
||||
NSMutableURLRequest *mutableRequest = [request mutableCopy];
|
||||
|
||||
if (parameters) {
|
||||
[mutableRequest setHTTPBody:[parameters dataUsingEncoding:self.stringEncoding]];
|
||||
}
|
||||
|
||||
return mutableRequest;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
@ -19,6 +19,6 @@
|
||||
*/
|
||||
@property(nonatomic) NSString* status;
|
||||
|
||||
@property(nonatomic) BOOL complete;
|
||||
@property(nonatomic) NSNumber* complete;
|
||||
|
||||
@end
|
||||
|
@ -122,13 +122,13 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[@"petstore_auth"];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
id __body = body;
|
||||
bodyParam = body;
|
||||
|
||||
if(__body != nil && [__body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)__body) {
|
||||
if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)bodyParam) {
|
||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict toDictionary]];
|
||||
}
|
||||
@ -136,20 +136,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
[objs addObject:dict];
|
||||
}
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
bodyParam = objs;
|
||||
}
|
||||
else if([__body respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)__body toDictionary];
|
||||
}
|
||||
else if([__body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)__body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding: NSUTF8StringEncoding]
|
||||
options: NSJSONReadingMutableContainers
|
||||
error: &error];
|
||||
bodyDictionary = JSON;
|
||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
||||
}
|
||||
|
||||
|
||||
@ -158,7 +148,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"PUT"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -219,13 +209,13 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[@"petstore_auth"];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
id __body = body;
|
||||
bodyParam = body;
|
||||
|
||||
if(__body != nil && [__body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)__body) {
|
||||
if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)bodyParam) {
|
||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict toDictionary]];
|
||||
}
|
||||
@ -233,20 +223,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
[objs addObject:dict];
|
||||
}
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
bodyParam = objs;
|
||||
}
|
||||
else if([__body respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)__body toDictionary];
|
||||
}
|
||||
else if([__body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)__body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding: NSUTF8StringEncoding]
|
||||
options: NSJSONReadingMutableContainers
|
||||
error: &error];
|
||||
bodyDictionary = JSON;
|
||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
||||
}
|
||||
|
||||
|
||||
@ -255,7 +235,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -322,7 +302,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[@"petstore_auth"];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
|
||||
|
||||
@ -335,7 +315,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -402,7 +382,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[@"petstore_auth"];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
|
||||
|
||||
@ -415,7 +395,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -441,7 +421,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
NSAssert(petId != nil, @"Missing the required parameter `petId` when calling getPetById");
|
||||
if (petId == nil) {
|
||||
[NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `getPetById`"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath];
|
||||
@ -480,7 +462,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[@"api_key", @"petstore_auth"];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
|
||||
|
||||
@ -493,7 +475,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -525,7 +507,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
NSAssert(petId != nil, @"Missing the required parameter `petId` when calling updatePetWithForm");
|
||||
if (petId == nil) {
|
||||
[NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `updatePetWithForm`"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath];
|
||||
@ -564,7 +548,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[@"petstore_auth"];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
|
||||
|
||||
@ -574,18 +558,18 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
formParams[@"name"] = name;
|
||||
|
||||
if(bodyDictionary == nil) {
|
||||
bodyDictionary = [[NSMutableArray alloc] init];
|
||||
if(bodyParam == nil) {
|
||||
bodyParam = [[NSMutableArray alloc] init];
|
||||
}
|
||||
[bodyDictionary addObject:formParams];
|
||||
[bodyParam addObject:formParams];
|
||||
|
||||
|
||||
formParams[@"status"] = status;
|
||||
|
||||
if(bodyDictionary == nil) {
|
||||
bodyDictionary = [[NSMutableArray alloc] init];
|
||||
if(bodyParam == nil) {
|
||||
bodyParam = [[NSMutableArray alloc] init];
|
||||
}
|
||||
[bodyDictionary addObject:formParams];
|
||||
[bodyParam addObject:formParams];
|
||||
|
||||
|
||||
|
||||
@ -593,7 +577,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -622,7 +606,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
NSAssert(petId != nil, @"Missing the required parameter `petId` when calling deletePet");
|
||||
if (petId == nil) {
|
||||
[NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `deletePet`"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}", basePath];
|
||||
@ -663,7 +649,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[@"petstore_auth"];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
|
||||
|
||||
@ -676,7 +662,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -708,7 +694,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
NSAssert(petId != nil, @"Missing the required parameter `petId` when calling uploadFile");
|
||||
if (petId == nil) {
|
||||
[NSException raise:@"Invalid parameter" format:@"Missing the required parameter `petId` when calling `uploadFile`"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/pet/{petId}/uploadImage", basePath];
|
||||
@ -747,7 +735,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[@"petstore_auth"];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
|
||||
|
||||
@ -757,25 +745,25 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
formParams[@"additionalMetadata"] = additionalMetadata;
|
||||
|
||||
if(bodyDictionary == nil) {
|
||||
bodyDictionary = [[NSMutableArray alloc] init];
|
||||
if(bodyParam == nil) {
|
||||
bodyParam = [[NSMutableArray alloc] init];
|
||||
}
|
||||
[bodyDictionary addObject:formParams];
|
||||
[bodyParam addObject:formParams];
|
||||
|
||||
|
||||
requestContentType = @"multipart/form-data";
|
||||
if(bodyDictionary == nil) {
|
||||
bodyDictionary = [[NSMutableArray alloc] init];
|
||||
if(bodyParam == nil) {
|
||||
bodyParam = [[NSMutableArray alloc] init];
|
||||
}
|
||||
if(file != nil) {
|
||||
[bodyDictionary addObject:file];
|
||||
[bodyParam addObject:file];
|
||||
file.paramName = @"file";
|
||||
}
|
||||
|
||||
if(bodyDictionary == nil) {
|
||||
bodyDictionary = [[NSMutableArray alloc] init];
|
||||
if(bodyParam == nil) {
|
||||
bodyParam = [[NSMutableArray alloc] init];
|
||||
}
|
||||
[bodyDictionary addObject:formParams];
|
||||
[bodyParam addObject:formParams];
|
||||
|
||||
|
||||
|
||||
@ -783,7 +771,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
|
@ -118,7 +118,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[@"api_key"];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
|
||||
|
||||
@ -131,7 +131,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -192,13 +192,13 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
id __body = body;
|
||||
bodyParam = body;
|
||||
|
||||
if(__body != nil && [__body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)__body) {
|
||||
if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)bodyParam) {
|
||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict toDictionary]];
|
||||
}
|
||||
@ -206,20 +206,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
[objs addObject:dict];
|
||||
}
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
bodyParam = objs;
|
||||
}
|
||||
else if([__body respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)__body toDictionary];
|
||||
}
|
||||
else if([__body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)__body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding: NSUTF8StringEncoding]
|
||||
options: NSJSONReadingMutableContainers
|
||||
error: &error];
|
||||
bodyDictionary = JSON;
|
||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
||||
}
|
||||
|
||||
|
||||
@ -228,7 +218,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -254,7 +244,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
|
||||
// verify the required parameter 'orderId' is set
|
||||
NSAssert(orderId != nil, @"Missing the required parameter `orderId` when calling getOrderById");
|
||||
if (orderId == nil) {
|
||||
[NSException raise:@"Invalid parameter" format:@"Missing the required parameter `orderId` when calling `getOrderById`"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order/{orderId}", basePath];
|
||||
@ -293,7 +285,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
|
||||
|
||||
@ -306,7 +298,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -332,7 +324,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
|
||||
// verify the required parameter 'orderId' is set
|
||||
NSAssert(orderId != nil, @"Missing the required parameter `orderId` when calling deleteOrder");
|
||||
if (orderId == nil) {
|
||||
[NSException raise:@"Invalid parameter" format:@"Missing the required parameter `orderId` when calling `deleteOrder`"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/store/order/{orderId}", basePath];
|
||||
@ -371,7 +365,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
|
||||
|
||||
@ -384,7 +378,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
|
@ -121,13 +121,13 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
id __body = body;
|
||||
bodyParam = body;
|
||||
|
||||
if(__body != nil && [__body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)__body) {
|
||||
if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)bodyParam) {
|
||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict toDictionary]];
|
||||
}
|
||||
@ -135,20 +135,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
[objs addObject:dict];
|
||||
}
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
bodyParam = objs;
|
||||
}
|
||||
else if([__body respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)__body toDictionary];
|
||||
}
|
||||
else if([__body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)__body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding: NSUTF8StringEncoding]
|
||||
options: NSJSONReadingMutableContainers
|
||||
error: &error];
|
||||
bodyDictionary = JSON;
|
||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
||||
}
|
||||
|
||||
|
||||
@ -157,7 +147,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -218,13 +208,13 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
id __body = body;
|
||||
bodyParam = body;
|
||||
|
||||
if(__body != nil && [__body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)__body) {
|
||||
if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)bodyParam) {
|
||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict toDictionary]];
|
||||
}
|
||||
@ -232,20 +222,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
[objs addObject:dict];
|
||||
}
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
bodyParam = objs;
|
||||
}
|
||||
else if([__body respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)__body toDictionary];
|
||||
}
|
||||
else if([__body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)__body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding: NSUTF8StringEncoding]
|
||||
options: NSJSONReadingMutableContainers
|
||||
error: &error];
|
||||
bodyDictionary = JSON;
|
||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
||||
}
|
||||
|
||||
|
||||
@ -254,7 +234,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -315,13 +295,13 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
id __body = body;
|
||||
bodyParam = body;
|
||||
|
||||
if(__body != nil && [__body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)__body) {
|
||||
if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)bodyParam) {
|
||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict toDictionary]];
|
||||
}
|
||||
@ -329,20 +309,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
[objs addObject:dict];
|
||||
}
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
bodyParam = objs;
|
||||
}
|
||||
else if([__body respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)__body toDictionary];
|
||||
}
|
||||
else if([__body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)__body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding: NSUTF8StringEncoding]
|
||||
options: NSJSONReadingMutableContainers
|
||||
error: &error];
|
||||
bodyDictionary = JSON;
|
||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
||||
}
|
||||
|
||||
|
||||
@ -351,7 +321,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"POST"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -423,7 +393,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
|
||||
|
||||
@ -436,7 +406,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -494,7 +464,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
|
||||
|
||||
@ -507,7 +477,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -533,7 +503,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
NSAssert(username != nil, @"Missing the required parameter `username` when calling getUserByName");
|
||||
if (username == nil) {
|
||||
[NSException raise:@"Invalid parameter" format:@"Missing the required parameter `username` when calling `getUserByName`"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath];
|
||||
@ -572,7 +544,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
|
||||
|
||||
@ -585,7 +557,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"GET"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -614,7 +586,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
NSAssert(username != nil, @"Missing the required parameter `username` when calling updateUser");
|
||||
if (username == nil) {
|
||||
[NSException raise:@"Invalid parameter" format:@"Missing the required parameter `username` when calling `updateUser`"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath];
|
||||
@ -653,13 +627,13 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
id __body = body;
|
||||
bodyParam = body;
|
||||
|
||||
if(__body != nil && [__body isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray * objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)__body) {
|
||||
if(bodyParam != nil && [bodyParam isKindOfClass:[NSArray class]]){
|
||||
NSMutableArray *objs = [[NSMutableArray alloc] init];
|
||||
for (id dict in (NSArray*)bodyParam) {
|
||||
if([dict respondsToSelector:@selector(toDictionary)]) {
|
||||
[objs addObject:[(SWGObject*)dict toDictionary]];
|
||||
}
|
||||
@ -667,20 +641,10 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
[objs addObject:dict];
|
||||
}
|
||||
}
|
||||
bodyDictionary = objs;
|
||||
bodyParam = objs;
|
||||
}
|
||||
else if([__body respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyDictionary = [(SWGObject*)__body toDictionary];
|
||||
}
|
||||
else if([__body isKindOfClass:[NSString class]]) {
|
||||
// convert it to a dictionary
|
||||
NSError * error;
|
||||
NSString * str = (NSString*)__body;
|
||||
NSDictionary *JSON =
|
||||
[NSJSONSerialization JSONObjectWithData: [str dataUsingEncoding: NSUTF8StringEncoding]
|
||||
options: NSJSONReadingMutableContainers
|
||||
error: &error];
|
||||
bodyDictionary = JSON;
|
||||
else if([bodyParam respondsToSelector:@selector(toDictionary)]) {
|
||||
bodyParam = [(SWGObject*)bodyParam toDictionary];
|
||||
}
|
||||
|
||||
|
||||
@ -689,7 +653,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"PUT"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
@ -715,7 +679,9 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
NSAssert(username != nil, @"Missing the required parameter `username` when calling deleteUser");
|
||||
if (username == nil) {
|
||||
[NSException raise:@"Invalid parameter" format:@"Missing the required parameter `username` when calling `deleteUser`"];
|
||||
}
|
||||
|
||||
|
||||
NSMutableString* requestUrl = [NSMutableString stringWithFormat:@"%@/user/{username}", basePath];
|
||||
@ -754,7 +720,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
// Authentication setting
|
||||
NSArray *authSettings = @[];
|
||||
|
||||
id bodyDictionary = nil;
|
||||
id bodyParam = nil;
|
||||
|
||||
|
||||
|
||||
@ -767,7 +733,7 @@ static NSString * basePath = @"http://petstore.swagger.io/v2";
|
||||
return [self.apiClient requestWithCompletionBlock: requestUrl
|
||||
method: @"DELETE"
|
||||
queryParams: queryParams
|
||||
body: bodyDictionary
|
||||
body: bodyParam
|
||||
headerParams: headerParams
|
||||
authSettings: authSettings
|
||||
requestContentType: requestContentType
|
||||
|
Loading…
x
Reference in New Issue
Block a user