forked from loafle/openapi-generator-original
Merge pull request #1245 from geekerzp/objc_ssl
[Objc] Enhancements of objc client
This commit is contained in:
commit
6d21422bad
@ -546,7 +546,8 @@ static void (^reachabilityChangeBlock)(int);
|
|||||||
parameters:nil
|
parameters:nil
|
||||||
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
|
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
|
||||||
[formParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
[formParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||||
NSData *data = [obj dataUsingEncoding:NSUTF8StringEncoding];
|
NSString *objString = [self parameterToString:obj];
|
||||||
|
NSData *data = [objString dataUsingEncoding:NSUTF8StringEncoding];
|
||||||
[formData appendPartWithFormData:data name:key];
|
[formData appendPartWithFormData:data name:key];
|
||||||
}];
|
}];
|
||||||
[files enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
[files enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||||
@ -763,4 +764,30 @@ static void (^reachabilityChangeBlock)(int);
|
|||||||
return securityPolicy;
|
return securityPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *) parameterToString:(id)param {
|
||||||
|
if ([param isKindOfClass:[NSString class]]) {
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
else if ([param isKindOfClass:[NSNumber class]]) {
|
||||||
|
return [param stringValue];
|
||||||
|
}
|
||||||
|
else if ([param isKindOfClass:[NSDate class]]) {
|
||||||
|
return [param ISO8601String];
|
||||||
|
}
|
||||||
|
else if ([param isKindOfClass:[NSArray class]]) {
|
||||||
|
NSMutableArray *mutableParam;
|
||||||
|
[param enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
|
[mutableParam addObject:[self parameterToString:obj]];
|
||||||
|
}];
|
||||||
|
return [mutableParam componentsJoinedByString:@","];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NSException *e = [NSException
|
||||||
|
exceptionWithName:@"InvalidObjectArgumentException"
|
||||||
|
reason:[NSString stringWithFormat:@"*** The argument object: %@ is invalid", param]
|
||||||
|
userInfo:nil];
|
||||||
|
@throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -210,4 +210,9 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
|
|||||||
*/
|
*/
|
||||||
- (AFSecurityPolicy *) customSecurityPolicy;
|
- (AFSecurityPolicy *) customSecurityPolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert parameter to NSString
|
||||||
|
*/
|
||||||
|
- (NSString *) parameterToString: (id) param;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -100,11 +100,7 @@ static {{classname}}* singletonAPI = nil;
|
|||||||
|
|
||||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
{{#pathParams}}if ({{paramName}} != nil) {
|
{{#pathParams}}if ({{paramName}} != nil) {
|
||||||
if([{{paramName}} isKindOfClass:[NSNumber class]]){
|
pathParams[@"{{baseName}}"] = {{paramName}};
|
||||||
pathParams[@"{{baseName}}"] = [((NSNumber *){{paramName}}) stringValue];
|
|
||||||
}else{
|
|
||||||
pathParams[@"{{baseName}}"] = {{paramName}};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
{{/pathParams}}
|
{{/pathParams}}
|
||||||
|
|
||||||
@ -118,12 +114,8 @@ static {{classname}}* singletonAPI = nil;
|
|||||||
{{/queryParams}}
|
{{/queryParams}}
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
{{#headerParams}}if({{paramName}} != nil){
|
{{#headerParams}}if({{paramName}} != nil) {
|
||||||
if([{{paramName}} isKindOfClass:[NSNumber class]]){
|
headerParams[@"{{baseName}}"] = {{paramName}};
|
||||||
headerParams[@"{{baseName}}"] = [((NSNumber *){{paramName}}) stringValue];
|
|
||||||
}else{
|
|
||||||
headerParams[@"{{baseName}}"] = {{paramName}};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
{{/headerParams}}
|
{{/headerParams}}
|
||||||
|
|
||||||
@ -157,11 +149,7 @@ static {{classname}}* singletonAPI = nil;
|
|||||||
{{#formParams}}
|
{{#formParams}}
|
||||||
{{#notFile}}
|
{{#notFile}}
|
||||||
if ({{paramName}}) {
|
if ({{paramName}}) {
|
||||||
if([{{paramName}} isKindOfClass:[NSNumber class]]){
|
formParams[@"{{baseName}}"] = {{paramName}};
|
||||||
formParams[@"{{baseName}}"] = [((NSNumber *){{paramName}}) stringValue];
|
|
||||||
}else{
|
|
||||||
formParams[@"{{baseName}}"] = {{paramName}};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
{{/notFile}}{{#isFile}}
|
{{/notFile}}{{#isFile}}
|
||||||
files[@"{{paramName}}"] = {{paramName}};
|
files[@"{{paramName}}"] = {{paramName}};
|
||||||
|
@ -21,10 +21,10 @@ Pod::Spec.new do |s|
|
|||||||
|
|
||||||
s.framework = 'SystemConfiguration'
|
s.framework = 'SystemConfiguration'
|
||||||
|
|
||||||
s.homepage = "https://github.com/swagger-api/swagger-codegen"
|
s.homepage = ""
|
||||||
s.license = "MIT"
|
s.license = ""
|
||||||
s.source = { :git => "https://github.com/swagger-api/swagger-codegen.git", :tag => "#{s.version}" }
|
s.source = { :git => ".git", :tag => "#{s.version}" }
|
||||||
s.author = { "Swagger" => "apiteam@swagger.io" }
|
s.author = { "" => "" }
|
||||||
|
|
||||||
s.source_files = 'SwaggerClient/**/*'
|
s.source_files = 'SwaggerClient/**/*'
|
||||||
s.public_header_files = 'SwaggerClient/**/*.h'
|
s.public_header_files = 'SwaggerClient/**/*.h'
|
||||||
|
@ -214,4 +214,9 @@ extern NSString *const SWGResponseObjectErrorKey;
|
|||||||
*/
|
*/
|
||||||
- (AFSecurityPolicy *) customSecurityPolicy;
|
- (AFSecurityPolicy *) customSecurityPolicy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert parameter to NSString
|
||||||
|
*/
|
||||||
|
- (NSString *) parameterToString: (id) param;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -546,7 +546,8 @@ static void (^reachabilityChangeBlock)(int);
|
|||||||
parameters:nil
|
parameters:nil
|
||||||
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
|
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
|
||||||
[formParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
[formParams enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||||
NSData *data = [obj dataUsingEncoding:NSUTF8StringEncoding];
|
NSString *objString = [self parameterToString:obj];
|
||||||
|
NSData *data = [objString dataUsingEncoding:NSUTF8StringEncoding];
|
||||||
[formData appendPartWithFormData:data name:key];
|
[formData appendPartWithFormData:data name:key];
|
||||||
}];
|
}];
|
||||||
[files enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
[files enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||||
@ -763,4 +764,30 @@ static void (^reachabilityChangeBlock)(int);
|
|||||||
return securityPolicy;
|
return securityPolicy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSString *) parameterToString:(id)param {
|
||||||
|
if ([param isKindOfClass:[NSString class]]) {
|
||||||
|
return param;
|
||||||
|
}
|
||||||
|
else if ([param isKindOfClass:[NSNumber class]]) {
|
||||||
|
return [param stringValue];
|
||||||
|
}
|
||||||
|
else if ([param isKindOfClass:[NSDate class]]) {
|
||||||
|
return [param ISO8601String];
|
||||||
|
}
|
||||||
|
else if ([param isKindOfClass:[NSArray class]]) {
|
||||||
|
NSMutableArray *mutableParam;
|
||||||
|
[param enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
|
||||||
|
[mutableParam addObject:[self parameterToString:obj]];
|
||||||
|
}];
|
||||||
|
return [mutableParam componentsJoinedByString:@","];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
NSException *e = [NSException
|
||||||
|
exceptionWithName:@"InvalidObjectArgumentException"
|
||||||
|
reason:[NSString stringWithFormat:@"*** The argument object: %@ is invalid", param]
|
||||||
|
userInfo:nil];
|
||||||
|
@throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@ -421,11 +421,7 @@ static SWGPetApi* singletonAPI = nil;
|
|||||||
|
|
||||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
if (petId != nil) {
|
if (petId != nil) {
|
||||||
if([petId isKindOfClass:[NSNumber class]]){
|
pathParams[@"petId"] = petId;
|
||||||
pathParams[@"petId"] = [((NSNumber *)petId) stringValue];
|
|
||||||
}else{
|
|
||||||
pathParams[@"petId"] = petId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -517,11 +513,7 @@ static SWGPetApi* singletonAPI = nil;
|
|||||||
|
|
||||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
if (petId != nil) {
|
if (petId != nil) {
|
||||||
if([petId isKindOfClass:[NSNumber class]]){
|
pathParams[@"petId"] = petId;
|
||||||
pathParams[@"petId"] = [((NSNumber *)petId) stringValue];
|
|
||||||
}else{
|
|
||||||
pathParams[@"petId"] = petId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -559,21 +551,13 @@ static SWGPetApi* singletonAPI = nil;
|
|||||||
|
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
if([name isKindOfClass:[NSNumber class]]){
|
formParams[@"name"] = name;
|
||||||
formParams[@"name"] = [((NSNumber *)name) stringValue];
|
|
||||||
}else{
|
|
||||||
formParams[@"name"] = name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (status) {
|
if (status) {
|
||||||
if([status isKindOfClass:[NSNumber class]]){
|
formParams[@"status"] = status;
|
||||||
formParams[@"status"] = [((NSNumber *)status) stringValue];
|
|
||||||
}else{
|
|
||||||
formParams[@"status"] = status;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -630,11 +614,7 @@ static SWGPetApi* singletonAPI = nil;
|
|||||||
|
|
||||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
if (petId != nil) {
|
if (petId != nil) {
|
||||||
if([petId isKindOfClass:[NSNumber class]]){
|
pathParams[@"petId"] = petId;
|
||||||
pathParams[@"petId"] = [((NSNumber *)petId) stringValue];
|
|
||||||
}else{
|
|
||||||
pathParams[@"petId"] = petId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -642,12 +622,8 @@ static SWGPetApi* singletonAPI = nil;
|
|||||||
|
|
||||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||||
|
|
||||||
if(apiKey != nil){
|
if(apiKey != nil) {
|
||||||
if([apiKey isKindOfClass:[NSNumber class]]){
|
headerParams[@"api_key"] = apiKey;
|
||||||
headerParams[@"api_key"] = [((NSNumber *)apiKey) stringValue];
|
|
||||||
}else{
|
|
||||||
headerParams[@"api_key"] = apiKey;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -733,11 +709,7 @@ static SWGPetApi* singletonAPI = nil;
|
|||||||
|
|
||||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
if (petId != nil) {
|
if (petId != nil) {
|
||||||
if([petId isKindOfClass:[NSNumber class]]){
|
pathParams[@"petId"] = petId;
|
||||||
pathParams[@"petId"] = [((NSNumber *)petId) stringValue];
|
|
||||||
}else{
|
|
||||||
pathParams[@"petId"] = petId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -775,11 +747,7 @@ static SWGPetApi* singletonAPI = nil;
|
|||||||
|
|
||||||
|
|
||||||
if (additionalMetadata) {
|
if (additionalMetadata) {
|
||||||
if([additionalMetadata isKindOfClass:[NSNumber class]]){
|
formParams[@"additionalMetadata"] = additionalMetadata;
|
||||||
formParams[@"additionalMetadata"] = [((NSNumber *)additionalMetadata) stringValue];
|
|
||||||
}else{
|
|
||||||
formParams[@"additionalMetadata"] = additionalMetadata;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -250,11 +250,7 @@ static SWGStoreApi* singletonAPI = nil;
|
|||||||
|
|
||||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
if (orderId != nil) {
|
if (orderId != nil) {
|
||||||
if([orderId isKindOfClass:[NSNumber class]]){
|
pathParams[@"orderId"] = orderId;
|
||||||
pathParams[@"orderId"] = [((NSNumber *)orderId) stringValue];
|
|
||||||
}else{
|
|
||||||
pathParams[@"orderId"] = orderId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -340,11 +336,7 @@ static SWGStoreApi* singletonAPI = nil;
|
|||||||
|
|
||||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
if (orderId != nil) {
|
if (orderId != nil) {
|
||||||
if([orderId isKindOfClass:[NSNumber class]]){
|
pathParams[@"orderId"] = orderId;
|
||||||
pathParams[@"orderId"] = [((NSNumber *)orderId) stringValue];
|
|
||||||
}else{
|
|
||||||
pathParams[@"orderId"] = orderId;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -495,11 +495,7 @@ static SWGUserApi* singletonAPI = nil;
|
|||||||
|
|
||||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
if (username != nil) {
|
if (username != nil) {
|
||||||
if([username isKindOfClass:[NSNumber class]]){
|
pathParams[@"username"] = username;
|
||||||
pathParams[@"username"] = [((NSNumber *)username) stringValue];
|
|
||||||
}else{
|
|
||||||
pathParams[@"username"] = username;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -588,11 +584,7 @@ static SWGUserApi* singletonAPI = nil;
|
|||||||
|
|
||||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
if (username != nil) {
|
if (username != nil) {
|
||||||
if([username isKindOfClass:[NSNumber class]]){
|
pathParams[@"username"] = username;
|
||||||
pathParams[@"username"] = [((NSNumber *)username) stringValue];
|
|
||||||
}else{
|
|
||||||
pathParams[@"username"] = username;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -678,11 +670,7 @@ static SWGUserApi* singletonAPI = nil;
|
|||||||
|
|
||||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||||
if (username != nil) {
|
if (username != nil) {
|
||||||
if([username isKindOfClass:[NSNumber class]]){
|
pathParams[@"username"] = username;
|
||||||
pathParams[@"username"] = [((NSNumber *)username) stringValue];
|
|
||||||
}else{
|
|
||||||
pathParams[@"username"] = username;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,11 +24,10 @@
|
|||||||
|
|
||||||
SWGConfiguration *config = [SWGConfiguration sharedConfig];
|
SWGConfiguration *config = [SWGConfiguration sharedConfig];
|
||||||
config.debug = YES;
|
config.debug = YES;
|
||||||
config.verifySSL = NO;
|
|
||||||
|
|
||||||
SWGPetApi *api = [[SWGPetApi alloc] init];
|
SWGPetApi *api = [[SWGPetApi alloc] init];
|
||||||
SWGPet *pet = [self createPet];
|
NSURL *file = [NSURL fileURLWithPath:@"/Users/geekerzp/tmp/test.jpg"];
|
||||||
[api addPetWithCompletionBlock:pet completionHandler:^(NSError *error) {
|
[api uploadFileWithCompletionBlock:@2 additionalMetadata:@2 file:file completionHandler:^(NSError *error) {
|
||||||
NSLog(@"*** error: %@", error);
|
NSLog(@"*** error: %@", error);
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user