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";