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
|
||||
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
|
||||
[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];
|
||||
}];
|
||||
[files enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||
@ -763,4 +764,30 @@ static void (^reachabilityChangeBlock)(int);
|
||||
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
|
||||
|
@ -210,4 +210,9 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey;
|
||||
*/
|
||||
- (AFSecurityPolicy *) customSecurityPolicy;
|
||||
|
||||
/**
|
||||
* Convert parameter to NSString
|
||||
*/
|
||||
- (NSString *) parameterToString: (id) param;
|
||||
|
||||
@end
|
||||
|
@ -100,11 +100,7 @@ static {{classname}}* singletonAPI = nil;
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
{{#pathParams}}if ({{paramName}} != nil) {
|
||||
if([{{paramName}} isKindOfClass:[NSNumber class]]){
|
||||
pathParams[@"{{baseName}}"] = [((NSNumber *){{paramName}}) stringValue];
|
||||
}else{
|
||||
pathParams[@"{{baseName}}"] = {{paramName}};
|
||||
}
|
||||
pathParams[@"{{baseName}}"] = {{paramName}};
|
||||
}
|
||||
{{/pathParams}}
|
||||
|
||||
@ -118,12 +114,8 @@ static {{classname}}* singletonAPI = nil;
|
||||
{{/queryParams}}
|
||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||
|
||||
{{#headerParams}}if({{paramName}} != nil){
|
||||
if([{{paramName}} isKindOfClass:[NSNumber class]]){
|
||||
headerParams[@"{{baseName}}"] = [((NSNumber *){{paramName}}) stringValue];
|
||||
}else{
|
||||
headerParams[@"{{baseName}}"] = {{paramName}};
|
||||
}
|
||||
{{#headerParams}}if({{paramName}} != nil) {
|
||||
headerParams[@"{{baseName}}"] = {{paramName}};
|
||||
}
|
||||
{{/headerParams}}
|
||||
|
||||
@ -157,11 +149,7 @@ static {{classname}}* singletonAPI = nil;
|
||||
{{#formParams}}
|
||||
{{#notFile}}
|
||||
if ({{paramName}}) {
|
||||
if([{{paramName}} isKindOfClass:[NSNumber class]]){
|
||||
formParams[@"{{baseName}}"] = [((NSNumber *){{paramName}}) stringValue];
|
||||
}else{
|
||||
formParams[@"{{baseName}}"] = {{paramName}};
|
||||
}
|
||||
formParams[@"{{baseName}}"] = {{paramName}};
|
||||
}
|
||||
{{/notFile}}{{#isFile}}
|
||||
files[@"{{paramName}}"] = {{paramName}};
|
||||
|
@ -21,10 +21,10 @@ Pod::Spec.new do |s|
|
||||
|
||||
s.framework = 'SystemConfiguration'
|
||||
|
||||
s.homepage = "https://github.com/swagger-api/swagger-codegen"
|
||||
s.license = "MIT"
|
||||
s.source = { :git => "https://github.com/swagger-api/swagger-codegen.git", :tag => "#{s.version}" }
|
||||
s.author = { "Swagger" => "apiteam@swagger.io" }
|
||||
s.homepage = ""
|
||||
s.license = ""
|
||||
s.source = { :git => ".git", :tag => "#{s.version}" }
|
||||
s.author = { "" => "" }
|
||||
|
||||
s.source_files = 'SwaggerClient/**/*'
|
||||
s.public_header_files = 'SwaggerClient/**/*.h'
|
||||
|
@ -214,4 +214,9 @@ extern NSString *const SWGResponseObjectErrorKey;
|
||||
*/
|
||||
- (AFSecurityPolicy *) customSecurityPolicy;
|
||||
|
||||
/**
|
||||
* Convert parameter to NSString
|
||||
*/
|
||||
- (NSString *) parameterToString: (id) param;
|
||||
|
||||
@end
|
||||
|
@ -546,7 +546,8 @@ static void (^reachabilityChangeBlock)(int);
|
||||
parameters:nil
|
||||
constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
|
||||
[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];
|
||||
}];
|
||||
[files enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
|
||||
@ -763,4 +764,30 @@ static void (^reachabilityChangeBlock)(int);
|
||||
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
|
||||
|
@ -421,11 +421,7 @@ static SWGPetApi* singletonAPI = nil;
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
if (petId != nil) {
|
||||
if([petId isKindOfClass:[NSNumber class]]){
|
||||
pathParams[@"petId"] = [((NSNumber *)petId) stringValue];
|
||||
}else{
|
||||
pathParams[@"petId"] = petId;
|
||||
}
|
||||
pathParams[@"petId"] = petId;
|
||||
}
|
||||
|
||||
|
||||
@ -517,11 +513,7 @@ static SWGPetApi* singletonAPI = nil;
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
if (petId != nil) {
|
||||
if([petId isKindOfClass:[NSNumber class]]){
|
||||
pathParams[@"petId"] = [((NSNumber *)petId) stringValue];
|
||||
}else{
|
||||
pathParams[@"petId"] = petId;
|
||||
}
|
||||
pathParams[@"petId"] = petId;
|
||||
}
|
||||
|
||||
|
||||
@ -559,21 +551,13 @@ static SWGPetApi* singletonAPI = nil;
|
||||
|
||||
|
||||
if (name) {
|
||||
if([name isKindOfClass:[NSNumber class]]){
|
||||
formParams[@"name"] = [((NSNumber *)name) stringValue];
|
||||
}else{
|
||||
formParams[@"name"] = name;
|
||||
}
|
||||
formParams[@"name"] = name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (status) {
|
||||
if([status isKindOfClass:[NSNumber class]]){
|
||||
formParams[@"status"] = [((NSNumber *)status) stringValue];
|
||||
}else{
|
||||
formParams[@"status"] = status;
|
||||
}
|
||||
formParams[@"status"] = status;
|
||||
}
|
||||
|
||||
|
||||
@ -630,11 +614,7 @@ static SWGPetApi* singletonAPI = nil;
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
if (petId != nil) {
|
||||
if([petId isKindOfClass:[NSNumber class]]){
|
||||
pathParams[@"petId"] = [((NSNumber *)petId) stringValue];
|
||||
}else{
|
||||
pathParams[@"petId"] = petId;
|
||||
}
|
||||
pathParams[@"petId"] = petId;
|
||||
}
|
||||
|
||||
|
||||
@ -642,12 +622,8 @@ static SWGPetApi* singletonAPI = nil;
|
||||
|
||||
NSMutableDictionary* headerParams = [NSMutableDictionary dictionaryWithDictionary:self.defaultHeaders];
|
||||
|
||||
if(apiKey != nil){
|
||||
if([apiKey isKindOfClass:[NSNumber class]]){
|
||||
headerParams[@"api_key"] = [((NSNumber *)apiKey) stringValue];
|
||||
}else{
|
||||
headerParams[@"api_key"] = apiKey;
|
||||
}
|
||||
if(apiKey != nil) {
|
||||
headerParams[@"api_key"] = apiKey;
|
||||
}
|
||||
|
||||
|
||||
@ -733,11 +709,7 @@ static SWGPetApi* singletonAPI = nil;
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
if (petId != nil) {
|
||||
if([petId isKindOfClass:[NSNumber class]]){
|
||||
pathParams[@"petId"] = [((NSNumber *)petId) stringValue];
|
||||
}else{
|
||||
pathParams[@"petId"] = petId;
|
||||
}
|
||||
pathParams[@"petId"] = petId;
|
||||
}
|
||||
|
||||
|
||||
@ -775,11 +747,7 @@ static SWGPetApi* singletonAPI = nil;
|
||||
|
||||
|
||||
if (additionalMetadata) {
|
||||
if([additionalMetadata isKindOfClass:[NSNumber class]]){
|
||||
formParams[@"additionalMetadata"] = [((NSNumber *)additionalMetadata) stringValue];
|
||||
}else{
|
||||
formParams[@"additionalMetadata"] = additionalMetadata;
|
||||
}
|
||||
formParams[@"additionalMetadata"] = additionalMetadata;
|
||||
}
|
||||
|
||||
|
||||
|
@ -250,11 +250,7 @@ static SWGStoreApi* singletonAPI = nil;
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
if (orderId != nil) {
|
||||
if([orderId isKindOfClass:[NSNumber class]]){
|
||||
pathParams[@"orderId"] = [((NSNumber *)orderId) stringValue];
|
||||
}else{
|
||||
pathParams[@"orderId"] = orderId;
|
||||
}
|
||||
pathParams[@"orderId"] = orderId;
|
||||
}
|
||||
|
||||
|
||||
@ -340,11 +336,7 @@ static SWGStoreApi* singletonAPI = nil;
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
if (orderId != nil) {
|
||||
if([orderId isKindOfClass:[NSNumber class]]){
|
||||
pathParams[@"orderId"] = [((NSNumber *)orderId) stringValue];
|
||||
}else{
|
||||
pathParams[@"orderId"] = orderId;
|
||||
}
|
||||
pathParams[@"orderId"] = orderId;
|
||||
}
|
||||
|
||||
|
||||
|
@ -99,7 +99,7 @@
|
||||
/// Get user by user name
|
||||
///
|
||||
///
|
||||
/// @param username The name that needs to be fetched. Use user1 for testing.
|
||||
/// @param username The name that needs to be fetched. Use user1 for testing.
|
||||
///
|
||||
///
|
||||
/// @return SWGUser*
|
||||
|
@ -470,7 +470,7 @@ static SWGUserApi* singletonAPI = nil;
|
||||
///
|
||||
/// Get user by user name
|
||||
///
|
||||
/// @param username The name that needs to be fetched. Use user1 for testing.
|
||||
/// @param username The name that needs to be fetched. Use user1 for testing.
|
||||
///
|
||||
/// @returns SWGUser*
|
||||
///
|
||||
@ -495,11 +495,7 @@ static SWGUserApi* singletonAPI = nil;
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
if (username != nil) {
|
||||
if([username isKindOfClass:[NSNumber class]]){
|
||||
pathParams[@"username"] = [((NSNumber *)username) stringValue];
|
||||
}else{
|
||||
pathParams[@"username"] = username;
|
||||
}
|
||||
pathParams[@"username"] = username;
|
||||
}
|
||||
|
||||
|
||||
@ -588,11 +584,7 @@ static SWGUserApi* singletonAPI = nil;
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
if (username != nil) {
|
||||
if([username isKindOfClass:[NSNumber class]]){
|
||||
pathParams[@"username"] = [((NSNumber *)username) stringValue];
|
||||
}else{
|
||||
pathParams[@"username"] = username;
|
||||
}
|
||||
pathParams[@"username"] = username;
|
||||
}
|
||||
|
||||
|
||||
@ -678,11 +670,7 @@ static SWGUserApi* singletonAPI = nil;
|
||||
|
||||
NSMutableDictionary *pathParams = [[NSMutableDictionary alloc] init];
|
||||
if (username != nil) {
|
||||
if([username isKindOfClass:[NSNumber class]]){
|
||||
pathParams[@"username"] = [((NSNumber *)username) stringValue];
|
||||
}else{
|
||||
pathParams[@"username"] = username;
|
||||
}
|
||||
pathParams[@"username"] = username;
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,11 +24,10 @@
|
||||
|
||||
SWGConfiguration *config = [SWGConfiguration sharedConfig];
|
||||
config.debug = YES;
|
||||
config.verifySSL = NO;
|
||||
|
||||
SWGPetApi *api = [[SWGPetApi alloc] init];
|
||||
SWGPet *pet = [self createPet];
|
||||
[api addPetWithCompletionBlock:pet completionHandler:^(NSError *error) {
|
||||
NSURL *file = [NSURL fileURLWithPath:@"/Users/geekerzp/tmp/test.jpg"];
|
||||
[api uploadFileWithCompletionBlock:@2 additionalMetadata:@2 file:file completionHandler:^(NSError *error) {
|
||||
NSLog(@"*** error: %@", error);
|
||||
}];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user