Skip to content

Commit 6cc5a32

Browse files
committed
update objc sample
1 parent 64fd942 commit 6cc5a32

File tree

12 files changed

+33
-44
lines changed

12 files changed

+33
-44
lines changed

samples/client/petstore/objc/SwaggerClient/SWGApiClient.m

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,10 @@ - (id) deserialize:(id) data class:(NSString *) class {
311311
range:NSMakeRange(0, [class length])];
312312

313313
if (match) {
314+
NSArray *dataArray = data;
314315
innerType = [class substringWithRange:[match rangeAtIndex:1]];
315316

316-
resultArray = [NSMutableArray arrayWithCapacity:[data count]];
317+
resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]];
317318
[data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
318319
[resultArray addObject:[self deserialize:obj class:innerType]];
319320
}
@@ -332,9 +333,10 @@ - (id) deserialize:(id) data class:(NSString *) class {
332333
range:NSMakeRange(0, [class length])];
333334

334335
if (match) {
336+
NSArray *dataArray = data;
335337
innerType = [class substringWithRange:[match rangeAtIndex:1]];
336338

337-
resultArray = [NSMutableArray arrayWithCapacity:[data count]];
339+
resultArray = [NSMutableArray arrayWithCapacity:[dataArray count]];
338340
[data enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
339341
[resultArray addObject:[self deserialize:obj class:innerType]];
340342
}];
@@ -352,9 +354,10 @@ - (id) deserialize:(id) data class:(NSString *) class {
352354
range:NSMakeRange(0, [class length])];
353355

354356
if (match) {
357+
NSDictionary *dataDict = data;
355358
NSString *valueType = [class substringWithRange:[match rangeAtIndex:2]];
356359

357-
resultDict = [NSMutableDictionary dictionaryWithCapacity:[data count]];
360+
resultDict = [NSMutableDictionary dictionaryWithCapacity:[dataDict count]];
358361
[data enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
359362
[resultDict setValue:[self deserialize:obj class:valueType] forKey:key];
360363
}];
@@ -728,7 +731,8 @@ - (id) sanitizeForSerialization:(id) object {
728731
return [object ISO8601String];
729732
}
730733
else if ([object isKindOfClass:[NSArray class]]) {
731-
NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[object count]];
734+
NSArray *objectArray = object;
735+
NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[objectArray count]];
732736
[object enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
733737
if (obj) {
734738
[sanitizedObjs addObject:[self sanitizeForSerialization:obj]];
@@ -737,7 +741,8 @@ - (id) sanitizeForSerialization:(id) object {
737741
return sanitizedObjs;
738742
}
739743
else if ([object isKindOfClass:[NSDictionary class]]) {
740-
NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[object count]];
744+
NSDictionary *objectDict = object;
745+
NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[objectDict count]];
741746
[object enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
742747
if (obj) {
743748
[sanitizedObjs setValue:[self sanitizeForSerialization:obj] forKey:key];

samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,6 @@ - (NSDictionary *) apiKeyPrefix {
107107

108108
- (NSDictionary *) authSettings {
109109
return @{
110-
@"api_key":
111-
@{
112-
@"type": @"api_key",
113-
@"in": @"header",
114-
@"key": @"api_key",
115-
@"value": [self getApiKeyWithPrefix:@"api_key"]
116-
},
117110
};
118111
}
119112

samples/client/petstore/objc/SwaggerClient/SWGOrder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@
2626
*/
2727
@property(nonatomic) NSString* status;
2828

29-
@property(nonatomic) NSString* count;
29+
@property(nonatomic) NSNumber* complete;
3030

3131
@end

samples/client/petstore/objc/SwaggerClient/SWGOrder.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ @implementation SWGOrder
88
*/
99
+ (JSONKeyMapper *)keyMapper
1010
{
11-
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"count": @"count" }];
11+
return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"complete": @"complete" }];
1212
}
1313

1414
/**
@@ -18,7 +18,7 @@ + (JSONKeyMapper *)keyMapper
1818
*/
1919
+ (BOOL)propertyIsOptional:(NSString *)propertyName
2020
{
21-
NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"count"];
21+
NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"complete"];
2222

2323
if ([optionalProperties containsObject:propertyName]) {
2424
return YES;

samples/client/petstore/objc/SwaggerClient/SWGPetApi.m

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ -(NSNumber*) updatePetWithCompletionBlock: (SWGPet*) body
118118
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]];
119119

120120
// Authentication setting
121-
NSArray *authSettings = @[@"petstore_auth"];
121+
NSArray *authSettings = @[];
122122

123123
id bodyParam = nil;
124124
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
@@ -196,7 +196,7 @@ -(NSNumber*) addPetWithCompletionBlock: (SWGPet*) body
196196
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/json", @"application/xml"]];
197197

198198
// Authentication setting
199-
NSArray *authSettings = @[@"petstore_auth"];
199+
NSArray *authSettings = @[];
200200

201201
id bodyParam = nil;
202202
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
@@ -280,7 +280,7 @@ -(NSNumber*) findPetsByStatusWithCompletionBlock: (NSArray* /* NSString */) stat
280280
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
281281

282282
// Authentication setting
283-
NSArray *authSettings = @[@"petstore_auth"];
283+
NSArray *authSettings = @[];
284284

285285
id bodyParam = nil;
286286
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
@@ -364,7 +364,7 @@ -(NSNumber*) findPetsByTagsWithCompletionBlock: (NSArray* /* NSString */) tags
364364
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
365365

366366
// Authentication setting
367-
NSArray *authSettings = @[@"petstore_auth"];
367+
NSArray *authSettings = @[];
368368

