From 9e6896c8f03ed58ac6ebe69aa8325b5ab43323f2 Mon Sep 17 00:00:00 2001 From: Jason Gavris Date: Mon, 18 Jul 2016 16:02:32 -0400 Subject: [PATCH] [Swift] Fix pod authors in podspec --- .../codegen/languages/SwiftCodegen.java | 5 ++++ .../src/main/resources/swift/Podspec.mustache | 2 +- .../codegen/languages/SwiftCodegenTest.java | 26 +++++++++++++++++++ .../swift/default/PetstoreClient.podspec | 2 +- .../PetstoreClient.podspec.json | 2 +- .../SwaggerClientTests/Pods/Manifest.lock | 2 +- 6 files changed, 35 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java index 214eca994efb..b782e3626f48 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwiftCodegen.java @@ -38,6 +38,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig { public static final String POD_SCREENSHOTS = "podScreenshots"; public static final String POD_DOCUMENTATION_URL = "podDocumentationURL"; public static final String SWIFT_USE_API_NAMESPACE = "swiftUseApiNamespace"; + public static final String DEFAULT_POD_AUTHORS = "Swagger Codegen"; protected static final String LIBRARY_PROMISE_KIT = "PromiseKit"; protected static final String[] RESPONSE_LIBRARIES = { LIBRARY_PROMISE_KIT }; protected String projectName = "SwaggerClient"; @@ -193,6 +194,10 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig { } additionalProperties.put(SWIFT_USE_API_NAMESPACE, swiftUseApiNamespace); + if (!additionalProperties.containsKey(POD_AUTHORS)) { + additionalProperties.put(POD_AUTHORS, DEFAULT_POD_AUTHORS); + } + supportingFiles.add(new SupportingFile("Podspec.mustache", "", projectName + ".podspec")); supportingFiles.add(new SupportingFile("Cartfile.mustache", "", "Cartfile")); supportingFiles.add(new SupportingFile("APIHelper.mustache", sourceFolder, "APIHelper.swift")); diff --git a/modules/swagger-codegen/src/main/resources/swift/Podspec.mustache b/modules/swagger-codegen/src/main/resources/swift/Podspec.mustache index 3af6910a094e..2289e7f6f018 100644 --- a/modules/swagger-codegen/src/main/resources/swift/Podspec.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/Podspec.mustache @@ -5,7 +5,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.9' s.version = '{{#podVersion}}{{podVersion}}{{/podVersion}}{{^podVersion}}0.0.1{{/podVersion}}' s.source = {{#podSource}}{{& podSource}}{{/podSource}}{{^podSource}}{ :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' }{{/podSource}}{{#podAuthors}} - s.authors = {{& podAuthors}}{{/podAuthors}}{{#podSocialMediaURL}} + s.authors = '{{podAuthors}}'{{/podAuthors}}{{#podSocialMediaURL}} s.social_media_url = '{{podSocialMediaURL}}'{{/podSocialMediaURL}}{{#podDocsetURL}} s.docset_url = '{{podDocsetURL}}'{{/podDocsetURL}} s.license = {{#podLicense}}{{& podLicense}}{{/podLicense}}{{^podLicense}}'Apache License, Version 2.0'{{/podLicense}}{{#podHomepage}} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/languages/SwiftCodegenTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/languages/SwiftCodegenTest.java index acede31f7361..4f4508f78efc 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/languages/SwiftCodegenTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/languages/SwiftCodegenTest.java @@ -42,4 +42,30 @@ public class SwiftCodegenTest { Assert.assertEquals(swiftCodegen.toSwiftyEnumName("entry_name"), "EntryName"); } + @Test + public void testDefaultPodAuthors() throws Exception { + // Given + + // When + swiftCodegen.processOpts(); + + // Then + final String podAuthors = (String) swiftCodegen.additionalProperties().get(SwiftCodegen.POD_AUTHORS); + Assert.assertEquals(podAuthors, SwiftCodegen.DEFAULT_POD_AUTHORS); + } + + @Test + public void testPodAuthors() throws Exception { + // Given + final String swaggerDevs = "Swagger Devs"; + swiftCodegen.additionalProperties().put(SwiftCodegen.POD_AUTHORS, swaggerDevs); + + // When + swiftCodegen.processOpts(); + + // Then + final String podAuthors = (String) swiftCodegen.additionalProperties().get(SwiftCodegen.POD_AUTHORS); + Assert.assertEquals(podAuthors, swaggerDevs); + } + } \ No newline at end of file diff --git a/samples/client/petstore/swift/default/PetstoreClient.podspec b/samples/client/petstore/swift/default/PetstoreClient.podspec index 86fa60dd1c6b..d1c9460ba1ab 100644 --- a/samples/client/petstore/swift/default/PetstoreClient.podspec +++ b/samples/client/petstore/swift/default/PetstoreClient.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.9' s.version = '0.0.1' s.source = { :git => 'git@github.com:swagger-api/swagger-mustache.git', :tag => 'v1.0.0' } - s.authors = + s.authors = '' s.license = 'Apache License, Version 2.0' s.homepage = 'https://github.com/swagger-api/swagger-codegen' s.summary = 'PetstoreClient' diff --git a/samples/client/petstore/swift/default/SwaggerClientTests/Pods/Local Podspecs/PetstoreClient.podspec.json b/samples/client/petstore/swift/default/SwaggerClientTests/Pods/Local Podspecs/PetstoreClient.podspec.json index 069b678d88cf..addbe0f7543d 100644 --- a/samples/client/petstore/swift/default/SwaggerClientTests/Pods/Local Podspecs/PetstoreClient.podspec.json +++ b/samples/client/petstore/swift/default/SwaggerClientTests/Pods/Local Podspecs/PetstoreClient.podspec.json @@ -9,8 +9,8 @@ "git": "git@github.com:swagger-api/swagger-mustache.git", "tag": "v1.0.0" }, + "authors": "", "license": "Apache License, Version 2.0", - "authors": "Apache License, Version 2.0", "homepage": "https://github.com/swagger-api/swagger-codegen", "summary": "PetstoreClient", "source_files": "PetstoreClient/Classes/Swaggers/**/*.swift", diff --git a/samples/client/petstore/swift/default/SwaggerClientTests/Pods/Manifest.lock b/samples/client/petstore/swift/default/SwaggerClientTests/Pods/Manifest.lock index ce1490e954e4..ac8d66719169 100644 --- a/samples/client/petstore/swift/default/SwaggerClientTests/Pods/Manifest.lock +++ b/samples/client/petstore/swift/default/SwaggerClientTests/Pods/Manifest.lock @@ -12,7 +12,7 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Alamofire: 5f730ba29fd113b7ddd71c1e65d0c630acf5d7b0 - PetstoreClient: 65dabd411c65d965d5b4c3d5decb909323d1363b + PetstoreClient: 575f4a5776e6a693e70f9d14bae0aabd8c467111 PODFILE CHECKSUM: 84472aca2a88b7f7ed9fcd63e9f5fdb5ad4aab94