From 39ac8f6d467aadd4f152b04991ffeb4008aaa6de Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Tue, 25 Feb 2014 12:52:49 -0800 Subject: [PATCH] added patch support --- .../resources/android-java/apiInvoker.mustache | 12 ++++++++++++ .../resources/android-java/httpPatch.mustache | 16 ++++++++++++++++ src/main/resources/android-java/pom.mustache | 2 +- 3 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 src/main/resources/android-java/httpPatch.mustache diff --git a/src/main/resources/android-java/apiInvoker.mustache b/src/main/resources/android-java/apiInvoker.mustache index e67bddc377a0..425c2e7e004c 100644 --- a/src/main/resources/android-java/apiInvoker.mustache +++ b/src/main/resources/android-java/apiInvoker.mustache @@ -184,6 +184,18 @@ public class ApiInvoker { } response = client.execute(delete); } + else if ("PATCH".equals(method)) { + HttpPatch patch = new HttpPatch(url); + + if (body != null) { + patch.setHeader("Content-Type", contentType); + patch.setEntity(new StringEntity(serialize(body), "UTF-8")); + } + for(String key : headers.keySet()) { + patch.setHeader(key, headers.get(key)); + } + response = client.execute(patch); + } int code = response.getStatusLine().getStatusCode(); String responseString = null; diff --git a/src/main/resources/android-java/httpPatch.mustache b/src/main/resources/android-java/httpPatch.mustache new file mode 100644 index 000000000000..55cec2f12790 --- /dev/null +++ b/src/main/resources/android-java/httpPatch.mustache @@ -0,0 +1,16 @@ +package {{invokerPackage}}; + +import org.apache.http.client.methods.*; + +public class HttpPatch extends HttpPost { + public static final String METHOD_PATCH = "PATCH"; + + public HttpPatch(final String url) { + super(url); + } + + @Override + public String getMethod() { + return METHOD_PATCH; + } +} \ No newline at end of file diff --git a/src/main/resources/android-java/pom.mustache b/src/main/resources/android-java/pom.mustache index edf017a47d51..c595e16d83aa 100644 --- a/src/main/resources/android-java/pom.mustache +++ b/src/main/resources/android-java/pom.mustache @@ -5,7 +5,7 @@ {{artifactId}} jar {{artifactId}} - {{apiVersion}} + {{artifactVersion}} scm:git:git@github.com:wordnik/swagger-mustache.git scm:git:git@github.com:wordnik/swagger-codegen.git