Skip to content

Commit 9ecb2e9

Browse files
committed
restore sample files for objc, php and ruby
1 parent 6cc5a32 commit 9ecb2e9

File tree

17 files changed

+87
-38
lines changed

17 files changed

+87
-38
lines changed

samples/client/petstore/objc/SwaggerClient.podspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ Pod::Spec.new do |s|
2121

2222
s.framework = 'SystemConfiguration'
2323

24-
s.homepage = "https://github.com/swagger-api/swagger-codegen"
25-
s.license = "MIT"
26-
s.source = { :git => "https://github.com/swagger-api/swagger-codegen.git", :tag => "#{s.version}" }
27-
s.author = { "Swagger" => "[email protected]" }
24+
s.homepage = ""
25+
s.license = ""
26+
s.source = { :git => ".git", :tag => "#{s.version}" }
27+
s.author = { "" => "" }
2828

2929
s.source_files = 'SwaggerClient/**/*'
3030
s.public_header_files = 'SwaggerClient/**/*.h'

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

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

313313
if (match) {
314-
NSArray *dataArray = data;
315314
innerType = [class substringWithRange:[match rangeAtIndex:1]];
316315

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

335334
if (match) {
336-
NSArray *dataArray = data;
337335
innerType = [class substringWithRange:[match rangeAtIndex:1]];
338336

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

356354
if (match) {
357-
NSDictionary *dataDict = data;
358355
NSString *valueType = [class substringWithRange:[match rangeAtIndex:2]];
359356

360-
resultDict = [NSMutableDictionary dictionaryWithCapacity:[dataDict count]];
357+
resultDict = [NSMutableDictionary dictionaryWithCapacity:[data count]];
361358
[data enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
362359
[resultDict setValue:[self deserialize:obj class:valueType] forKey:key];
363360
}];
@@ -731,8 +728,7 @@ - (id) sanitizeForSerialization:(id) object {
731728
return [object ISO8601String];
732729
}
733730
else if ([object isKindOfClass:[NSArray class]]) {
734-
NSArray *objectArray = object;
735-
NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[objectArray count]];
731+
NSMutableArray *sanitizedObjs = [NSMutableArray arrayWithCapacity:[object count]];
736732
[object enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
737733
if (obj) {
738734
[sanitizedObjs addObject:[self sanitizeForSerialization:obj]];
@@ -741,8 +737,7 @@ - (id) sanitizeForSerialization:(id) object {
741737
return sanitizedObjs;
742738
}
743739
else if ([object isKindOfClass:[NSDictionary class]]) {
744-
NSDictionary *objectDict = object;
745-
NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[objectDict count]];
740+
NSMutableDictionary *sanitizedObjs = [NSMutableDictionary dictionaryWithCapacity:[object count]];
746741
[object enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
747742
if (obj) {
748743
[sanitizedObjs setValue:[self sanitizeForSerialization:obj] forKey:key];

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ - (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+
},
110117
};
111118
}
112119

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
* Do not edit the class manually.
88
*/
99

10-
#import "SWGTag.h"
1110
#import "SWGCategory.h"
11+
#import "SWGTag.h"
1212

1313

1414
@protocol SWGPet

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 = @[];
121+
NSArray *authSettings = @[@"petstore_auth"];
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 = @[];
199+
NSArray *authSettings = @[@"petstore_auth"];
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 = @[];
283+
NSArray *authSettings = @[@"petstore_auth"];
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 = @[];
367+
NSArray *authSettings = @[@"petstore_auth"];
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 = @[];
453+
NSArray *authSettings = @[@"petstore_auth", @"api_key"];
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 = @[];
545+
NSArray *authSettings = @[@"petstore_auth"];
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 = @[];
649+
NSArray *authSettings = @[@"petstore_auth"];
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 = @[];
741+
NSArray *authSettings = @[@"petstore_auth"];
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 = @[];
118+
NSArray *authSettings = @[@"api_key"];
119119

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

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999
/// Get user by user name
100100
///
101101
///
102-
/// @param username The name that needs to be fetched. Use user1 for testing.
102+
/// @param username The name that needs to be fetched. Use user1 for testing.
103103
///
104104
///
105105
/// @return SWGUser*

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ -(NSNumber*) logoutUserWithCompletionBlock:
470470
///
471471
/// Get user by user name
472472
///
473-
/// @param username The name that needs to be fetched. Use user1 for testing.
473+
/// @param username The name that needs to be fetched. Use user1 for testing.
474474
///
475475
/// @returns SWGUser*
476476
///

samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,9 @@ public function updatePet($body=null)
135135
$httpBody = $formParams; // for HTTP post (form)
136136
}
137137

138+
139+
//TODO support oauth
140+
138141
// make the API Call
139142
try
140143
{
@@ -197,6 +200,9 @@ public function addPet($body=null)
197200
$httpBody = $formParams; // for HTTP post (form)
198201
}
199202

203+
204+
//TODO support oauth
205+
200206
// make the API Call
201207
try
202208
{
@@ -258,6 +264,9 @@ public function findPetsByStatus($status=null)
258264
$httpBody = $formParams; // for HTTP post (form)
259265
}
260266

267+
268+
//TODO support oauth
269+
261270
// make the API Call
262271
try
263272
{
@@ -331,6 +340,9 @@ public function findPetsByTags($tags=null)
331340
$httpBody = $formParams; // for HTTP post (form)
332341
}
333342

343+
344+
//TODO support oauth
345+
334346
// make the API Call
335347
try
336348
{
@@ -412,6 +424,16 @@ public function getPetById($pet_id)
412424
$httpBody = $formParams; // for HTTP post (form)
413425
}
414426

427+
428+
//TODO support oauth
429+
430+
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
431+
if (isset($apiKey)) {
432+
$headerParams['api_key'] = $apiKey;
433+
}
434+
435+
436+
415437
// make the API Call
416438
try
417439
{
@@ -501,6 +523,9 @@ public function updatePetWithForm($pet_id, $name=null, $status=null)
501523
$httpBody = $formParams; // for HTTP post (form)
502524
}
503525

526+
527+
//TODO support oauth
528+
504529
// make the API Call
505530
try
506531
{
@@ -574,6 +599,9 @@ public function deletePet($pet_id, $api_key=null)
574599
$httpBody = $formParams; // for HTTP post (form)
575600
}
576601

602+
603+
//TODO support oauth
604+
577605
// make the API Call
578606
try
579607
{
@@ -651,6 +679,9 @@ public function uploadFile($pet_id, $additional_metadata=null, $file=null)
651679
$httpBody = $formParams; // for HTTP post (form)
652680
}
653681

682+
683+
//TODO support oauth
684+
654685
// make the API Call
655686
try
656687
{

samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ public function getInventory()
130130
$httpBody = $formParams; // for HTTP post (form)
131131
}
132132

133+
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
134+
if (isset($apiKey)) {
135+
$headerParams['api_key'] = $apiKey;
136+
}
137+
138+
139+
133140
// make the API Call
134141
try
135142
{

0 commit comments

Comments
 (0)