minor fix to android after switching default lib

This commit is contained in:
wing328
2016-05-15 14:40:20 +08:00
parent c5136e4dda
commit d01305671f
35 changed files with 44 additions and 43 deletions

View File

@@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead. # if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -t modules/swagger-codegen/src/main/resources/android -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l android -o samples/client/petstore/android/httpclient" ags="$@ generate -t modules/swagger-codegen/src/main/resources/android -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l android -Dlibrary=httpclient -o samples/client/petstore/android/httpclient"
java $JAVA_OPTS -jar $executable $ags java $JAVA_OPTS -jar $executable $ags

View File

@@ -26,6 +26,6 @@ fi
# if you've executed sbt assembly previously it will use that instead. # if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l android -c bin/android-petstore-volley.json -o samples/client/petstore/android/volley" ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l android -o samples/client/petstore/android/volley"
java $JAVA_OPTS -jar $executable $ags java $JAVA_OPTS -jar $executable $ags

View File

@@ -89,8 +89,8 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
cliOptions.add(CliOption.newBoolean(USE_ANDROID_MAVEN_GRADLE_PLUGIN, "A flag to toggle android-maven gradle plugin.") cliOptions.add(CliOption.newBoolean(USE_ANDROID_MAVEN_GRADLE_PLUGIN, "A flag to toggle android-maven gradle plugin.")
.defaultValue(Boolean.TRUE.toString())); .defaultValue(Boolean.TRUE.toString()));
supportedLibraries.put("volley", "HTTP client: Volley 1.0.19"); supportedLibraries.put("volley", "HTTP client: Volley 1.0.19 (default)");
supportedLibraries.put("httpclient", "HTTP client: Apache HttpClient 4.3.6. JSON processing: Gson 2.3.1"); supportedLibraries.put("httpclient", "HTTP client: Apache HttpClient 4.3.6. JSON processing: Gson 2.3.1. IMPORTANT: Android client using HttpClient is not actively maintained and will be depecreated in the next major release.");
CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use"); CliOption library = new CliOption(CodegenConstants.LIBRARY, "library template (sub-template) to use");
library.setEnum(supportedLibraries); library.setEnum(supportedLibraries);
cliOptions.add(library); cliOptions.add(library);
@@ -382,30 +382,26 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
additionalProperties.put( "modelDocPath", modelDocPath ); additionalProperties.put( "modelDocPath", modelDocPath );
if (StringUtils.isEmpty(getLibrary())) { if (StringUtils.isEmpty(getLibrary())) {
modelDocTemplateFiles.put( "model_doc.mustache", ".md" ); setLibrary("volley"); // set volley as the default library
apiDocTemplateFiles.put( "api_doc.mustache", ".md" );
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
//supportingFiles.add(new SupportingFile("api_doc.mustache", apiDocPath, "api.md"));
//supportingFiles.add(new SupportingFile("model_doc.mustache", modelDocPath, "model.md"));
addSupportingFilesForVolley();
}else if( "volley".equals( getLibrary() ) ){
modelDocTemplateFiles.put( "model_doc.mustache", ".md" );
apiDocTemplateFiles.put( "api_doc.mustache", ".md" );
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
//supportingFiles.add(new SupportingFile("api_doc.mustache", apiDocPath, "api.md"));
//supportingFiles.add(new SupportingFile("model_doc.mustache", modelDocPath, "model.md"));
addSupportingFilesForVolley();
}else if ("http-client".equals(getLibrary())) {
modelDocTemplateFiles.put( "model_doc.mustache", ".md" );
apiDocTemplateFiles.put( "api_doc.mustache", ".md" );
//supportingFiles.add(new SupportingFile("api_doc.mustache", apiDocPath, "api.md"));
//supportingFiles.add(new SupportingFile("model_doc.mustache", modelDocPath, "model.md"));
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
addSupportingFilesForHttpClient();
} }
// determine which file (mustache) to add based on library
if ("volley".equals(getLibrary())) {
addSupportingFilesForVolley();
} else if ("httpclient".equals(getLibrary())) {
addSupportingFilesForHttpClient();
} else {
throw new IllegalArgumentException("Invalid 'library' option specified: '" + getLibrary() + "'. Must be 'httpclient' or 'volley' (default)");
}
} }
private void addSupportingFilesForHttpClient() { private void addSupportingFilesForHttpClient() {
// documentation files
modelDocTemplateFiles.put( "model_doc.mustache", ".md" );
apiDocTemplateFiles.put( "api_doc.mustache", ".md" );
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));
supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle")); supportingFiles.add(new SupportingFile("settings.gradle.mustache", "", "settings.gradle"));
supportingFiles.add(new SupportingFile("build.mustache", "", "build.gradle")); supportingFiles.add(new SupportingFile("build.mustache", "", "build.gradle"));
@@ -425,6 +421,11 @@ public class AndroidClientCodegen extends DefaultCodegen implements CodegenConfi
} }
private void addSupportingFilesForVolley() { private void addSupportingFilesForVolley() {
// documentation files
modelDocTemplateFiles.put( "model_doc.mustache", ".md" );
apiDocTemplateFiles.put( "api_doc.mustache", ".md" );
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml")); supportingFiles.add(new SupportingFile("pom.mustache", "", "pom.xml"));

View File

@@ -18,7 +18,7 @@ public class AndroidClientOptionsProvider implements OptionsProvider {
public static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT"; public static final String ARTIFACT_VERSION_VALUE = "1.0.0-SNAPSHOT";
public static final String SOURCE_FOLDER_VALUE = "src/main/java/test"; public static final String SOURCE_FOLDER_VALUE = "src/main/java/test";
public static final String ANDROID_MAVEN_GRADLE_PLUGIN_VALUE = "true"; public static final String ANDROID_MAVEN_GRADLE_PLUGIN_VALUE = "true";
public static final String LIBRARY_VALUE = "volley"; public static final String LIBRARY_VALUE = "httpclient";
@Override @Override
public String getLanguage() { public String getLanguage() {

View File

@@ -267,7 +267,7 @@
</property> </property>
</activation> </activation>
<modules> <modules>
<module>samples/client/petstore/android/default</module> <module>samples/client/petstore/android/volley</module>
</modules> </modules>
</profile> </profile>
<profile> <profile>
@@ -471,7 +471,7 @@
</property> </property>
</activation> </activation>
<modules> <modules>
<module>samples/client/petstore/android/default</module> <module>samples/client/petstore/android/volley</module>
<module>samples/client/petstore/clojure</module> <module>samples/client/petstore/clojure</module>
<module>samples/client/petstore/java/default</module> <module>samples/client/petstore/java/default</module>
<module>samples/client/petstore/java/feign</module> <module>samples/client/petstore/java/feign</module>

View File

@@ -116,6 +116,12 @@ Class | Method | HTTP request | Description
## Documentation for Authorization ## Documentation for Authorization
Authentication schemes defined for the API: Authentication schemes defined for the API:
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
### petstore_auth ### petstore_auth
- **Type**: OAuth - **Type**: OAuth
@@ -125,12 +131,6 @@ Authentication schemes defined for the API:
- write:pets: modify pets in your account - write:pets: modify pets in your account
- read:pets: read your pets - read:pets: read your pets
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
## Recommendation ## Recommendation

View File

@@ -222,7 +222,7 @@ Name | Type | Description | Notes
### Authorization ### Authorization
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) [api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
### HTTP request headers ### HTTP request headers

View File

@@ -116,6 +116,12 @@ Class | Method | HTTP request | Description
## Documentation for Authorization ## Documentation for Authorization
Authentication schemes defined for the API: Authentication schemes defined for the API:
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
### petstore_auth ### petstore_auth
- **Type**: OAuth - **Type**: OAuth
@@ -125,12 +131,6 @@ Authentication schemes defined for the API:
- write:pets: modify pets in your account - write:pets: modify pets in your account
- read:pets: read your pets - read:pets: read your pets
### api_key
- **Type**: API key
- **API key parameter name**: api_key
- **Location**: HTTP header
## Recommendation ## Recommendation

View File

@@ -222,7 +222,7 @@ Name | Type | Description | Notes
### Authorization ### Authorization
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key) [api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
### HTTP request headers ### HTTP request headers