From f9ad16e7aa7a96ec558696a2e5ec95bfdd06b8d0 Mon Sep 17 00:00:00 2001 From: geekerzp Date: Wed, 22 Jul 2015 17:45:31 +0800 Subject: [PATCH 1/5] Update objc client. * Add test cases for deserialization. * Pretty print model infomation. --- .../main/resources/objc/model-body.mustache | 6 +- .../petstore/objc/SwaggerClient/SWGCategory.m | 6 +- .../petstore/objc/SwaggerClient/SWGOrder.m | 6 +- .../petstore/objc/SwaggerClient/SWGPet.m | 6 +- .../petstore/objc/SwaggerClient/SWGTag.m | 6 +- .../petstore/objc/SwaggerClient/SWGUser.m | 6 +- .../SwaggerClient.xcodeproj/project.pbxproj | 8 ++ .../SwaggerClient/SWGViewController.m | 30 ++++- .../Tests/DeserializationTest.m | 119 ++++++++++++++++++ .../objc/SwaggerClientTests/Tests/PetTest.m | 37 ++++++ .../Tests/SWGApiClientTest.m | 73 ----------- 11 files changed, 222 insertions(+), 81 deletions(-) create mode 100644 samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m create mode 100644 samples/client/petstore/objc/SwaggerClientTests/Tests/PetTest.m diff --git a/modules/swagger-codegen/src/main/resources/objc/model-body.mustache b/modules/swagger-codegen/src/main/resources/objc/model-body.mustache index b728e6bb06c..6e93823b1f5 100644 --- a/modules/swagger-codegen/src/main/resources/objc/model-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/model-body.mustache @@ -3,7 +3,7 @@ #import "{{classname}}.h" @implementation {{classname}} - + + (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ {{#vars}}@"{{baseName}}": @"{{name}}"{{#hasMore}}, {{/hasMore}}{{/vars}} }]; @@ -21,6 +21,10 @@ } } +- (NSString *)description { + return [[self toDictionary] description]; +} + {{/model}} @end {{/models}} diff --git a/samples/client/petstore/objc/SwaggerClient/SWGCategory.m b/samples/client/petstore/objc/SwaggerClient/SWGCategory.m index c41f76a5247..ebe7326d1bb 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGCategory.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGCategory.m @@ -1,7 +1,7 @@ #import "SWGCategory.h" @implementation SWGCategory - + + (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }]; @@ -19,4 +19,8 @@ } } +- (NSString *)description { + return [[self toDictionary] description]; +} + @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m index 5d3179446ed..d511eee2e08 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m @@ -1,7 +1,7 @@ #import "SWGOrder.h" @implementation SWGOrder - + + (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"complete": @"complete" }]; @@ -19,4 +19,8 @@ } } +- (NSString *)description { + return [[self toDictionary] description]; +} + @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPet.m b/samples/client/petstore/objc/SwaggerClient/SWGPet.m index d5559aa6f72..33c20c2dd20 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPet.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGPet.m @@ -1,7 +1,7 @@ #import "SWGPet.h" @implementation SWGPet - + + (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"category": @"category", @"name": @"name", @"photoUrls": @"photoUrls", @"tags": @"tags", @"status": @"status" }]; @@ -19,4 +19,8 @@ } } +- (NSString *)description { + return [[self toDictionary] description]; +} + @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGTag.m b/samples/client/petstore/objc/SwaggerClient/SWGTag.m index 5d48a099070..5a2f395e7ad 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGTag.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGTag.m @@ -1,7 +1,7 @@ #import "SWGTag.h" @implementation SWGTag - + + (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }]; @@ -19,4 +19,8 @@ } } +- (NSString *)description { + return [[self toDictionary] description]; +} + @end diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUser.m b/samples/client/petstore/objc/SwaggerClient/SWGUser.m index 060b65ffa12..1ee47811995 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUser.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGUser.m @@ -1,7 +1,7 @@ #import "SWGUser.h" @implementation SWGUser - + + (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"username": @"username", @"firstName": @"firstName", @"lastName": @"lastName", @"email": @"email", @"password": @"password", @"phone": @"phone", @"userStatus": @"userStatus" }]; @@ -19,4 +19,8 @@ } } +- (NSString *)description { + return [[self toDictionary] description]; +} + @end diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj index 0ba21c560ef..a5fe06f63b7 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj +++ b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj @@ -23,6 +23,8 @@ 6003F5BC195388D20070C39A /* Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6003F5BB195388D20070C39A /* Tests.m */; }; 873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; }; 94BE6BE84795B5034A811E61 /* libPods-SwaggerClient_Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8D46325ECAD48245C07F6733 /* libPods-SwaggerClient_Example.a */; }; + CF0ADB481B5F95D6008A2729 /* PetTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CF0ADB471B5F95D6008A2729 /* PetTest.m */; }; + CF8F71391B5F73AC00162980 /* DeserializationTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CF8F71381B5F73AC00162980 /* DeserializationTest.m */; }; CFDFB4121B3CFFA8009739C5 /* UserApiTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CFDFB40D1B3CFEC3009739C5 /* UserApiTest.m */; }; CFDFB4131B3CFFDD009739C5 /* PetApiTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CFDFB40A1B3CFEC3009739C5 /* PetApiTest.m */; }; CFDFB4141B3CFFF6009739C5 /* StoreApiTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CFDFB40B1B3CFEC3009739C5 /* StoreApiTest.m */; }; @@ -65,6 +67,8 @@ 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; }; 8D46325ECAD48245C07F6733 /* libPods-SwaggerClient_Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SwaggerClient_Example.a"; sourceTree = BUILT_PRODUCTS_DIR; }; BFB4BE760737508B3CFC23B2 /* Pods-SwaggerClient_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwaggerClient_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-SwaggerClient_Example/Pods-SwaggerClient_Example.release.xcconfig"; sourceTree = ""; }; + CF0ADB471B5F95D6008A2729 /* PetTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PetTest.m; sourceTree = ""; }; + CF8F71381B5F73AC00162980 /* DeserializationTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DeserializationTest.m; sourceTree = ""; }; CFDFB40A1B3CFEC3009739C5 /* PetApiTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PetApiTest.m; sourceTree = ""; }; CFDFB40B1B3CFEC3009739C5 /* StoreApiTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StoreApiTest.m; sourceTree = ""; }; CFDFB40C1B3CFEC3009739C5 /* SWGApiClientTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGApiClientTest.m; sourceTree = ""; }; @@ -166,6 +170,8 @@ CFDFB40A1B3CFEC3009739C5 /* PetApiTest.m */, CFDFB40B1B3CFEC3009739C5 /* StoreApiTest.m */, CFDFB40C1B3CFEC3009739C5 /* SWGApiClientTest.m */, + CF0ADB471B5F95D6008A2729 /* PetTest.m */, + CF8F71381B5F73AC00162980 /* DeserializationTest.m */, CFDFB40D1B3CFEC3009739C5 /* UserApiTest.m */, 6003F5BB195388D20070C39A /* Tests.m */, 6003F5B6195388D20070C39A /* Supporting Files */, @@ -374,10 +380,12 @@ buildActionMask = 2147483647; files = ( CFDFB4141B3CFFF6009739C5 /* StoreApiTest.m in Sources */, + CF0ADB481B5F95D6008A2729 /* PetTest.m in Sources */, CFDFB4131B3CFFDD009739C5 /* PetApiTest.m in Sources */, 6003F5BC195388D20070C39A /* Tests.m in Sources */, CFDFB4151B3D000B009739C5 /* SWGApiClientTest.m in Sources */, CFDFB4121B3CFFA8009739C5 /* UserApiTest.m in Sources */, + CF8F71391B5F73AC00162980 /* DeserializationTest.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGViewController.m b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGViewController.m index a56f31408aa..d538fe49fdc 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGViewController.m +++ b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGViewController.m @@ -7,6 +7,7 @@ // #import "SWGViewController.h" +#import @interface SWGViewController () @@ -17,13 +18,38 @@ - (void)viewDidLoad { [super viewDidLoad]; - // Do any additional setup after loading the view, typically from a nib. + SWGPet *pet = [self createPet]; + NSLog(@"%@", pet); } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; - // Dispose of any resources that can be recreated. +} + +- (SWGPet*) createPet { + SWGPet * pet = [[SWGPet alloc] init]; + pet._id = [[NSNumber alloc] initWithLong:[[NSDate date] timeIntervalSince1970]]; + pet.name = @"monkey"; + + SWGCategory * category = [[SWGCategory alloc] init]; + category._id = [[NSNumber alloc] initWithInteger:arc4random_uniform(100000)]; + category.name = @"super-happy"; + pet.category = category; + + SWGTag *tag1 = [[SWGTag alloc] init]; + tag1._id = [[NSNumber alloc] initWithInteger:arc4random_uniform(100000)]; + tag1.name = @"test tag 1"; + SWGTag *tag2 = [[SWGTag alloc] init]; + tag2._id = [[NSNumber alloc] initWithInteger:arc4random_uniform(100000)]; + tag2.name = @"test tag 2"; + pet.tags = (NSArray *)[[NSArray alloc] initWithObjects:tag1, tag2, nil]; + + pet.status = @"available"; + + NSArray * photos = [[NSArray alloc] initWithObjects:@"http://foo.bar.com/3", @"http://foo.bar.com/4", nil]; + pet.photoUrls = photos; + return pet; } @end diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m b/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m new file mode 100644 index 00000000000..2650dde31d0 --- /dev/null +++ b/samples/client/petstore/objc/SwaggerClientTests/Tests/DeserializationTest.m @@ -0,0 +1,119 @@ +#import +#import +#import +#import + +@interface DeserializationTest : XCTestCase { + +@private SWGApiClient *apiClient; + +} + +@end + +@implementation DeserializationTest + +- (void)setUp { + [super setUp]; + apiClient = [[SWGApiClient alloc] init]; +} + +- (void)testDeserializeDate { + NSString *dateStr = @"2012-09-27"; + + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + NSTimeZone *timezone = [NSTimeZone timeZoneWithName:@"UTC"]; + [formatter setTimeZone:timezone]; + [formatter setDateFormat:@"yyyy-MM-dd"]; + NSDate *date = [formatter dateFromString:dateStr]; + + NSDate *deserializedDate = [apiClient deserialize:dateStr class:@"NSDate*"]; + + XCTAssertEqualWithAccuracy([date timeIntervalSinceReferenceDate], [deserializedDate timeIntervalSinceReferenceDate], 0.001); +} + +- (void)testDeserializeDateTime { + NSString *dateTimeStr = @"1997-07-16T19:20:30+00:00"; + + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + [formatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZ"]; + NSDate *dateTime = [formatter dateFromString:dateTimeStr]; + + NSDate *deserializedDateTime = [apiClient deserialize:dateTimeStr class:@"NSDate*"]; + + XCTAssertEqualWithAccuracy([dateTime timeIntervalSinceReferenceDate], [deserializedDateTime timeIntervalSinceReferenceDate], 0.001); +} + +- (void)testDeserializeObject { + XCTAssertTrue([[apiClient deserialize:@"" class:@"NSObject*"] isKindOfClass:[NSObject class]]); +} + +- (void)testDeserializeString { + NSString *data = @"test string"; + NSString *result = [apiClient deserialize:data class:@"NSString*"]; + + XCTAssertTrue([result isEqualToString:data]); +} + +- (void)testDeserializeListOfModels { + NSArray *data = + @[ + @{ + @"id": @119, + @"category": @{ + @"id": @0, + @"name": @"string" + }, + @"name": @"doggie", + @"photoUrls": @[ + @"string" + ], + @"tags": @[ + @{ + @"id": @0, + @"name": @"string" + } + ], + @"status": @"available" + + }]; + + NSArray *result = [apiClient deserialize:data class:@"NSArray*"]; + + XCTAssertTrue([result isKindOfClass:[NSArray class]]); + XCTAssertTrue([[result firstObject] isKindOfClass:[SWGPet class]]); + XCTAssertEqualObjects([[result firstObject] _id], @119); +} + +- (void)testDeserializeMapOfModels { + NSDictionary *data = + @{ + @"pet": @{ + @"id": @119, + @"category": @{ + @"id": @0, + @"name": @"string" + }, + @"name": @"doggie", + @"photoUrls": @[ + @"string" + ], + @"tags": @[ + @{ + @"id": @0, + @"name": @"string" + } + ], + @"status": @"available" + + } + }; + + NSDictionary *result = [apiClient deserialize:data class:@"NSDictionary* /* NSString, SWGPet */"]; + + XCTAssertTrue([result isKindOfClass:[NSDictionary class]]); + XCTAssertTrue([result[@"pet"] isKindOfClass:[SWGPet class]]); + XCTAssertEqualObjects([result[@"pet"] _id], @119); +} + +@end diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/PetTest.m b/samples/client/petstore/objc/SwaggerClientTests/Tests/PetTest.m new file mode 100644 index 00000000000..9dbde13310b --- /dev/null +++ b/samples/client/petstore/objc/SwaggerClientTests/Tests/PetTest.m @@ -0,0 +1,37 @@ +#import +#import +#import + +@interface PetTest : XCTestCase { + +@private SWGPet *pet; + +} + +@end + +@implementation PetTest + +- (void)setUp { + [super setUp]; + + NSDictionary *petDict = @{ @"id": @1, @"name": @"test pet", + @"status": @"sold", + @"photoUrls": @[@"string"], + @"category": @{ @"id": @1, @"name": @"test category" }, + @"tags": @[ @{ @"id": @1, @"name": @"test tag" } ]}; + pet = [[SWGPet alloc] initWithDictionary:petDict error:nil]; +} + +- (void)testDescription { + NSDictionary *petDict = @{ @"id": @1, @"name": @"test pet", + @"status": @"sold", + @"photoUrls": @[@"string"], + @"category": @{ @"id": @1, @"name": @"test category" }, + @"tags": @[ @{ @"id": @1, @"name": @"test tag" } ]}; + NSString *petStr = [petDict description]; + + XCTAssertTrue([[pet description] isEqualToString:petStr]); +} + +@end diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m b/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m index 00c6bf70da6..6365632ea2d 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m +++ b/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m @@ -98,77 +98,4 @@ XCTAssertEqualObjects(basicAuthCredentials, [config getBasicAuthToken]); } -- (void)testDeserialize { - id data; - id result; - - // list of models - data = - @[ - @{ - @"id": @119, - @"category": @{ - @"id": @0, - @"name": @"string" - }, - @"name": @"doggie", - @"photoUrls": @[ - @"string" - ], - @"tags": @[ - @{ - @"id": @0, - @"name": @"string" - } - ], - @"status": @"available" - - }]; - result = [self.apiClient deserialize:data class:@"NSArray*"]; - - XCTAssertTrue([result isKindOfClass:[NSArray class]]); - XCTAssertTrue([[result firstObject] isKindOfClass:[SWGPet class]]); - XCTAssertEqualObjects([[result firstObject] _id], @119); - - // map of models - data = - @{ - @"pet": @{ - @"id": @119, - @"category": @{ - @"id": @0, - @"name": @"string" - }, - @"name": @"doggie", - @"photoUrls": @[ - @"string" - ], - @"tags": @[ - @{ - @"id": @0, - @"name": @"string" - } - ], - @"status": @"available" - - } - }; - result = [self.apiClient deserialize:data class:@"NSDictionary* /* NSString, SWGPet */"]; - - XCTAssertTrue([result isKindOfClass:[NSDictionary class]]); - XCTAssertTrue([result[@"pet"] isKindOfClass:[SWGPet class]]); - XCTAssertEqualObjects([result[@"pet"] _id], @119); - - // pure object - result = [self.apiClient deserialize:@"" class:@"NSObject*"]; - - XCTAssertTrue([result isKindOfClass:[NSObject class]]); - - // NSString - data = @"test string"; - result = [self.apiClient deserialize:data class:@"NSString*"]; - - XCTAssertTrue([result isKindOfClass:[NSString class]]); -} - @end From 37c79525f7b6ecf7c776301474f0ec6dbd734ec3 Mon Sep 17 00:00:00 2001 From: geekerzp Date: Wed, 22 Jul 2015 18:31:50 +0800 Subject: [PATCH 2/5] Update model body template in objc client. * Add some comments. --- .../src/main/resources/objc/model-body.mustache | 13 +++++++++++++ .../petstore/objc/SwaggerClient/SWGCategory.m | 13 +++++++++++++ .../client/petstore/objc/SwaggerClient/SWGOrder.m | 13 +++++++++++++ samples/client/petstore/objc/SwaggerClient/SWGPet.m | 13 +++++++++++++ samples/client/petstore/objc/SwaggerClient/SWGTag.m | 13 +++++++++++++ .../client/petstore/objc/SwaggerClient/SWGUser.m | 13 +++++++++++++ 6 files changed, 78 insertions(+) diff --git a/modules/swagger-codegen/src/main/resources/objc/model-body.mustache b/modules/swagger-codegen/src/main/resources/objc/model-body.mustache index 6e93823b1f5..4ce1155a820 100644 --- a/modules/swagger-codegen/src/main/resources/objc/model-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/model-body.mustache @@ -4,11 +4,20 @@ @implementation {{classname}} +/** + * Maps json key to property name. + * This method is used by `JSONModel`. + */ + (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ {{#vars}}@"{{baseName}}": @"{{name}}"{{#hasMore}}, {{/hasMore}}{{/vars}} }]; } +/** + * Indicates whether the property with the given name is optional. + * If `propertyName` is optional, then return `YES`, or return `NO`. + * This method is used by `JSONModel`. + */ + (BOOL)propertyIsOptional:(NSString *)propertyName { NSArray *optionalProperties = @[{{#vars}}{{^required}}@"{{name}}"{{#hasMore}}, {{/hasMore}}{{/required}}{{/vars}}]; @@ -21,6 +30,10 @@ } } +/** + * Return a string that represents the properties json of the model. + * This method will be called when logging model object using `NSLog`. + */ - (NSString *)description { return [[self toDictionary] description]; } diff --git a/samples/client/petstore/objc/SwaggerClient/SWGCategory.m b/samples/client/petstore/objc/SwaggerClient/SWGCategory.m index ebe7326d1bb..8d41527ea2a 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGCategory.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGCategory.m @@ -2,11 +2,20 @@ @implementation SWGCategory +/** + * Maps json key to property name. + * This method is used by `JSONModel`. + */ + (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }]; } +/** + * Indicates whether the property with the given name is optional. + * If `propertyName` is optional, then return `YES`, or return `NO`. + * This method is used by `JSONModel`. + */ + (BOOL)propertyIsOptional:(NSString *)propertyName { NSArray *optionalProperties = @[@"_id", @"name"]; @@ -19,6 +28,10 @@ } } +/** + * Return a string that represents the properties json of the model. + * This method will be called when logging model object using `NSLog`. + */ - (NSString *)description { return [[self toDictionary] description]; } diff --git a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m index d511eee2e08..950edd796a9 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m @@ -2,11 +2,20 @@ @implementation SWGOrder +/** + * Maps json key to property name. + * This method is used by `JSONModel`. + */ + (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"petId": @"petId", @"quantity": @"quantity", @"shipDate": @"shipDate", @"status": @"status", @"complete": @"complete" }]; } +/** + * Indicates whether the property with the given name is optional. + * If `propertyName` is optional, then return `YES`, or return `NO`. + * This method is used by `JSONModel`. + */ + (BOOL)propertyIsOptional:(NSString *)propertyName { NSArray *optionalProperties = @[@"_id", @"petId", @"quantity", @"shipDate", @"status", @"complete"]; @@ -19,6 +28,10 @@ } } +/** + * Return a string that represents the properties json of the model. + * This method will be called when logging model object using `NSLog`. + */ - (NSString *)description { return [[self toDictionary] description]; } diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPet.m b/samples/client/petstore/objc/SwaggerClient/SWGPet.m index 33c20c2dd20..48a0940338c 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPet.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGPet.m @@ -2,11 +2,20 @@ @implementation SWGPet +/** + * Maps json key to property name. + * This method is used by `JSONModel`. + */ + (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"category": @"category", @"name": @"name", @"photoUrls": @"photoUrls", @"tags": @"tags", @"status": @"status" }]; } +/** + * Indicates whether the property with the given name is optional. + * If `propertyName` is optional, then return `YES`, or return `NO`. + * This method is used by `JSONModel`. + */ + (BOOL)propertyIsOptional:(NSString *)propertyName { NSArray *optionalProperties = @[@"_id", @"category", @"tags", @"status"]; @@ -19,6 +28,10 @@ } } +/** + * Return a string that represents the properties json of the model. + * This method will be called when logging model object using `NSLog`. + */ - (NSString *)description { return [[self toDictionary] description]; } diff --git a/samples/client/petstore/objc/SwaggerClient/SWGTag.m b/samples/client/petstore/objc/SwaggerClient/SWGTag.m index 5a2f395e7ad..1ee6964e60c 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGTag.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGTag.m @@ -2,11 +2,20 @@ @implementation SWGTag +/** + * Maps json key to property name. + * This method is used by `JSONModel`. + */ + (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"name": @"name" }]; } +/** + * Indicates whether the property with the given name is optional. + * If `propertyName` is optional, then return `YES`, or return `NO`. + * This method is used by `JSONModel`. + */ + (BOOL)propertyIsOptional:(NSString *)propertyName { NSArray *optionalProperties = @[@"_id", @"name"]; @@ -19,6 +28,10 @@ } } +/** + * Return a string that represents the properties json of the model. + * This method will be called when logging model object using `NSLog`. + */ - (NSString *)description { return [[self toDictionary] description]; } diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUser.m b/samples/client/petstore/objc/SwaggerClient/SWGUser.m index 1ee47811995..934b91fba73 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUser.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGUser.m @@ -2,11 +2,20 @@ @implementation SWGUser +/** + * Maps json key to property name. + * This method is used by `JSONModel`. + */ + (JSONKeyMapper *)keyMapper { return [[JSONKeyMapper alloc] initWithDictionary:@{ @"id": @"_id", @"username": @"username", @"firstName": @"firstName", @"lastName": @"lastName", @"email": @"email", @"password": @"password", @"phone": @"phone", @"userStatus": @"userStatus" }]; } +/** + * Indicates whether the property with the given name is optional. + * If `propertyName` is optional, then return `YES`, or return `NO`. + * This method is used by `JSONModel`. + */ + (BOOL)propertyIsOptional:(NSString *)propertyName { NSArray *optionalProperties = @[@"_id", @"username", @"firstName", @"lastName", @"email", @"password", @"phone", @"userStatus"]; @@ -19,6 +28,10 @@ } } +/** + * Return a string that represents the properties json of the model. + * This method will be called when logging model object using `NSLog`. + */ - (NSString *)description { return [[self toDictionary] description]; } From 08ea05f7a14fbfc02dc38ec1a33942940845e950 Mon Sep 17 00:00:00 2001 From: geekerzp Date: Thu, 23 Jul 2015 16:03:38 +0800 Subject: [PATCH 3/5] Update objc client. * Add comments in SWGConfiguration.h * Change `Date` to `date` in ObjcClientCodegen.java * Update comments in model body template --- .../codegen/languages/ObjcClientCodegen.java | 2 +- .../objc/Configuration-body.mustache | 22 ++++--- .../objc/Configuration-header.mustache | 63 ++++++++++++++++--- .../main/resources/objc/model-body.mustache | 4 +- .../petstore/objc/SwaggerClient/SWGCategory.m | 4 +- .../objc/SwaggerClient/SWGConfiguration.h | 63 ++++++++++++++++--- .../objc/SwaggerClient/SWGConfiguration.m | 22 ++++--- .../petstore/objc/SwaggerClient/SWGOrder.m | 4 +- .../petstore/objc/SwaggerClient/SWGPet.m | 4 +- .../petstore/objc/SwaggerClient/SWGTag.m | 4 +- .../petstore/objc/SwaggerClient/SWGUser.m | 4 +- .../SwaggerClient/SWGViewController.m | 8 ++- .../Tests/SWGApiClientTest.m | 4 +- 13 files changed, 161 insertions(+), 47 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java index 0fdb19e806d..3e5edbc169f 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ObjcClientCodegen.java @@ -57,7 +57,7 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { typeMapping.clear(); typeMapping.put("enum", "NSString"); - typeMapping.put("Date", "NSDate"); + typeMapping.put("date", "NSDate"); typeMapping.put("DateTime", "NSDate"); typeMapping.put("boolean", "NSNumber"); typeMapping.put("string", "NSString"); diff --git a/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache b/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache index 832c69f417e..75d73d6e414 100644 --- a/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/Configuration-body.mustache @@ -60,12 +60,20 @@ #pragma mark - Setter Methods -- (void) setValue:(NSString *)value forApiKeyField:(NSString *)field { - [self.mutableApiKey setValue:value forKey:field]; +- (void) setApiKey:(NSString *)apiKey forApiKeyIdentifier:(NSString *)identifier { + [self.mutableApiKey setValue:apiKey forKey:identifier]; } -- (void) setValue:(NSString *)value forApiKeyPrefixField:(NSString *)field { - [self.mutableApiKeyPrefix setValue:value forKey:field]; +- (void) removeApiKey:(NSString *)identifier { + [self.mutableApiKey removeObjectForKey:identifier]; +} + +- (void) setApiKeyPrefix:(NSString *)prefix forApiKeyPrefixIdentifier:(NSString *)identifier { + [self.mutableApiKeyPrefix setValue:prefix forKey:identifier]; +} + +- (void) removeApiKeyPrefix:(NSString *)identifier { + [self.mutableApiKeyPrefix removeObjectForKey:identifier]; } - (void) setLoggingFile:(NSString *)loggingFile { @@ -75,10 +83,10 @@ } _loggingFile = loggingFile; - self.loggingFileHanlder = [NSFileHandle fileHandleForWritingAtPath:_loggingFile]; - if (self.loggingFileHanlder == nil) { + _loggingFileHanlder = [NSFileHandle fileHandleForWritingAtPath:_loggingFile]; + if (_loggingFileHanlder == nil) { [[NSFileManager defaultManager] createFileAtPath:_loggingFile contents:nil attributes:nil]; - self.loggingFileHanlder = [NSFileHandle fileHandleForWritingAtPath:_loggingFile]; + _loggingFileHanlder = [NSFileHandle fileHandleForWritingAtPath:_loggingFile]; } } diff --git a/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache b/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache index 4f9518ea9d1..2ec6e18e9d5 100644 --- a/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache @@ -1,26 +1,36 @@ #import +/** The `{{classPrefix}}Configuration` class manages the configurations for the sdk. + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ @interface {{classPrefix}}Configuration : NSObject /** * Api key values for Api Key type Authentication * - * To add or remove api key, use `setValue:forApiKeyField:`. + * To add or remove api key, use `setApiKey:forApiKeyIdentifier:`. */ @property (readonly, nonatomic, strong) NSDictionary *apiKey; /** * Api key prefix values to be prepend to the respective api key * - * To add or remove prefix, use `setValue:forApiKeyPrefixField:`. + * To add or remove prefix, use `setApiKeyPrefix:forApiKeyPrefixIdentifier:`. */ @property (readonly, nonatomic, strong) NSDictionary *apiKeyPrefix; /** - * Usename and Password for Basic type Authentication + * Usename for HTTP Basic Authentication + */ + @property (nonatomic) NSString *username; + +/** + * Password for HTTP Basic Authentication */ -@property (nonatomic) NSString *username; @property (nonatomic) NSString *password; /** @@ -31,9 +41,21 @@ /** * Logging Settings */ + +/** + * Debug switch, default false + */ @property (nonatomic) BOOL debug; + +/** + * Debug file location, default nil + */ @property (nonatomic) NSString *loggingFile; -@property (nonatomic) NSFileHandle *loggingFileHanlder; + +/** + * Log file handler, this property is used by sdk internally. + */ +@property (nonatomic, readonly) NSFileHandle *loggingFileHanlder; /** * Get configuration singleton instance @@ -41,14 +63,39 @@ + (instancetype) sharedConfig; /** - * Sets field in `apiKey` + * Sets field in `apiKey`. + * + * To remove a apiKey for a identifier, just set the apiKey to nil. + * + * @param apiKey The apiKey value. + * @param identifier The apiKey name. + * */ -- (void) setValue:(NSString *)value forApiKeyField:(NSString*)field; +- (void) setApiKey:(NSString *)apiKey forApiKeyIdentifier:(NSString*)identifier; + +/** + * Remove api key + * + * @param identifier The apiKey name. + */ +- (void) removeApiKey:(NSString *)identifier; /** * Sets field in `apiKeyPrefix` + * + * To remove a apiKeyPrefix for a identifier, just set the apiKeyPrefix to nil. + * + * @param apiKeyPrefix The apiKeyPrefix value. + * @param identifier The apiKeyPrefix name. */ -- (void) setValue:(NSString *)value forApiKeyPrefixField:(NSString *)field; +- (void) setApiKeyPrefix:(NSString *)prefix forApiKeyPrefixIdentifier:(NSString *)identifier; + +/** + * Remove api key prefix + * + * @param identifier The apiKeyPrefix name. + */ +- (void) removeApiKeyPrefix:(NSString *)identifier; /** * Get API key (with prefix if set) diff --git a/modules/swagger-codegen/src/main/resources/objc/model-body.mustache b/modules/swagger-codegen/src/main/resources/objc/model-body.mustache index 4ce1155a820..209cd7bf5a5 100644 --- a/modules/swagger-codegen/src/main/resources/objc/model-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/model-body.mustache @@ -15,7 +15,7 @@ /** * Indicates whether the property with the given name is optional. - * If `propertyName` is optional, then return `YES`, or return `NO`. + * If `propertyName` is optional, then return `YES`, otherwise return `NO`. * This method is used by `JSONModel`. */ + (BOOL)propertyIsOptional:(NSString *)propertyName @@ -31,7 +31,7 @@ } /** - * Return a string that represents the properties json of the model. + * Returns a string that represents the properties json of the model. * This method will be called when logging model object using `NSLog`. */ - (NSString *)description { diff --git a/samples/client/petstore/objc/SwaggerClient/SWGCategory.m b/samples/client/petstore/objc/SwaggerClient/SWGCategory.m index 8d41527ea2a..d2ac30e403b 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGCategory.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGCategory.m @@ -13,7 +13,7 @@ /** * Indicates whether the property with the given name is optional. - * If `propertyName` is optional, then return `YES`, or return `NO`. + * If `propertyName` is optional, then return `YES`, otherwise return `NO`. * This method is used by `JSONModel`. */ + (BOOL)propertyIsOptional:(NSString *)propertyName @@ -29,7 +29,7 @@ } /** - * Return a string that represents the properties json of the model. + * Returns a string that represents the properties json of the model. * This method will be called when logging model object using `NSLog`. */ - (NSString *)description { diff --git a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.h b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.h index d3619c72ab5..d1176257779 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.h @@ -1,26 +1,36 @@ #import +/** The `SWGConfiguration` class manages the configurations for the sdk. + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ @interface SWGConfiguration : NSObject /** * Api key values for Api Key type Authentication * - * To add or remove api key, use `setValue:forApiKeyField:`. + * To add or remove api key, use `setApiKey:forApiKeyIdentifier:`. */ @property (readonly, nonatomic, strong) NSDictionary *apiKey; /** * Api key prefix values to be prepend to the respective api key * - * To add or remove prefix, use `setValue:forApiKeyPrefixField:`. + * To add or remove prefix, use `setApiKeyPrefix:forApiKeyPrefixIdentifier:`. */ @property (readonly, nonatomic, strong) NSDictionary *apiKeyPrefix; /** - * Usename and Password for Basic type Authentication + * Usename for HTTP Basic Authentication + */ + @property (nonatomic) NSString *username; + +/** + * Password for HTTP Basic Authentication */ -@property (nonatomic) NSString *username; @property (nonatomic) NSString *password; /** @@ -31,9 +41,21 @@ /** * Logging Settings */ + +/** + * Debug switch, default false + */ @property (nonatomic) BOOL debug; + +/** + * Debug file location, default nil + */ @property (nonatomic) NSString *loggingFile; -@property (nonatomic) NSFileHandle *loggingFileHanlder; + +/** + * Log file handler, this property is used by sdk internally. + */ +@property (nonatomic, readonly) NSFileHandle *loggingFileHanlder; /** * Get configuration singleton instance @@ -41,14 +63,39 @@ + (instancetype) sharedConfig; /** - * Sets field in `apiKey` + * Sets field in `apiKey`. + * + * To remove a apiKey for a identifier, just set the apiKey to nil. + * + * @param apiKey The apiKey value. + * @param identifier The apiKey name. + * */ -- (void) setValue:(NSString *)value forApiKeyField:(NSString*)field; +- (void) setApiKey:(NSString *)apiKey forApiKeyIdentifier:(NSString*)identifier; + +/** + * Remove api key + * + * @param identifier The apiKey name. + */ +- (void) removeApiKey:(NSString *)identifier; /** * Sets field in `apiKeyPrefix` + * + * To remove a apiKeyPrefix for a identifier, just set the apiKeyPrefix to nil. + * + * @param apiKeyPrefix The apiKeyPrefix value. + * @param identifier The apiKeyPrefix name. */ -- (void) setValue:(NSString *)value forApiKeyPrefixField:(NSString *)field; +- (void) setApiKeyPrefix:(NSString *)prefix forApiKeyPrefixIdentifier:(NSString *)identifier; + +/** + * Remove api key prefix + * + * @param identifier The apiKeyPrefix name. + */ +- (void) removeApiKeyPrefix:(NSString *)identifier; /** * Get API key (with prefix if set) diff --git a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m index 81e308a53fc..0e0e70e27ea 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.m @@ -60,12 +60,20 @@ #pragma mark - Setter Methods -- (void) setValue:(NSString *)value forApiKeyField:(NSString *)field { - [self.mutableApiKey setValue:value forKey:field]; +- (void) setApiKey:(NSString *)apiKey forApiKeyIdentifier:(NSString *)identifier { + [self.mutableApiKey setValue:apiKey forKey:identifier]; } -- (void) setValue:(NSString *)value forApiKeyPrefixField:(NSString *)field { - [self.mutableApiKeyPrefix setValue:value forKey:field]; +- (void) removeApiKey:(NSString *)identifier { + [self.mutableApiKey removeObjectForKey:identifier]; +} + +- (void) setApiKeyPrefix:(NSString *)prefix forApiKeyPrefixIdentifier:(NSString *)identifier { + [self.mutableApiKeyPrefix setValue:prefix forKey:identifier]; +} + +- (void) removeApiKeyPrefix:(NSString *)identifier { + [self.mutableApiKeyPrefix removeObjectForKey:identifier]; } - (void) setLoggingFile:(NSString *)loggingFile { @@ -75,10 +83,10 @@ } _loggingFile = loggingFile; - self.loggingFileHanlder = [NSFileHandle fileHandleForWritingAtPath:_loggingFile]; - if (self.loggingFileHanlder == nil) { + _loggingFileHanlder = [NSFileHandle fileHandleForWritingAtPath:_loggingFile]; + if (_loggingFileHanlder == nil) { [[NSFileManager defaultManager] createFileAtPath:_loggingFile contents:nil attributes:nil]; - self.loggingFileHanlder = [NSFileHandle fileHandleForWritingAtPath:_loggingFile]; + _loggingFileHanlder = [NSFileHandle fileHandleForWritingAtPath:_loggingFile]; } } diff --git a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m index 950edd796a9..e2ee7a1f321 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m @@ -13,7 +13,7 @@ /** * Indicates whether the property with the given name is optional. - * If `propertyName` is optional, then return `YES`, or return `NO`. + * If `propertyName` is optional, then return `YES`, otherwise return `NO`. * This method is used by `JSONModel`. */ + (BOOL)propertyIsOptional:(NSString *)propertyName @@ -29,7 +29,7 @@ } /** - * Return a string that represents the properties json of the model. + * Returns a string that represents the properties json of the model. * This method will be called when logging model object using `NSLog`. */ - (NSString *)description { diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPet.m b/samples/client/petstore/objc/SwaggerClient/SWGPet.m index 48a0940338c..1d1965cfa04 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPet.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGPet.m @@ -13,7 +13,7 @@ /** * Indicates whether the property with the given name is optional. - * If `propertyName` is optional, then return `YES`, or return `NO`. + * If `propertyName` is optional, then return `YES`, otherwise return `NO`. * This method is used by `JSONModel`. */ + (BOOL)propertyIsOptional:(NSString *)propertyName @@ -29,7 +29,7 @@ } /** - * Return a string that represents the properties json of the model. + * Returns a string that represents the properties json of the model. * This method will be called when logging model object using `NSLog`. */ - (NSString *)description { diff --git a/samples/client/petstore/objc/SwaggerClient/SWGTag.m b/samples/client/petstore/objc/SwaggerClient/SWGTag.m index 1ee6964e60c..36215d9482c 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGTag.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGTag.m @@ -13,7 +13,7 @@ /** * Indicates whether the property with the given name is optional. - * If `propertyName` is optional, then return `YES`, or return `NO`. + * If `propertyName` is optional, then return `YES`, otherwise return `NO`. * This method is used by `JSONModel`. */ + (BOOL)propertyIsOptional:(NSString *)propertyName @@ -29,7 +29,7 @@ } /** - * Return a string that represents the properties json of the model. + * Returns a string that represents the properties json of the model. * This method will be called when logging model object using `NSLog`. */ - (NSString *)description { diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUser.m b/samples/client/petstore/objc/SwaggerClient/SWGUser.m index 934b91fba73..ecf7ee5ad7d 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUser.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGUser.m @@ -13,7 +13,7 @@ /** * Indicates whether the property with the given name is optional. - * If `propertyName` is optional, then return `YES`, or return `NO`. + * If `propertyName` is optional, then return `YES`, otherwise return `NO`. * This method is used by `JSONModel`. */ + (BOOL)propertyIsOptional:(NSString *)propertyName @@ -29,7 +29,7 @@ } /** - * Return a string that represents the properties json of the model. + * Returns a string that represents the properties json of the model. * This method will be called when logging model object using `NSLog`. */ - (NSString *)description { diff --git a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGViewController.m b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGViewController.m index d538fe49fdc..5fe98be055f 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGViewController.m +++ b/samples/client/petstore/objc/SwaggerClientTests/SwaggerClient/SWGViewController.m @@ -8,6 +8,7 @@ #import "SWGViewController.h" #import +#import @interface SWGViewController () @@ -18,8 +19,11 @@ - (void)viewDidLoad { [super viewDidLoad]; - SWGPet *pet = [self createPet]; - NSLog(@"%@", pet); + SWGConfiguration *config = [SWGConfiguration sharedConfig]; + [config setApiKey:@"hello" forApiKeyIdentifier:@"world"]; + [config setApiKey:@"geekerzp" forApiKeyIdentifier:@"zp"]; + [config removeApiKey:@"zp"]; + NSLog(@"%@", config.apiKey); } - (void)didReceiveMemoryWarning diff --git a/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m b/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m index 6365632ea2d..d19180dc008 100644 --- a/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m +++ b/samples/client/petstore/objc/SwaggerClientTests/Tests/SWGApiClientTest.m @@ -61,8 +61,8 @@ - (void)testConfiguration { SWGConfiguration *config = [SWGConfiguration sharedConfig]; - [config setValue:@"123456" forApiKeyField:@"api_key"]; - [config setValue:@"PREFIX" forApiKeyPrefixField:@"api_key"]; + [config setApiKey:@"123456" forApiKeyIdentifier:@"api_key"]; + [config setApiKeyPrefix:@"PREFIX" forApiKeyPrefixIdentifier:@"api_key"]; config.username = @"test_username"; config.password = @"test_password"; From 5a235c642accc342682a81d46a161a7ce7f8cf22 Mon Sep 17 00:00:00 2001 From: geekerzp Date: Thu, 23 Jul 2015 18:03:19 +0800 Subject: [PATCH 4/5] Update comments of objc client --- .../resources/objc/ApiClient-header.mustache | 53 ++++++++-------- .../objc/Configuration-header.mustache | 34 +++++------ .../main/resources/objc/api-header.mustache | 6 ++ .../main/resources/objc/model-body.mustache | 2 +- .../main/resources/objc/model-header.mustache | 9 ++- .../objc/SwaggerClient/SWGApiClient.h | 61 ++++++++++--------- .../petstore/objc/SwaggerClient/SWGCategory.h | 9 ++- .../petstore/objc/SwaggerClient/SWGCategory.m | 2 +- .../objc/SwaggerClient/SWGConfiguration.h | 34 +++++------ .../petstore/objc/SwaggerClient/SWGOrder.h | 9 ++- .../petstore/objc/SwaggerClient/SWGOrder.m | 2 +- .../petstore/objc/SwaggerClient/SWGPet.h | 9 ++- .../petstore/objc/SwaggerClient/SWGPet.m | 2 +- .../petstore/objc/SwaggerClient/SWGPetApi.h | 6 ++ .../petstore/objc/SwaggerClient/SWGStoreApi.h | 6 ++ .../petstore/objc/SwaggerClient/SWGTag.h | 9 ++- .../petstore/objc/SwaggerClient/SWGTag.m | 2 +- .../petstore/objc/SwaggerClient/SWGUser.h | 9 ++- .../petstore/objc/SwaggerClient/SWGUser.m | 2 +- .../petstore/objc/SwaggerClient/SWGUserApi.h | 6 ++ 20 files changed, 174 insertions(+), 98 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache index 0edab7414f1..a5871400352 100644 --- a/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/ApiClient-header.mustache @@ -5,9 +5,14 @@ #import "{{classPrefix}}JSONRequestSerializer.h" #import "{{classPrefix}}QueryParamCollection.h" #import "{{classPrefix}}Configuration.h" - -{{#models}}{{#model}}#import "{{classname}}.h" +/** + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ + +{{#models}}{{#model}}#import "{{classname}}.h" {{/model}}{{/models}} /** @@ -25,7 +30,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; @property(nonatomic, readonly) NSOperationQueue* queue; /** - * Get the Api Client instance from pool + * Gets the Api Client instance from pool * * @param baseUrl The base url of api client. * @@ -34,68 +39,68 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; +({{classPrefix}}ApiClient *)sharedClientFromPool:(NSString *)baseUrl; /** - * Get the operations queue + * Gets the operations queue * * @return The `shardQueue` static variable. */ +(NSOperationQueue*) sharedQueue; /** - * Clear Cache + * Clears Cache */ +(void)clearCache; /** - * Turn on cache + * Turns on cache * * @param enabled If the cached is enable, must be `YES` or `NO` */ +(void)setCacheEnabled:(BOOL) enabled; /** - * Get the request queue size + * Gets the request queue size * * @return The size of `queuedRequests` static variable. */ +(unsigned long)requestQueueSize; /** - * Set the client unreachable + * Sets the client unreachable * - * @param state off line state, must be `YES` or `NO` + * @param state off line state, must be `YES` or `NO` */ +(void) setOfflineState:(BOOL) state; /** - * Get the client reachability + * Gets the client reachability * * @return The client reachability. */ +(AFNetworkReachabilityStatus) getReachabilityStatus; /** - * Get the next request id + * Gets the next request id * * @return The next executed request id. */ +(NSNumber*) nextRequestId; /** - * Generate request id and add it to the queue + * Generates request id and add it to the queue * * @return The next executed request id. */ +(NSNumber*) queueRequest; /** - * Remove request id from the queue + * Removes request id from the queue * * @param requestId The request which will be removed. */ +(void) cancelRequest:(NSNumber*)requestId; /** - * URL encode NSString + * Gets URL encoded NSString * * @param unescaped The string which will be escaped. * @@ -104,21 +109,21 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; +(NSString*) escape:(id)unescaped; /** - * Customize the behavior when the reachability changed + * Customizes the behavior when the reachability changed * * @param changeBlock The block will be executed when the reachability changed. */ +(void) setReachabilityChangeBlock:(void(^)(int))changeBlock; /** - * Set the client reachability strategy + * Sets the client reachability strategy * * @param host The host of {{classPrefix}}ApiClient. */ +(void) configureCacheReachibilityForHost:(NSString*)host; /** - * Detect Accept header from accepts NSArray + * Detects Accept header from accepts NSArray * * @param accepts NSArray of header * @@ -127,7 +132,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; +(NSString *) selectHeaderAccept:(NSArray *)accepts; /** - * Detect Content-Type header from contentTypes NSArray + * Detects Content-Type header from contentTypes NSArray * * @param contentTypes NSArray of header * @@ -136,7 +141,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; +(NSString *) selectHeaderContentType:(NSArray *)contentTypes; /** - * Set header for request + * Sets header for request * * @param value The header value * @param forKey The header key @@ -145,7 +150,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; forKey:(NSString*) forKey; /** - * Update header parameters and query parameters for authentication + * Updates header parameters and query parameters for authentication * * @param headers The header parameter will be udpated, passed by pointer to pointer. * @param querys The query parameters will be updated, passed by pointer to pointer. @@ -156,7 +161,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; WithAuthSettings:(NSArray *)authSettings; /** - * Deserialize the given data to Objective-C object. + * Deserializes the given data to Objective-C object. * * @param data The data will be deserialized. * @param class The type of objective-c object. @@ -164,7 +169,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; - (id) deserialize:(id) data class:(NSString *) class; /** - * Logging request and response + * Logs request and response * * @param operation AFHTTPRequestOperation for the HTTP request. * @param request The HTTP request. @@ -175,7 +180,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; error:(NSError *)error; /** - * Perform request + * Performs request * * @param path Request url. * @param method Request method. @@ -185,7 +190,7 @@ extern NSString *const {{classPrefix}}ResponseObjectErrorKey; * @param authSettings Request authentication names. * @param requestContentType Request content-type. * @param responseContentType Response content-type. - * @param completionBlock The block will be executed when the request completed. + * @param completionBlock The block will be executed when the request completed. * * @return The request id. */ diff --git a/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache b/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache index 2ec6e18e9d5..56e9fcaecd5 100644 --- a/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache @@ -2,7 +2,7 @@ /** The `{{classPrefix}}Configuration` class manages the configurations for the sdk. * - * NOTE: This class is auto generated by the swagger code generator program. + * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen * Do not edit the class manually. */ @@ -58,57 +58,57 @@ @property (nonatomic, readonly) NSFileHandle *loggingFileHanlder; /** - * Get configuration singleton instance + * Gets configuration singleton instance */ + (instancetype) sharedConfig; /** - * Sets field in `apiKey`. + * Sets API key * - * To remove a apiKey for a identifier, just set the apiKey to nil. + * To remove a apiKey for an identifier, just set the apiKey to nil. * - * @param apiKey The apiKey value. - * @param identifier The apiKey name. + * @param apiKey API key or token. + * @param identifier API key identifier (authentication schema). * */ - (void) setApiKey:(NSString *)apiKey forApiKeyIdentifier:(NSString*)identifier; /** - * Remove api key + * Removes api key * - * @param identifier The apiKey name. + * @param identifier API key identifier. */ - (void) removeApiKey:(NSString *)identifier; /** - * Sets field in `apiKeyPrefix` + * Sets the prefix for API key * - * To remove a apiKeyPrefix for a identifier, just set the apiKeyPrefix to nil. + * To remove a apiKeyPrefix for an identifier, just set the apiKeyPrefix to nil. * - * @param apiKeyPrefix The apiKeyPrefix value. - * @param identifier The apiKeyPrefix name. + * @param apiKeyPrefix API key prefix. + * @param identifier API key identifier. */ - (void) setApiKeyPrefix:(NSString *)prefix forApiKeyPrefixIdentifier:(NSString *)identifier; /** - * Remove api key prefix + * Removes api key prefix * - * @param identifier The apiKeyPrefix name. + * @param identifier API key identifier. */ - (void) removeApiKeyPrefix:(NSString *)identifier; /** - * Get API key (with prefix if set) + * Gets API key (with prefix if set) */ - (NSString *) getApiKeyWithPrefix:(NSString *) key; /** - * Get Basic Auth token + * Gets Basic Auth token */ - (NSString *) getBasicAuthToken; /** - * Get Authentication Setings + * Gets Authentication Setings */ - (NSDictionary *) authSettings; diff --git a/modules/swagger-codegen/src/main/resources/objc/api-header.mustache b/modules/swagger-codegen/src/main/resources/objc/api-header.mustache index 263c213dd6f..6b85f753e45 100644 --- a/modules/swagger-codegen/src/main/resources/objc/api-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/api-header.mustache @@ -5,6 +5,12 @@ #import "{{classPrefix}}ApiClient.h" {{newline}} +/** + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ + {{#operations}} @interface {{classname}}: NSObject diff --git a/modules/swagger-codegen/src/main/resources/objc/model-body.mustache b/modules/swagger-codegen/src/main/resources/objc/model-body.mustache index 209cd7bf5a5..33c0f8cf42b 100644 --- a/modules/swagger-codegen/src/main/resources/objc/model-body.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/model-body.mustache @@ -31,7 +31,7 @@ } /** - * Returns a string that represents the properties json of the model. + * Gets the string presentation of the object. * This method will be called when logging model object using `NSLog`. */ - (NSString *)description { diff --git a/modules/swagger-codegen/src/main/resources/objc/model-header.mustache b/modules/swagger-codegen/src/main/resources/objc/model-header.mustache index 4afaec31a24..c3f3c865424 100644 --- a/modules/swagger-codegen/src/main/resources/objc/model-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/model-header.mustache @@ -1,5 +1,12 @@ #import #import "{{classPrefix}}Object.h" + +/** + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ + {{#imports}}#import "{{import}}.h" {{/imports}} {{newline}} @@ -8,7 +15,7 @@ @protocol {{classname}} @end - + @interface {{classname}} : {{classPrefix}}Object {{#vars}} diff --git a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h index 56c6adf30f2..ada8035e579 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGApiClient.h @@ -5,13 +5,18 @@ #import "SWGJSONRequestSerializer.h" #import "SWGQueryParamCollection.h" #import "SWGConfiguration.h" - -#import "SWGUser.h" -#import "SWGCategory.h" -#import "SWGPet.h" -#import "SWGTag.h" -#import "SWGOrder.h" +/** + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ + +#import "SWGUser.h" +#import "SWGCategory.h" +#import "SWGPet.h" +#import "SWGTag.h" +#import "SWGOrder.h" /** @@ -29,7 +34,7 @@ extern NSString *const SWGResponseObjectErrorKey; @property(nonatomic, readonly) NSOperationQueue* queue; /** - * Get the Api Client instance from pool + * Gets the Api Client instance from pool * * @param baseUrl The base url of api client. * @@ -38,68 +43,68 @@ extern NSString *const SWGResponseObjectErrorKey; +(SWGApiClient *)sharedClientFromPool:(NSString *)baseUrl; /** - * Get the operations queue + * Gets the operations queue * * @return The `shardQueue` static variable. */ +(NSOperationQueue*) sharedQueue; /** - * Clear Cache + * Clears Cache */ +(void)clearCache; /** - * Turn on cache + * Turns on cache * * @param enabled If the cached is enable, must be `YES` or `NO` */ +(void)setCacheEnabled:(BOOL) enabled; /** - * Get the request queue size + * Gets the request queue size * * @return The size of `queuedRequests` static variable. */ +(unsigned long)requestQueueSize; /** - * Set the client unreachable + * Sets the client unreachable * - * @param state off line state, must be `YES` or `NO` + * @param state off line state, must be `YES` or `NO` */ +(void) setOfflineState:(BOOL) state; /** - * Get the client reachability + * Gets the client reachability * * @return The client reachability. */ +(AFNetworkReachabilityStatus) getReachabilityStatus; /** - * Get the next request id + * Gets the next request id * * @return The next executed request id. */ +(NSNumber*) nextRequestId; /** - * Generate request id and add it to the queue + * Generates request id and add it to the queue * * @return The next executed request id. */ +(NSNumber*) queueRequest; /** - * Remove request id from the queue + * Removes request id from the queue * * @param requestId The request which will be removed. */ +(void) cancelRequest:(NSNumber*)requestId; /** - * URL encode NSString + * Gets URL encoded NSString * * @param unescaped The string which will be escaped. * @@ -108,21 +113,21 @@ extern NSString *const SWGResponseObjectErrorKey; +(NSString*) escape:(id)unescaped; /** - * Customize the behavior when the reachability changed + * Customizes the behavior when the reachability changed * * @param changeBlock The block will be executed when the reachability changed. */ +(void) setReachabilityChangeBlock:(void(^)(int))changeBlock; /** - * Set the client reachability strategy + * Sets the client reachability strategy * * @param host The host of SWGApiClient. */ +(void) configureCacheReachibilityForHost:(NSString*)host; /** - * Detect Accept header from accepts NSArray + * Detects Accept header from accepts NSArray * * @param accepts NSArray of header * @@ -131,7 +136,7 @@ extern NSString *const SWGResponseObjectErrorKey; +(NSString *) selectHeaderAccept:(NSArray *)accepts; /** - * Detect Content-Type header from contentTypes NSArray + * Detects Content-Type header from contentTypes NSArray * * @param contentTypes NSArray of header * @@ -140,7 +145,7 @@ extern NSString *const SWGResponseObjectErrorKey; +(NSString *) selectHeaderContentType:(NSArray *)contentTypes; /** - * Set header for request + * Sets header for request * * @param value The header value * @param forKey The header key @@ -149,7 +154,7 @@ extern NSString *const SWGResponseObjectErrorKey; forKey:(NSString*) forKey; /** - * Update header parameters and query parameters for authentication + * Updates header parameters and query parameters for authentication * * @param headers The header parameter will be udpated, passed by pointer to pointer. * @param querys The query parameters will be updated, passed by pointer to pointer. @@ -160,7 +165,7 @@ extern NSString *const SWGResponseObjectErrorKey; WithAuthSettings:(NSArray *)authSettings; /** - * Deserialize the given data to Objective-C object. + * Deserializes the given data to Objective-C object. * * @param data The data will be deserialized. * @param class The type of objective-c object. @@ -168,7 +173,7 @@ extern NSString *const SWGResponseObjectErrorKey; - (id) deserialize:(id) data class:(NSString *) class; /** - * Logging request and response + * Logs request and response * * @param operation AFHTTPRequestOperation for the HTTP request. * @param request The HTTP request. @@ -179,7 +184,7 @@ extern NSString *const SWGResponseObjectErrorKey; error:(NSError *)error; /** - * Perform request + * Performs request * * @param path Request url. * @param method Request method. @@ -189,7 +194,7 @@ extern NSString *const SWGResponseObjectErrorKey; * @param authSettings Request authentication names. * @param requestContentType Request content-type. * @param responseContentType Response content-type. - * @param completionBlock The block will be executed when the request completed. + * @param completionBlock The block will be executed when the request completed. * * @return The request id. */ diff --git a/samples/client/petstore/objc/SwaggerClient/SWGCategory.h b/samples/client/petstore/objc/SwaggerClient/SWGCategory.h index a2fed79b4a3..983fd610123 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGCategory.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGCategory.h @@ -1,10 +1,17 @@ #import #import "SWGObject.h" +/** + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ + + @protocol SWGCategory @end - + @interface SWGCategory : SWGObject diff --git a/samples/client/petstore/objc/SwaggerClient/SWGCategory.m b/samples/client/petstore/objc/SwaggerClient/SWGCategory.m index d2ac30e403b..fb3ccecf176 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGCategory.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGCategory.m @@ -29,7 +29,7 @@ } /** - * Returns a string that represents the properties json of the model. + * Gets the string presentation of the object. * This method will be called when logging model object using `NSLog`. */ - (NSString *)description { diff --git a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.h b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.h index d1176257779..4b7f318b5ec 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.h @@ -2,7 +2,7 @@ /** The `SWGConfiguration` class manages the configurations for the sdk. * - * NOTE: This class is auto generated by the swagger code generator program. + * NOTE: This class is auto generated by the swagger code generator program. * https://github.com/swagger-api/swagger-codegen * Do not edit the class manually. */ @@ -58,57 +58,57 @@ @property (nonatomic, readonly) NSFileHandle *loggingFileHanlder; /** - * Get configuration singleton instance + * Gets configuration singleton instance */ + (instancetype) sharedConfig; /** - * Sets field in `apiKey`. + * Sets API key * - * To remove a apiKey for a identifier, just set the apiKey to nil. + * To remove a apiKey for an identifier, just set the apiKey to nil. * - * @param apiKey The apiKey value. - * @param identifier The apiKey name. + * @param apiKey API key or token. + * @param identifier API key identifier (authentication schema). * */ - (void) setApiKey:(NSString *)apiKey forApiKeyIdentifier:(NSString*)identifier; /** - * Remove api key + * Removes api key * - * @param identifier The apiKey name. + * @param identifier API key identifier. */ - (void) removeApiKey:(NSString *)identifier; /** - * Sets field in `apiKeyPrefix` + * Sets the prefix for API key * - * To remove a apiKeyPrefix for a identifier, just set the apiKeyPrefix to nil. + * To remove a apiKeyPrefix for an identifier, just set the apiKeyPrefix to nil. * - * @param apiKeyPrefix The apiKeyPrefix value. - * @param identifier The apiKeyPrefix name. + * @param apiKeyPrefix API key prefix. + * @param identifier API key identifier. */ - (void) setApiKeyPrefix:(NSString *)prefix forApiKeyPrefixIdentifier:(NSString *)identifier; /** - * Remove api key prefix + * Removes api key prefix * - * @param identifier The apiKeyPrefix name. + * @param identifier API key identifier. */ - (void) removeApiKeyPrefix:(NSString *)identifier; /** - * Get API key (with prefix if set) + * Gets API key (with prefix if set) */ - (NSString *) getApiKeyWithPrefix:(NSString *) key; /** - * Get Basic Auth token + * Gets Basic Auth token */ - (NSString *) getBasicAuthToken; /** - * Get Authentication Setings + * Gets Authentication Setings */ - (NSDictionary *) authSettings; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGOrder.h b/samples/client/petstore/objc/SwaggerClient/SWGOrder.h index 2e71906cd53..48a7cf0d6c1 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGOrder.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGOrder.h @@ -1,10 +1,17 @@ #import #import "SWGObject.h" +/** + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ + + @protocol SWGOrder @end - + @interface SWGOrder : SWGObject diff --git a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m index e2ee7a1f321..83fe5741cd7 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGOrder.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGOrder.m @@ -29,7 +29,7 @@ } /** - * Returns a string that represents the properties json of the model. + * Gets the string presentation of the object. * This method will be called when logging model object using `NSLog`. */ - (NSString *)description { diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPet.h b/samples/client/petstore/objc/SwaggerClient/SWGPet.h index edd54e9f31a..d78baade81a 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPet.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGPet.h @@ -1,12 +1,19 @@ #import #import "SWGObject.h" + +/** + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ + #import "SWGTag.h" #import "SWGCategory.h" @protocol SWGPet @end - + @interface SWGPet : SWGObject diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPet.m b/samples/client/petstore/objc/SwaggerClient/SWGPet.m index 1d1965cfa04..3fd315ab011 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPet.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGPet.m @@ -29,7 +29,7 @@ } /** - * Returns a string that represents the properties json of the model. + * Gets the string presentation of the object. * This method will be called when logging model object using `NSLog`. */ - (NSString *)description { diff --git a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h index 39f23edb028..929b16eab1f 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGPetApi.h @@ -4,6 +4,12 @@ #import "SWGApiClient.h" +/** + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ + @interface SWGPetApi: NSObject @property(nonatomic, assign)SWGApiClient *apiClient; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h index 7488c1baa70..7b4f99dea7b 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGStoreApi.h @@ -4,6 +4,12 @@ #import "SWGApiClient.h" +/** + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ + @interface SWGStoreApi: NSObject @property(nonatomic, assign)SWGApiClient *apiClient; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGTag.h b/samples/client/petstore/objc/SwaggerClient/SWGTag.h index d9cc84be270..97e95807550 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGTag.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGTag.h @@ -1,10 +1,17 @@ #import #import "SWGObject.h" +/** + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ + + @protocol SWGTag @end - + @interface SWGTag : SWGObject diff --git a/samples/client/petstore/objc/SwaggerClient/SWGTag.m b/samples/client/petstore/objc/SwaggerClient/SWGTag.m index 36215d9482c..3bcb9973dfd 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGTag.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGTag.m @@ -29,7 +29,7 @@ } /** - * Returns a string that represents the properties json of the model. + * Gets the string presentation of the object. * This method will be called when logging model object using `NSLog`. */ - (NSString *)description { diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUser.h b/samples/client/petstore/objc/SwaggerClient/SWGUser.h index f505ca2c041..6ba19e632b8 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUser.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGUser.h @@ -1,10 +1,17 @@ #import #import "SWGObject.h" +/** + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ + + @protocol SWGUser @end - + @interface SWGUser : SWGObject diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUser.m b/samples/client/petstore/objc/SwaggerClient/SWGUser.m index ecf7ee5ad7d..d040a6bce6d 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUser.m +++ b/samples/client/petstore/objc/SwaggerClient/SWGUser.m @@ -29,7 +29,7 @@ } /** - * Returns a string that represents the properties json of the model. + * Gets the string presentation of the object. * This method will be called when logging model object using `NSLog`. */ - (NSString *)description { diff --git a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h index 6fda87cca70..9a3dfd9d23d 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGUserApi.h @@ -4,6 +4,12 @@ #import "SWGApiClient.h" +/** + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen + * Do not edit the class manually. + */ + @interface SWGUserApi: NSObject @property(nonatomic, assign)SWGApiClient *apiClient; From 3b9b3e82f961e3aaa380d568b5f48ced28076bc9 Mon Sep 17 00:00:00 2001 From: geekerzp Date: Mon, 27 Jul 2015 10:27:48 +0800 Subject: [PATCH 5/5] Update comments in objc client --- .../src/main/resources/objc/Configuration-header.mustache | 8 ++++---- .../client/petstore/objc/SwaggerClient/SWGConfiguration.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache b/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache index 56e9fcaecd5..6b311e968b0 100644 --- a/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/Configuration-header.mustache @@ -2,8 +2,8 @@ /** The `{{classPrefix}}Configuration` class manages the configurations for the sdk. * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen * Do not edit the class manually. */ @interface {{classPrefix}}Configuration : NSObject @@ -41,14 +41,14 @@ /** * Logging Settings */ - + /** * Debug switch, default false */ @property (nonatomic) BOOL debug; /** - * Debug file location, default nil + * Debug file location, default log in console */ @property (nonatomic) NSString *loggingFile; diff --git a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.h b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.h index 4b7f318b5ec..0ccbe0cd8f6 100644 --- a/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.h +++ b/samples/client/petstore/objc/SwaggerClient/SWGConfiguration.h @@ -2,8 +2,8 @@ /** The `SWGConfiguration` class manages the configurations for the sdk. * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen * Do not edit the class manually. */ @interface SWGConfiguration : NSObject @@ -41,14 +41,14 @@ /** * Logging Settings */ - + /** * Debug switch, default false */ @property (nonatomic) BOOL debug; /** - * Debug file location, default nil + * Debug file location, default log in console */ @property (nonatomic) NSString *loggingFile;