From 37404909bfb241d6c17782780941d9fb46413369 Mon Sep 17 00:00:00 2001 From: wing328 Date: Tue, 19 Jul 2016 16:55:39 +0800 Subject: [PATCH] to set a default description if none is provided --- .../io/swagger/codegen/DefaultGenerator.java | 12 +++++-- .../client/petstore/objc/core-data/README.md | 18 +++++----- .../core-data/SwaggerClient/Api/SWGPetApi.m | 2 +- .../SwaggerClient/Core/SWGConfiguration.m | 14 ++++---- .../SwaggerClient.xcodeproj/project.pbxproj | 36 +++++++++---------- .../client/petstore/objc/default/README.md | 2 +- .../SwaggerClient.xcodeproj/project.pbxproj | 36 +++++++++---------- 7 files changed, 63 insertions(+), 57 deletions(-) diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java index 20b6acca907a..0851a2e6f40d 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultGenerator.java @@ -17,7 +17,7 @@ import org.slf4j.LoggerFactory; import java.io.*; import java.util.*; -import static org.apache.commons.lang3.StringUtils.isNotEmpty; +import org.apache.commons.lang3.StringUtils; public class DefaultGenerator extends AbstractGenerator implements Generator { protected Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class); @@ -149,10 +149,16 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { if (info.getVersion() != null) { config.additionalProperties().put("appVersion", config.escapeText(info.getVersion())); } - if (info.getDescription() != null) { + + if (StringUtils.isEmpty(info.getDescription())) { + // set a default description if none if provided + config.additionalProperties().put("appDescription", + "No descripton provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)"); + } else { config.additionalProperties().put("appDescription", config.escapeText(info.getDescription())); } + if (info.getContact() != null) { Contact contact = info.getContact(); config.additionalProperties().put("infoUrl", config.escapeText(contact.getUrl())); @@ -522,7 +528,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator { for (SupportingFile support : config.supportingFiles()) { try { String outputFolder = config.outputFolder(); - if (isNotEmpty(support.folder)) { + if (StringUtils.isNotEmpty(support.folder)) { outputFolder += File.separator + support.folder; } File of = new File(outputFolder); diff --git a/samples/client/petstore/objc/core-data/README.md b/samples/client/petstore/objc/core-data/README.md index 151ffe96225f..3fe81114d774 100644 --- a/samples/client/petstore/objc/core-data/README.md +++ b/samples/client/petstore/objc/core-data/README.md @@ -6,7 +6,7 @@ This ObjC package is automatically generated by the [Swagger Codegen](https://gi - API version: 1.0.0 - Package version: -- Build date: 2016-06-16T11:33:34.619+02:00 +- Build date: 2016-07-19T16:53:26.476+08:00 - Build package: class io.swagger.codegen.languages.ObjcClientCodegen ## Requirements @@ -74,9 +74,9 @@ SWGPet* *body = [[SWGPet alloc] init]; // Pet object that needs to be added to t SWGPetApi *apiInstance = [[SWGPetApi alloc] init]; - // Add a new pet to the store +// Add a new pet to the store [apiInstance addPetWithBody:body - completionHandler: ^(NSError* error)) { + completionHandler: ^(NSError* error) { if (error) { NSLog(@"Error: %@", error); } @@ -124,6 +124,12 @@ Class | Method | HTTP request | Description ## Documentation For Authorization +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + ## petstore_auth - **Type**: OAuth @@ -133,12 +139,6 @@ Class | Method | HTTP request | Description - **write:pets**: modify pets in your account - **read:pets**: read your pets -## api_key - -- **Type**: API key -- **API key parameter name**: api_key -- **Location**: HTTP header - ## Author diff --git a/samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGPetApi.m b/samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGPetApi.m index 409f5b866557..e35421fc5202 100644 --- a/samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGPetApi.m +++ b/samples/client/petstore/objc/core-data/SwaggerClient/Api/SWGPetApi.m @@ -376,7 +376,7 @@ NSInteger kSWGPetApiMissingParamErrorCode = 234513; NSString *requestContentType = [self.apiClient.sanitizer selectHeaderContentType:@[]]; // Authentication setting - NSArray *authSettings = @[@"petstore_auth", @"api_key"]; + NSArray *authSettings = @[@"api_key", @"petstore_auth"]; id bodyParam = nil; NSMutableDictionary *formParams = [[NSMutableDictionary alloc] init]; diff --git a/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGConfiguration.m b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGConfiguration.m index 24172638bba6..b21290068a1c 100644 --- a/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGConfiguration.m +++ b/samples/client/petstore/objc/core-data/SwaggerClient/Core/SWGConfiguration.m @@ -110,13 +110,6 @@ - (NSDictionary *) authSettings { return @{ - @"petstore_auth": - @{ - @"type": @"oauth", - @"in": @"header", - @"key": @"Authorization", - @"value": [self getAccessToken] - }, @"api_key": @{ @"type": @"api_key", @@ -124,6 +117,13 @@ @"key": @"api_key", @"value": [self getApiKeyWithPrefix:@"api_key"] }, + @"petstore_auth": + @{ + @"type": @"oauth", + @"in": @"header", + @"key": @"Authorization", + @"value": [self getAccessToken] + }, }; } diff --git a/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj index b69c907b1612..68c3e696436d 100644 --- a/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj +++ b/samples/client/petstore/objc/core-data/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj @@ -214,12 +214,12 @@ isa = PBXNativeTarget; buildConfigurationList = 6003F5BF195388D20070C39A /* Build configuration list for PBXNativeTarget "SwaggerClient_Example" */; buildPhases = ( - 799E7E29D924C30424DFBA28 /* Check Pods Manifest.lock */, + 799E7E29D924C30424DFBA28 /* 📦 Check Pods Manifest.lock */, 6003F586195388D20070C39A /* Sources */, 6003F587195388D20070C39A /* Frameworks */, 6003F588195388D20070C39A /* Resources */, - 429AF5C69E165ED75311B4B0 /* Copy Pods Resources */, - 183E54C09C54DAEB54B2546F /* Embed Pods Frameworks */, + 429AF5C69E165ED75311B4B0 /* 📦 Copy Pods Resources */, + 183E54C09C54DAEB54B2546F /* 📦 Embed Pods Frameworks */, ); buildRules = ( ); @@ -234,12 +234,12 @@ isa = PBXNativeTarget; buildConfigurationList = 6003F5C2195388D20070C39A /* Build configuration list for PBXNativeTarget "SwaggerClient_Tests" */; buildPhases = ( - 7B069562A9F91E498732474F /* Check Pods Manifest.lock */, + 7B069562A9F91E498732474F /* 📦 Check Pods Manifest.lock */, 6003F5AA195388D20070C39A /* Sources */, 6003F5AB195388D20070C39A /* Frameworks */, 6003F5AC195388D20070C39A /* Resources */, - E337D7E459CCFFDF27046FFC /* Copy Pods Resources */, - 111D7956304BD6E860AA8709 /* Embed Pods Frameworks */, + E337D7E459CCFFDF27046FFC /* 📦 Copy Pods Resources */, + 111D7956304BD6E860AA8709 /* 📦 Embed Pods Frameworks */, ); buildRules = ( ); @@ -303,14 +303,14 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 111D7956304BD6E860AA8709 /* Embed Pods Frameworks */ = { + 111D7956304BD6E860AA8709 /* 📦 Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Embed Pods Frameworks"; + name = "📦 Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -318,14 +318,14 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwaggerClient_Tests/Pods-SwaggerClient_Tests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 183E54C09C54DAEB54B2546F /* Embed Pods Frameworks */ = { + 183E54C09C54DAEB54B2546F /* 📦 Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Embed Pods Frameworks"; + name = "📦 Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -333,14 +333,14 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwaggerClient_Example/Pods-SwaggerClient_Example-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 429AF5C69E165ED75311B4B0 /* Copy Pods Resources */ = { + 429AF5C69E165ED75311B4B0 /* 📦 Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Copy Pods Resources"; + name = "📦 Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -348,14 +348,14 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwaggerClient_Example/Pods-SwaggerClient_Example-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 799E7E29D924C30424DFBA28 /* Check Pods Manifest.lock */ = { + 799E7E29D924C30424DFBA28 /* 📦 Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Check Pods Manifest.lock"; + name = "📦 Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -363,14 +363,14 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - 7B069562A9F91E498732474F /* Check Pods Manifest.lock */ = { + 7B069562A9F91E498732474F /* 📦 Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Check Pods Manifest.lock"; + name = "📦 Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -378,14 +378,14 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - E337D7E459CCFFDF27046FFC /* Copy Pods Resources */ = { + E337D7E459CCFFDF27046FFC /* 📦 Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Copy Pods Resources"; + name = "📦 Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; diff --git a/samples/client/petstore/objc/default/README.md b/samples/client/petstore/objc/default/README.md index bef0aa17dabd..808a950606e1 100644 --- a/samples/client/petstore/objc/default/README.md +++ b/samples/client/petstore/objc/default/README.md @@ -6,7 +6,7 @@ This ObjC package is automatically generated by the [Swagger Codegen](https://gi - API version: 1.0.0 - Package version: -- Build date: 2016-07-03T21:49:00.509+08:00 +- Build date: 2016-07-19T16:53:24.981+08:00 - Build package: class io.swagger.codegen.languages.ObjcClientCodegen ## Requirements diff --git a/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj index cd20eb439986..25e7b5a2d2c2 100644 --- a/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj +++ b/samples/client/petstore/objc/default/SwaggerClientTests/SwaggerClient.xcodeproj/project.pbxproj @@ -232,12 +232,12 @@ isa = PBXNativeTarget; buildConfigurationList = 6003F5BF195388D20070C39A /* Build configuration list for PBXNativeTarget "SwaggerClient_Example" */; buildPhases = ( - 799E7E29D924C30424DFBA28 /* Check Pods Manifest.lock */, + 799E7E29D924C30424DFBA28 /* 📦 Check Pods Manifest.lock */, 6003F586195388D20070C39A /* Sources */, 6003F587195388D20070C39A /* Frameworks */, 6003F588195388D20070C39A /* Resources */, - 429AF5C69E165ED75311B4B0 /* Copy Pods Resources */, - 183E54C09C54DAEB54B2546F /* Embed Pods Frameworks */, + 429AF5C69E165ED75311B4B0 /* 📦 Copy Pods Resources */, + 183E54C09C54DAEB54B2546F /* 📦 Embed Pods Frameworks */, ); buildRules = ( ); @@ -252,12 +252,12 @@ isa = PBXNativeTarget; buildConfigurationList = 6003F5C2195388D20070C39A /* Build configuration list for PBXNativeTarget "SwaggerClient_Tests" */; buildPhases = ( - 7B069562A9F91E498732474F /* Check Pods Manifest.lock */, + 7B069562A9F91E498732474F /* 📦 Check Pods Manifest.lock */, 6003F5AA195388D20070C39A /* Sources */, 6003F5AB195388D20070C39A /* Frameworks */, 6003F5AC195388D20070C39A /* Resources */, - E337D7E459CCFFDF27046FFC /* Copy Pods Resources */, - 111D7956304BD6E860AA8709 /* Embed Pods Frameworks */, + E337D7E459CCFFDF27046FFC /* 📦 Copy Pods Resources */, + 111D7956304BD6E860AA8709 /* 📦 Embed Pods Frameworks */, ); buildRules = ( ); @@ -321,14 +321,14 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 111D7956304BD6E860AA8709 /* Embed Pods Frameworks */ = { + 111D7956304BD6E860AA8709 /* 📦 Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Embed Pods Frameworks"; + name = "📦 Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -336,14 +336,14 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwaggerClient_Tests/Pods-SwaggerClient_Tests-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 183E54C09C54DAEB54B2546F /* Embed Pods Frameworks */ = { + 183E54C09C54DAEB54B2546F /* 📦 Embed Pods Frameworks */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Embed Pods Frameworks"; + name = "📦 Embed Pods Frameworks"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -351,14 +351,14 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwaggerClient_Example/Pods-SwaggerClient_Example-frameworks.sh\"\n"; showEnvVarsInLog = 0; }; - 429AF5C69E165ED75311B4B0 /* Copy Pods Resources */ = { + 429AF5C69E165ED75311B4B0 /* 📦 Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Copy Pods Resources"; + name = "📦 Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -366,14 +366,14 @@ shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwaggerClient_Example/Pods-SwaggerClient_Example-resources.sh\"\n"; showEnvVarsInLog = 0; }; - 799E7E29D924C30424DFBA28 /* Check Pods Manifest.lock */ = { + 799E7E29D924C30424DFBA28 /* 📦 Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Check Pods Manifest.lock"; + name = "📦 Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -381,14 +381,14 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - 7B069562A9F91E498732474F /* Check Pods Manifest.lock */ = { + 7B069562A9F91E498732474F /* 📦 Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Check Pods Manifest.lock"; + name = "📦 Check Pods Manifest.lock"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0; @@ -396,14 +396,14 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; - E337D7E459CCFFDF27046FFC /* Copy Pods Resources */ = { + E337D7E459CCFFDF27046FFC /* 📦 Copy Pods Resources */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( ); - name = "Copy Pods Resources"; + name = "📦 Copy Pods Resources"; outputPaths = ( ); runOnlyForDeploymentPostprocessing = 0;