From 6cc5a32d4013cd405aa83cfd377302273e3cbbbd Mon Sep 17 00:00:00 2001 From: wing328 Date: Sat, 10 Oct 2015 23:09:41 +0800 Subject: [PATCH] update objc sample --- .../petstore/objc/SwaggerClient/SWGApiClient.m | 15 ++++++++++----- .../objc/SwaggerClient/SWGConfiguration.m | 7 ------- .../petstore/objc/SwaggerClient/SWGOrder.h | 2 +- .../petstore/objc/SwaggerClient/SWGOrder.m | 4 ++-- .../petstore/objc/SwaggerClient/SWGPetApi.m | 16 ++++++++-------- .../petstore/objc/SwaggerClient/SWGStoreApi.m | 2 +- samples/client/petstore/ruby/lib/petstore.rb | 2 +- .../petstore/ruby/lib/petstore/api/pet_api.rb | 16 ++++++++-------- .../petstore/ruby/lib/petstore/api/store_api.rb | 2 +- .../petstore/ruby/lib/petstore/api/user_api.rb | 2 +- .../petstore/ruby/lib/petstore/api_client.rb | 2 -- .../petstore/ruby/lib/petstore/configuration.rb | 7 ------- 12 files changed, 33 insertions(+), 44 deletions(-) diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m index fc3c79078625..dcd33575fc6f 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.m @@ -311,9 +311,10 @@ static void (^reachabilityChangeBlock)(int); range:NSMakeRange(0, [class length])]; if (match) { + NSArray *dataArray = data; innerType = [class substringWithRange:[match rangeAtIndex:1]]; - resultArray = [NSMutableArray arrayWithCapacity:[data count]]; + resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [resultArray addObject:[self deserialize:obj class:innerType]]; } @@ -332,9 +333,10 @@ static void (^reachabilityChangeBlock)(int); range:NSMakeRange(0, [class length])]; if (match) { + NSArray *dataArray = data; innerType = [class substringWithRange:[match rangeAtIndex:1]]; - resultArray = [NSMutableArray arrayWithCapacity:[data count]]; + resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]]; [data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { [resultArray addObject:[self deserialize:obj class:innerType]]; }]; @@ -352,9 +354,10 @@ static void (^reachabilityChangeBlock)(int); range:NSMakeRange(0, [class length])]; if (match) { + NSDictionary *dataDict = data; NSString *valueType = [class substringWithRange:[match rangeAtIndex:2]]; - resultDict = [NSMutableDictionary dictionaryWithCapacity:[data count]]; + resultDict = [NSMutableDictionary dictionaryWithCapacity:[dataDict count]]; [data enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { [resultDict setValue:[self deserialize:obj class:valueType] forKey:key]; }]; @@ -728,7 +731,8 @@ static void (^reachabilityChangeBlock)(int); return [object ISO8601String]; } else if ([object isKindOfClass:[NSArray class]]) { - NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[object count]]; + NSArray *objectArray = object; + NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[objectArray count]]; [object enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { if (obj) { [sanitizedObjs addObject:[self sanitizeForSerialization:obj]]; @@ -737,7 +741,8 @@ static void (^reachabilityChangeBlock)(int); return sanitizedObjs; } else if ([object isKindOfClass:[NSDictionary class]]) { - NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[object count]]; + NSDictionary *objectDict = object; + NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[objectDict count]]; [object enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) { if (obj) { [sanitizedObjs setValue:[self sanitizeForSerialization:obj] forKey:key]; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m index 16ce311c59ed..3f1f926b3312 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m @@ -107,13 +107,6 @@ - (NSDictionary *) authSettings { return @{ - @"api_key": - @{ - @"type": @"api_key", - @"in": @"header", - @"key": @"api_key", - @"value": [self getApiKeyWithPrefix:@"api_key"] - }, }; } diff --git a/samples/client/petstore/objc/SwaggerClient/SWGOrder.h b/samples/client/petstore/objc/SwaggerClient/SWGOrder.h index 4b132c57be50..48a7cf0d6c1f 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGOrder.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGOrder.h @@ -26,6 +26,6 @@ */ @property(nonatomic) NSString* status; -@property(nonatomic) NSString* count; +@property(nonatomic) NSNumber* complete; @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m index 8bf5f75c5ad6..83fe5741cd7f 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m @@ -8,7 +8,7 @@ */ + (JSONKeyMapper *)keyMapper { - return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"count": @"count" }]; + return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"complete": @"complete" }]; } /** @@ -18,7 +18,7 @@ */ + (BOOL)propertyIsOptional:(NSString *)propertyName { - NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"count"]; + NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"complete"]; if ([optionalProperties containsObject:propertyName]) { return YES; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m index 156700c9a769..64ff58e31e6b 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.m @@ -118,7 +118,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -196,7 +196,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]]; // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -280,7 +280,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -364,7 +364,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -450,7 +450,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"api_key", @"petstore_auth"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -542,7 +542,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/x-www-form-urlencoded"]]; // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -646,7 +646,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; @@ -738,7 +738,7 @@ static SWGPetApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"multipart/form-data"]]; // Authentication setting - NSArray *authSettings = @[@"petstore_auth"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m index 5fdf86b43aff..8450022164ce 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m @@ -115,7 +115,7 @@ static SWGStoreApi* singletonAPI = nil; NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"api_key"]; + NSArray *authSettings = @[]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; diff --git a/samples/client/petstore/ruby/lib/petstore.rb b/samples/client/petstore/ruby/lib/petstore.rb index c13e99f29fc4..61640d687ac7 100644 --- a/samples/client/petstore/ruby/lib/petstore.rb +++ b/samples/client/petstore/ruby/lib/petstore.rb @@ -14,8 +14,8 @@ require 'petstore/models/order' # APIs require 'petstore/api/user_api' -require 'petstore/api/store_api' require 'petstore/api/pet_api' +require 'petstore/api/store_api' module Petstore class << self diff --git a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb index a9d30a00147c..bb1b66c19a40 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/pet_api.rb @@ -42,7 +42,7 @@ module Petstore post_body = @api_client.object_to_http_body(opts[:'body']) - auth_names = ['petstore_auth'] + auth_names = [] @api_client.call_api(:PUT, path, :header_params => header_params, :query_params => query_params, @@ -89,7 +89,7 @@ module Petstore post_body = @api_client.object_to_http_body(opts[:'body']) - auth_names = ['petstore_auth'] + auth_names = [] @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, @@ -137,7 +137,7 @@ module Petstore post_body = nil - auth_names = ['petstore_auth'] + auth_names = [] result = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, @@ -186,7 +186,7 @@ module Petstore post_body = nil - auth_names = ['petstore_auth'] + auth_names = [] result = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, @@ -237,7 +237,7 @@ module Petstore post_body = nil - auth_names = ['petstore_auth', 'api_key'] + auth_names = [] result = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, @@ -292,7 +292,7 @@ module Petstore post_body = nil - auth_names = ['petstore_auth'] + auth_names = [] @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, @@ -344,7 +344,7 @@ module Petstore post_body = nil - auth_names = ['petstore_auth'] + auth_names = [] @api_client.call_api(:DELETE, path, :header_params => header_params, :query_params => query_params, @@ -398,7 +398,7 @@ module Petstore post_body = nil - auth_names = ['petstore_auth'] + auth_names = [] @api_client.call_api(:POST, path, :header_params => header_params, :query_params => query_params, diff --git a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb index 235ff1c41060..b33aa87a505b 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/store_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/store_api.rb @@ -41,7 +41,7 @@ module Petstore post_body = nil - auth_names = ['api_key'] + auth_names = [] result = @api_client.call_api(:GET, path, :header_params => header_params, :query_params => query_params, diff --git a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb index f4672e2a3585..7f546330f3aa 100644 --- a/samples/client/petstore/ruby/lib/petstore/api/user_api.rb +++ b/samples/client/petstore/ruby/lib/petstore/api/user_api.rb @@ -248,7 +248,7 @@ module Petstore # 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. # @param [Hash] opts the optional parameters # @return [User] def get_user_by_name(username, opts = {}) diff --git a/samples/client/petstore/ruby/lib/petstore/api_client.rb b/samples/client/petstore/ruby/lib/petstore/api_client.rb index 4f747bcd6a11..77e9c4487183 100644 --- a/samples/client/petstore/ruby/lib/petstore/api_client.rb +++ b/samples/client/petstore/ruby/lib/petstore/api_client.rb @@ -62,8 +62,6 @@ module Petstore form_params = opts[:form_params] || {} - update_params_for_auth! header_params, query_params, opts[:auth_names] - req_opts = { :method => http_method, diff --git a/samples/client/petstore/ruby/lib/petstore/configuration.rb b/samples/client/petstore/ruby/lib/petstore/configuration.rb index 008be48ee4da..5e333ee79efe 100644 --- a/samples/client/petstore/ruby/lib/petstore/configuration.rb +++ b/samples/client/petstore/ruby/lib/petstore/configuration.rb @@ -160,13 +160,6 @@ module Petstore # Returns Auth Settings hash for api client. def auth_settings { - 'api_key' => - { - type: 'api_key', - in: 'header', - key: 'api_key', - value: api_key_with_prefix('api_key') - }, } end end