diff --git a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/ObjcClientCodegen.java b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/ObjcClientCodegen.java index b7c38c703ca..d1e227ce744 100644 --- a/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/ObjcClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/com/wordnik/swagger/codegen/languages/ObjcClientCodegen.java @@ -120,8 +120,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { supportingFiles.add(new SupportingFile("SWGApiClient.m", sourceFolder, "SWGApiClient.m")); supportingFiles.add(new SupportingFile("SWGFile.h", sourceFolder, "SWGFile.h")); supportingFiles.add(new SupportingFile("SWGFile.m", sourceFolder, "SWGFile.m")); - supportingFiles.add(new SupportingFile("SWGDate.h", sourceFolder, "SWGDate.h")); - supportingFiles.add(new SupportingFile("SWGDate.m", sourceFolder, "SWGDate.m")); + supportingFiles.add(new SupportingFile("JSONValueTransformer+ISO8601.m", sourceFolder, "JSONValueTransformer+ISO8601.m")); + supportingFiles.add(new SupportingFile("JSONValueTransformer+ISO8601.h", sourceFolder, "JSONValueTransformer+ISO8601.h")); supportingFiles.add(new SupportingFile("Podfile.mustache", "", "Podfile")); } diff --git a/modules/swagger-codegen/src/main/resources/objc/JSONValueTransformer+ISO8601.h b/modules/swagger-codegen/src/main/resources/objc/JSONValueTransformer+ISO8601.h new file mode 100644 index 00000000000..832f485f4f0 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/objc/JSONValueTransformer+ISO8601.h @@ -0,0 +1,6 @@ +#import +#import +#import + +@interface JSONValueTransformer (ISO8601) +@end diff --git a/modules/swagger-codegen/src/main/resources/objc/JSONValueTransformer+ISO8601.m b/modules/swagger-codegen/src/main/resources/objc/JSONValueTransformer+ISO8601.m new file mode 100644 index 00000000000..cec8bdeea27 --- /dev/null +++ b/modules/swagger-codegen/src/main/resources/objc/JSONValueTransformer+ISO8601.m @@ -0,0 +1,10 @@ +#import "JSONValueTransformer+ISO8601.h" + +@implementation JSONValueTransformer (ISO8601) + +- (NSDate *) NSDateFromNSString:(NSString *)string +{ + return [NSDate dateWithISO8601String:string]; +} + +@end diff --git a/modules/swagger-codegen/src/main/resources/objc/Podfile.mustache b/modules/swagger-codegen/src/main/resources/objc/Podfile.mustache index 1a9d463c86a..c61ab59dd8f 100644 --- a/modules/swagger-codegen/src/main/resources/objc/Podfile.mustache +++ b/modules/swagger-codegen/src/main/resources/objc/Podfile.mustache @@ -2,3 +2,4 @@ platform :ios, '6.0' xcodeproj '{{projectName}}/{{projectName}}.xcodeproj' pod 'AFNetworking', '~> 2.1' pod 'JSONModel', '~> 1.0' +pod 'ISO8601' diff --git a/modules/swagger-codegen/src/main/resources/objc/SWGDate.h b/modules/swagger-codegen/src/main/resources/objc/SWGDate.h deleted file mode 100644 index 2c6c7cfe01b..00000000000 --- a/modules/swagger-codegen/src/main/resources/objc/SWGDate.h +++ /dev/null @@ -1,12 +0,0 @@ -#import -#import "SWGObject.h" - -@interface SWGDate : SWGObject { -@private - NSDate *_date; -} -@property(nonatomic, readonly) NSDate* date; - -- (id) initWithValues: (NSString*)input; --(NSString*) toString; -@end \ No newline at end of file diff --git a/modules/swagger-codegen/src/main/resources/objc/SWGDate.m b/modules/swagger-codegen/src/main/resources/objc/SWGDate.m deleted file mode 100644 index 07a1405626b..00000000000 --- a/modules/swagger-codegen/src/main/resources/objc/SWGDate.m +++ /dev/null @@ -1,34 +0,0 @@ -#import "SWGDate.h" - -@implementation SWGDate - -@synthesize date = _date; - -- (id) initWithValues:(NSString*)input { - if([input isKindOfClass:[NSString class]]){ - NSDateFormatter* df = [NSDateFormatter new]; - NSLocale *locale = [[NSLocale new] - initWithLocaleIdentifier:@"en_US_POSIX"]; - [df setLocale:locale]; - [df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"]; - - _date = [df dateFromString:input]; - } - else if([input isKindOfClass:[NSNumber class]]) { - NSTimeInterval interval = [input doubleValue]; - _date = [[NSDate alloc] initWithTimeIntervalSince1970:interval]; - } - return self; -} - --(NSString*) toString { - NSDateFormatter* df = [NSDateFormatter new]; - NSLocale *locale = [[NSLocale new] - initWithLocaleIdentifier:@"en_US_POSIX"]; - [df setLocale:locale]; - [df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"]; - - return [df stringFromDate:_date]; -} - -@end \ No newline at end of file diff --git a/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.pbxproj b/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.pbxproj index c22d57fa0ac..a3f7b4cae6b 100644 --- a/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.pbxproj +++ b/samples/client/petstore/objc/PetstoreClient/PetstoreClient.xcodeproj/project.pbxproj @@ -8,6 +8,8 @@ /* Begin PBXBuildFile section */ BA525648922D4C0E9F44D4F1 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 73DA4F1067C343C3962F1542 /* libPods.a */; }; + CFD1B6701B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m in Sources */ = {isa = PBXBuildFile; fileRef = CFD1B66F1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m */; }; + CFD1B6711B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m in Sources */ = {isa = PBXBuildFile; fileRef = CFD1B66F1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m */; }; EA66999A1811D2FA00A70D03 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA6699991811D2FA00A70D03 /* Foundation.framework */; }; EA66999C1811D2FA00A70D03 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA66999B1811D2FA00A70D03 /* CoreGraphics.framework */; }; EA66999E1811D2FA00A70D03 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EA66999D1811D2FA00A70D03 /* UIKit.framework */; }; @@ -28,7 +30,6 @@ EAB26B0D1AC8DF78002F5C7A /* PetApiTest.m in Sources */ = {isa = PBXBuildFile; fileRef = EA6699C71811D2FB00A70D03 /* PetApiTest.m */; }; EAEA85E41811D3AE00F06E69 /* SWGApiClient.m in Sources */ = {isa = PBXBuildFile; fileRef = EAEA85CD1811D3AE00F06E69 /* SWGApiClient.m */; }; EAEA85E51811D3AE00F06E69 /* SWGCategory.m in Sources */ = {isa = PBXBuildFile; fileRef = EAEA85CF1811D3AE00F06E69 /* SWGCategory.m */; }; - EAEA85E61811D3AE00F06E69 /* SWGDate.m in Sources */ = {isa = PBXBuildFile; fileRef = EAEA85D11811D3AE00F06E69 /* SWGDate.m */; }; EAEA85E71811D3AE00F06E69 /* SWGFile.m in Sources */ = {isa = PBXBuildFile; fileRef = EAEA85D31811D3AE00F06E69 /* SWGFile.m */; }; EAEA85E81811D3AE00F06E69 /* SWGObject.m in Sources */ = {isa = PBXBuildFile; fileRef = EAEA85D51811D3AE00F06E69 /* SWGObject.m */; }; EAEA85E91811D3AE00F06E69 /* SWGOrder.m in Sources */ = {isa = PBXBuildFile; fileRef = EAEA85D71811D3AE00F06E69 /* SWGOrder.m */; }; @@ -54,6 +55,8 @@ /* Begin PBXFileReference section */ 73DA4F1067C343C3962F1542 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; A425648B5C0A4849C7668069 /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "../Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; + CFD1B66E1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "JSONValueTransformer+ISO8601.h"; sourceTree = ""; }; + CFD1B66F1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "JSONValueTransformer+ISO8601.m"; sourceTree = ""; }; E2B6DA00BE52336E23783686 /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "../Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; EA6699961811D2FA00A70D03 /* PetstoreClient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PetstoreClient.app; sourceTree = BUILT_PRODUCTS_DIR; }; EA6699991811D2FA00A70D03 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; @@ -84,8 +87,6 @@ EAEA85CD1811D3AE00F06E69 /* SWGApiClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGApiClient.m; sourceTree = ""; }; EAEA85CE1811D3AE00F06E69 /* SWGCategory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWGCategory.h; sourceTree = ""; }; EAEA85CF1811D3AE00F06E69 /* SWGCategory.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGCategory.m; sourceTree = ""; }; - EAEA85D01811D3AE00F06E69 /* SWGDate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWGDate.h; sourceTree = ""; }; - EAEA85D11811D3AE00F06E69 /* SWGDate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGDate.m; sourceTree = ""; }; EAEA85D21811D3AE00F06E69 /* SWGFile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWGFile.h; sourceTree = ""; }; EAEA85D31811D3AE00F06E69 /* SWGFile.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SWGFile.m; sourceTree = ""; }; EAEA85D41811D3AE00F06E69 /* SWGObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SWGObject.h; sourceTree = ""; }; @@ -224,14 +225,14 @@ EAEA85CB1811D3AE00F06E69 /* client */ = { isa = PBXGroup; children = ( + CFD1B66E1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.h */, + CFD1B66F1B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m */, EA8B8AA21AC6683700638FBB /* SWGQueryParamCollection.h */, EA8B8AA31AC6683700638FBB /* SWGQueryParamCollection.m */, EAEA85CC1811D3AE00F06E69 /* SWGApiClient.h */, EAEA85CD1811D3AE00F06E69 /* SWGApiClient.m */, EAEA85CE1811D3AE00F06E69 /* SWGCategory.h */, EAEA85CF1811D3AE00F06E69 /* SWGCategory.m */, - EAEA85D01811D3AE00F06E69 /* SWGDate.h */, - EAEA85D11811D3AE00F06E69 /* SWGDate.m */, EAEA85D21811D3AE00F06E69 /* SWGFile.h */, EAEA85D31811D3AE00F06E69 /* SWGFile.m */, EAEA85D41811D3AE00F06E69 /* SWGObject.h */, @@ -397,8 +398,8 @@ EAEA85EE1811D3AE00F06E69 /* SWGUser.m in Sources */, EAEA85EF1811D3AE00F06E69 /* SWGUserApi.m in Sources */, EAEA85EB1811D3AE00F06E69 /* SWGPetApi.m in Sources */, - EAEA85E61811D3AE00F06E69 /* SWGDate.m in Sources */, EA6699A61811D2FA00A70D03 /* main.m in Sources */, + CFD1B6701B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m in Sources */, EAEA85EA1811D3AE00F06E69 /* SWGPet.m in Sources */, EAEA85E41811D3AE00F06E69 /* SWGApiClient.m in Sources */, EAEA85EC1811D3AE00F06E69 /* SWGStoreApi.m in Sources */, @@ -414,6 +415,7 @@ buildActionMask = 2147483647; files = ( EAB26B0C1AC8DF78002F5C7A /* PetApiTest.h in Sources */, + CFD1B6711B05EC7D00DCCD51 /* JSONValueTransformer+ISO8601.m in Sources */, EAB26B0D1AC8DF78002F5C7A /* PetApiTest.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/samples/client/petstore/objc/Podfile b/samples/client/petstore/objc/Podfile index 925e26812b9..9a1ad058940 100644 --- a/samples/client/petstore/objc/Podfile +++ b/samples/client/petstore/objc/Podfile @@ -2,3 +2,4 @@ platform :ios, '6.0' xcodeproj 'PetstoreClient/PetstoreClient.xcodeproj' pod 'AFNetworking', '~> 2.1' pod 'JSONModel', '~> 1.0' +pod 'ISO8601' diff --git a/samples/client/petstore/objc/Podfile.lock b/samples/client/petstore/objc/Podfile.lock index de949a0e238..e9e593cf299 100644 --- a/samples/client/petstore/objc/Podfile.lock +++ b/samples/client/petstore/objc/Podfile.lock @@ -1,33 +1,36 @@ PODS: - - AFNetworking (2.5.1): - - AFNetworking/NSURLConnection (= 2.5.1) - - AFNetworking/NSURLSession (= 2.5.1) - - AFNetworking/Reachability (= 2.5.1) - - AFNetworking/Security (= 2.5.1) - - AFNetworking/Serialization (= 2.5.1) - - AFNetworking/UIKit (= 2.5.1) - - AFNetworking/NSURLConnection (2.5.1): + - AFNetworking (2.5.3): + - AFNetworking/NSURLConnection (= 2.5.3) + - AFNetworking/NSURLSession (= 2.5.3) + - AFNetworking/Reachability (= 2.5.3) + - AFNetworking/Security (= 2.5.3) + - AFNetworking/Serialization (= 2.5.3) + - AFNetworking/UIKit (= 2.5.3) + - AFNetworking/NSURLConnection (2.5.3): - AFNetworking/Reachability - AFNetworking/Security - AFNetworking/Serialization - - AFNetworking/NSURLSession (2.5.1): + - AFNetworking/NSURLSession (2.5.3): - AFNetworking/Reachability - AFNetworking/Security - AFNetworking/Serialization - - AFNetworking/Reachability (2.5.1) - - AFNetworking/Security (2.5.1) - - AFNetworking/Serialization (2.5.1) - - AFNetworking/UIKit (2.5.1): + - AFNetworking/Reachability (2.5.3) + - AFNetworking/Security (2.5.3) + - AFNetworking/Serialization (2.5.3) + - AFNetworking/UIKit (2.5.3): - AFNetworking/NSURLConnection - AFNetworking/NSURLSession - - JSONModel (1.0.2) + - ISO8601 (0.2.0) + - JSONModel (1.1.0) DEPENDENCIES: - AFNetworking (~> 2.1) + - ISO8601 - JSONModel (~> 1.0) SPEC CHECKSUMS: - AFNetworking: 10e85a00bb0f475124e4ff2677bf15693b2c1523 - JSONModel: 6ffcb4ffa3659c9e9a2e5d45d6c7705bab187c03 + AFNetworking: e1d86c2a96bb5d2e7408da36149806706ee122fe + ISO8601: 962282de75074c38bbfaa7b133b0e743ed6deb8d + JSONModel: ec77e9865236a7a09d9cf7668df6b4b328d9ec1d -COCOAPODS: 0.36.0 +COCOAPODS: 0.37.1 diff --git a/samples/client/petstore/objc/client/JSONValueTransformer+ISO8601.h b/samples/client/petstore/objc/client/JSONValueTransformer+ISO8601.h new file mode 100644 index 00000000000..832f485f4f0 --- /dev/null +++ b/samples/client/petstore/objc/client/JSONValueTransformer+ISO8601.h @@ -0,0 +1,6 @@ +#import +#import +#import + +@interface JSONValueTransformer (ISO8601) +@end diff --git a/samples/client/petstore/objc/client/JSONValueTransformer+ISO8601.m b/samples/client/petstore/objc/client/JSONValueTransformer+ISO8601.m new file mode 100644 index 00000000000..cec8bdeea27 --- /dev/null +++ b/samples/client/petstore/objc/client/JSONValueTransformer+ISO8601.m @@ -0,0 +1,10 @@ +#import "JSONValueTransformer+ISO8601.h" + +@implementation JSONValueTransformer (ISO8601) + +- (NSDate *) NSDateFromNSString:(NSString *)string +{ + return [NSDate dateWithISO8601String:string]; +} + +@end diff --git a/samples/client/petstore/objc/client/SWGDate.h b/samples/client/petstore/objc/client/SWGDate.h deleted file mode 100644 index 2c6c7cfe01b..00000000000 --- a/samples/client/petstore/objc/client/SWGDate.h +++ /dev/null @@ -1,12 +0,0 @@ -#import -#import "SWGObject.h" - -@interface SWGDate : SWGObject { -@private - NSDate *_date; -} -@property(nonatomic, readonly) NSDate* date; - -- (id) initWithValues: (NSString*)input; --(NSString*) toString; -@end \ No newline at end of file diff --git a/samples/client/petstore/objc/client/SWGDate.m b/samples/client/petstore/objc/client/SWGDate.m deleted file mode 100644 index 07a1405626b..00000000000 --- a/samples/client/petstore/objc/client/SWGDate.m +++ /dev/null @@ -1,34 +0,0 @@ -#import "SWGDate.h" - -@implementation SWGDate - -@synthesize date = _date; - -- (id) initWithValues:(NSString*)input { - if([input isKindOfClass:[NSString class]]){ - NSDateFormatter* df = [NSDateFormatter new]; - NSLocale *locale = [[NSLocale new] - initWithLocaleIdentifier:@"en_US_POSIX"]; - [df setLocale:locale]; - [df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"]; - - _date = [df dateFromString:input]; - } - else if([input isKindOfClass:[NSNumber class]]) { - NSTimeInterval interval = [input doubleValue]; - _date = [[NSDate alloc] initWithTimeIntervalSince1970:interval]; - } - return self; -} - --(NSString*) toString { - NSDateFormatter* df = [NSDateFormatter new]; - NSLocale *locale = [[NSLocale new] - initWithLocaleIdentifier:@"en_US_POSIX"]; - [df setLocale:locale]; - [df setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSSZ"]; - - return [df stringFromDate:_date]; -} - -@end \ No newline at end of file diff --git a/samples/client/petstore/objc/client/SWGObject.h b/samples/client/petstore/objc/client/SWGObject.h index ccec208abc0..006701cde01 100644 --- a/samples/client/petstore/objc/client/SWGObject.h +++ b/samples/client/petstore/objc/client/SWGObject.h @@ -1,5 +1,6 @@ #import #import "JSONModel.h" +#import "JSONValueTransformer+ISO8601.h" @interface SWGObject : JSONModel @end