369369
id bodyParam = nil;
370370
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
@@ -450,7 +450,7 @@ -(NSNumber*) getPetByIdWithCompletionBlock: (NSNumber*) petId
450450
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
451451

452452
// Authentication setting
453-
NSArray *authSettings = @[@"api_key", @"petstore_auth"];
453+
NSArray *authSettings = @[];
454454

455455
id bodyParam = nil;
456456
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
@@ -542,7 +542,7 @@ -(NSNumber*) updatePetWithFormWithCompletionBlock: (NSString*) petId
542542
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"application/x-www-form-urlencoded"]];
543543

544544
// Authentication setting
545-
NSArray *authSettings = @[@"petstore_auth"];
545+
NSArray *authSettings = @[];
546546

547547
id bodyParam = nil;
548548
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
@@ -646,7 +646,7 @@ -(NSNumber*) deletePetWithCompletionBlock: (NSNumber*) petId
646646
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
647647

648648
// Authentication setting
649-
NSArray *authSettings = @[@"petstore_auth"];
649+
NSArray *authSettings = @[];
650650

651651
id bodyParam = nil;
652652
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];
@@ -738,7 +738,7 @@ -(NSNumber*) uploadFileWithCompletionBlock: (NSNumber*) petId
738738
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[@"multipart/form-data"]];
739739

740740
// Authentication setting
741-
NSArray *authSettings = @[@"petstore_auth"];
741+
NSArray *authSettings = @[];
742742

743743
id bodyParam = nil;
744744
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];

samples/client/petstore/objc/SwaggerClient/SWGStoreApi.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ -(NSNumber*) getInventoryWithCompletionBlock:
115115
NSString *requestContentType = [SWGApiClient selectHeaderContentType:@[]];
116116

117117
// Authentication setting
118-
NSArray *authSettings = @[@"api_key"];
118+
NSArray *authSettings = @[];
119119

120120
id bodyParam = nil;
121121
NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init];

samples/client/petstore/ruby/lib/petstore.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
# APIs
1616
require 'petstore/api/user_api'
17-
require 'petstore/api/store_api'
1817
require 'petstore/api/pet_api'
18+
require 'petstore/api/store_api'
1919

2020
module Petstore
2121
class << self

samples/client/petstore/ruby/lib/petstore/api/pet_api.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def update_pet(opts = {})
4242
post_body = @api_client.object_to_http_body(opts[:'body'])
4343

4444

45-
auth_names = ['petstore_auth']
45+
auth_names = []
4646
@api_client.call_api(:PUT, path,
4747
:header_params => header_params,
4848
:query_params => query_params,
@@ -89,7 +89,7 @@ def add_pet(opts = {})
8989
post_body = @api_client.object_to_http_body(opts[:'body'])
9090

9191

92-
auth_names = ['petstore_auth']
92+
auth_names = []
9393
@api_client.call_api(:POST, path,
9494
:header_params => header_params,
9595
:query_params => query_params,
@@ -137,7 +137,7 @@ def find_pets_by_status(opts = {})
137137
post_body = nil
138138

139139

140-
auth_names = ['petstore_auth']
140+
auth_names = []
141141
result = @api_client.call_api(:GET, path,
142142
:header_params => header_params,
143143
:query_params => query_params,
@@ -186,7 +186,7 @@ def find_pets_by_tags(opts = {})
186186
post_body = nil
187187

188188

189-
auth_names = ['petstore_auth']
189+
auth_names = []
190190
result = @api_client.call_api(:GET, path,
191191
:header_params => header_params,
192192
:query_params => query_params,
@@ -237,7 +237,7 @@ def get_pet_by_id(pet_id, opts = {})
237237
post_body = nil
238238

239239

240-
auth_names = ['petstore_auth', 'api_key']
240+
auth_names = []
241241
result = @api_client.call_api(:GET, path,
242242
:header_params => header_params,
243243
:query_params => query_params,
@@ -292,7 +292,7 @@ def update_pet_with_form(pet_id, opts = {})
292292
post_body = nil
293293

294294

295-
auth_names = ['petstore_auth']
295+
auth_names = []
296296
@api_client.call_api(:POST, path,
297297
:header_params => header_params,
298298
:query_params => query_params,
@@ -344,7 +344,7 @@ def delete_pet(pet_id, opts = {})
344344
post_body = nil
345345

346346

347-
auth_names = ['petstore_auth']
347+
auth_names = []
348348
@api_client.call_api(:DELETE, path,
349349
:header_params => header_params,
350350
:query_params => query_params,
@@ -398,7 +398,7 @@ def upload_file(pet_id, opts = {})
398398
post_body = nil
399399

400400

401-
auth_names = ['petstore_auth']
401+
auth_names = []
402402
@api_client.call_api(:POST, path,
403403
:header_params => header_params,
404404
:query_params => query_params,

samples/client/petstore/ruby/lib/petstore/api/store_api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def get_inventory(opts = {})
4141
post_body = nil
4242

4343

44-
auth_names = ['api_key']
44+
auth_names = []
4545
result = @api_client.call_api(:GET, path,
4646
:header_params => header_params,
4747
:query_params => query_params,

samples/client/petstore/ruby/lib/petstore/api/user_api.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def logout_user(opts = {})
248248

249249
# Get user by user name
250250
#
251-
# @param username The name that needs to be fetched. Use user1 for testing.
251+
# @param username The name that needs to be fetched. Use user1 for testing.
252252
# @param [Hash] opts the optional parameters
253253
# @return [User]
254254
def get_user_by_name(username, opts = {})

0 commit comments

Comments
 (0)