Minor improvement to Java API client accept and content-type header

This commit is contained in:
xhh 2015-05-24 08:51:08 +08:00
parent 095771d345
commit 141b580c8c
6 changed files with 273 additions and 95 deletions

View File

@ -64,13 +64,19 @@ public class {{classname}} {
{{#queryParams}}if ({{paramName}} != null) {{#queryParams}}if ({{paramName}} != null)
queryParams.put("{{baseName}}", ApiInvoker.parameterToString({{paramName}})); queryParams.put("{{baseName}}", ApiInvoker.parameterToString({{paramName}}));
{{/queryParams}} {{/queryParams}}
final String[] accepts = {
{{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
{{#consumes}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/consumes}}
};
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
{{#headerParams}}headerParams.put("{{baseName}}", ApiInvoker.parameterToString({{paramName}})); {{#headerParams}}headerParams.put("{{baseName}}", ApiInvoker.parameterToString({{paramName}}));
{{/headerParams}} {{/headerParams}}
String[] contentTypes = {
{{#consumes}}"{{mediaType}}"{{#hasMore}},{{/hasMore}}{{/consumes}}
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -92,7 +98,7 @@ public class {{classname}} {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "{{httpMethod}}", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "{{httpMethod}}", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return {{#returnType}}({{{returnType}}}) ApiInvoker.deserialize(response, "{{returnContainer}}", {{returnBaseType}}.class){{/returnType}}; return {{#returnType}}({{{returnType}}}) ApiInvoker.deserialize(response, "{{returnContainer}}", {{returnBaseType}}.class){{/returnType}};
} }

View File

@ -16,6 +16,7 @@ import com.sun.jersey.multipart.FormDataMultiPart;
import javax.ws.rs.core.Response.Status.Family; import javax.ws.rs.core.Response.Status.Family;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -105,6 +106,31 @@ public class ApiInvoker {
return String.valueOf(param); return String.valueOf(param);
} }
} }
public static String selectHeaderAccept(String[] accepts) {
if (accepts.length == 0) return "application/json";
if (Arrays.asList(accepts).contains("application/json")) return "application/json";
return joinString(accepts, ",");
}
public static String selectHeaderContentType(String[] contentTypes) {
if (contentTypes.length == 0) return "application/json";
if (Arrays.asList(contentTypes).contains("application/json")) return "application/json";
return contentTypes[0];
}
public static String joinString(String[] array, String separator) {
int len = array.length;
if (len == 0) return "";
StringBuilder out = new StringBuilder();
out.append(array[0]);
for (int i = 1; i < len; i++) {
out.append(separator).append(array[i]);
}
return out.toString();
}
public void enableDebug() { public void enableDebug() {
isDebug = true; isDebug = true;
} }
@ -163,7 +189,7 @@ public class ApiInvoker {
} }
} }
public String invokeAPI(String host, String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, Map<String, String> formParams, String contentType) throws ApiException { public String invokeAPI(String host, String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, Map<String, String> formParams, String accept, String contentType) throws ApiException {
Client client = getClient(host); Client client = getClient(host);
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
@ -180,7 +206,7 @@ public class ApiInvoker {
} }
String querystring = b.toString(); String querystring = b.toString();
Builder builder = client.resource(host + path + querystring).accept("application/json"); Builder builder = client.resource(host + path + querystring).accept(accept);
for(String key : headerParams.keySet()) { for(String key : headerParams.keySet()) {
builder = builder.header(key, headerParams.get(key)); builder = builder.header(key, headerParams.get(key));
} }

View File

@ -16,6 +16,7 @@ import com.sun.jersey.multipart.FormDataMultiPart;
import javax.ws.rs.core.Response.Status.Family; import javax.ws.rs.core.Response.Status.Family;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -105,6 +106,31 @@ public class ApiInvoker {
return String.valueOf(param); return String.valueOf(param);
} }
} }
public static String selectHeaderAccept(String[] accepts) {
if (accepts.length == 0) return "application/json";
if (Arrays.asList(accepts).contains("application/json")) return "application/json";
return joinString(accepts, ",");
}
public static String selectHeaderContentType(String[] contentTypes) {
if (contentTypes.length == 0) return "application/json";
if (Arrays.asList(contentTypes).contains("application/json")) return "application/json";
return contentTypes[0];
}
public static String joinString(String[] array, String separator) {
int len = array.length;
if (len == 0) return "";
StringBuilder out = new StringBuilder();
out.append(array[0]);
for (int i = 1; i < len; i++) {
out.append(separator).append(array[i]);
}
return out.toString();
}
public void enableDebug() { public void enableDebug() {
isDebug = true; isDebug = true;
} }
@ -163,7 +189,7 @@ public class ApiInvoker {
} }
} }
public String invokeAPI(String host, String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, Map<String, String> formParams, String contentType) throws ApiException { public String invokeAPI(String host, String path, String method, Map<String, String> queryParams, Object body, Map<String, String> headerParams, Map<String, String> formParams, String accept, String contentType) throws ApiException {
Client client = getClient(host); Client client = getClient(host);
StringBuilder b = new StringBuilder(); StringBuilder b = new StringBuilder();
@ -180,7 +206,7 @@ public class ApiInvoker {
} }
String querystring = b.toString(); String querystring = b.toString();
Builder builder = client.resource(host + path + querystring).accept("application/json"); Builder builder = client.resource(host + path + querystring).accept(accept);
for(String key : headerParams.keySet()) { for(String key : headerParams.keySet()) {
builder = builder.header(key, headerParams.get(key)); builder = builder.header(key, headerParams.get(key));
} }

View File

@ -55,12 +55,18 @@ public class PetApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = {
"application/json","application/xml"
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
"application/json", "application/xml"
};
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -74,7 +80,7 @@ public class PetApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return ; return ;
} }
@ -105,12 +111,18 @@ public class PetApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = {
"application/json","application/xml"
};
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
"application/json", "application/xml"
};
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -124,7 +136,7 @@ public class PetApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return ; return ;
} }
@ -157,12 +169,18 @@ public class PetApi {
if (status != null) if (status != null)
queryParams.put("status", ApiInvoker.parameterToString(status)); queryParams.put("status", ApiInvoker.parameterToString(status));
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -176,7 +194,7 @@ public class PetApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return (List<Pet>) ApiInvoker.deserialize(response, "array", Pet.class); return (List<Pet>) ApiInvoker.deserialize(response, "array", Pet.class);
} }
@ -209,12 +227,18 @@ public class PetApi {
if (tags != null) if (tags != null)
queryParams.put("tags", ApiInvoker.parameterToString(tags)); queryParams.put("tags", ApiInvoker.parameterToString(tags));
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -228,7 +252,7 @@ public class PetApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return (List<Pet>) ApiInvoker.deserialize(response, "array", Pet.class); return (List<Pet>) ApiInvoker.deserialize(response, "array", Pet.class);
} }
@ -265,12 +289,18 @@ public class PetApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -284,7 +314,7 @@ public class PetApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return (Pet) ApiInvoker.deserialize(response, "", Pet.class); return (Pet) ApiInvoker.deserialize(response, "", Pet.class);
} }
@ -323,12 +353,18 @@ public class PetApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
"application/x-www-form-urlencoded" "application/x-www-form-urlencoded"
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -350,7 +386,7 @@ public class PetApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return ; return ;
} }
@ -388,13 +424,19 @@ public class PetApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
headerParams.put("api_key", ApiInvoker.parameterToString(apiKey));
final String[] accepts = {
String[] contentTypes = { "application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; headerParams.put("api_key", ApiInvoker.parameterToString(apiKey));
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -408,7 +450,7 @@ public class PetApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return ; return ;
} }
@ -447,12 +489,18 @@ public class PetApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
"multipart/form-data" "multipart/form-data"
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -475,7 +523,7 @@ public class PetApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return ; return ;
} }

View File

@ -54,12 +54,18 @@ public class StoreApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -73,7 +79,7 @@ public class StoreApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return (Map<String, Integer>) ApiInvoker.deserialize(response, "map", Map.class); return (Map<String, Integer>) ApiInvoker.deserialize(response, "map", Map.class);
} }
@ -104,12 +110,18 @@ public class StoreApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -123,7 +135,7 @@ public class StoreApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return (Order) ApiInvoker.deserialize(response, "", Order.class); return (Order) ApiInvoker.deserialize(response, "", Order.class);
} }
@ -160,12 +172,18 @@ public class StoreApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -179,7 +197,7 @@ public class StoreApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return (Order) ApiInvoker.deserialize(response, "", Order.class); return (Order) ApiInvoker.deserialize(response, "", Order.class);
} }
@ -216,12 +234,18 @@ public class StoreApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -235,7 +259,7 @@ public class StoreApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return ; return ;
} }

View File

@ -55,12 +55,18 @@ public class UserApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -74,7 +80,7 @@ public class UserApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return ; return ;
} }
@ -105,12 +111,18 @@ public class UserApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -124,7 +136,7 @@ public class UserApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return ; return ;
} }
@ -155,12 +167,18 @@ public class UserApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -174,7 +192,7 @@ public class UserApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "POST", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return ; return ;
} }
@ -210,12 +228,18 @@ public class UserApi {
if (password != null) if (password != null)
queryParams.put("password", ApiInvoker.parameterToString(password)); queryParams.put("password", ApiInvoker.parameterToString(password));
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -229,7 +253,7 @@ public class UserApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return (String) ApiInvoker.deserialize(response, "", String.class); return (String) ApiInvoker.deserialize(response, "", String.class);
} }
@ -259,12 +283,18 @@ public class UserApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -278,7 +308,7 @@ public class UserApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return ; return ;
} }
@ -315,12 +345,18 @@ public class UserApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -334,7 +370,7 @@ public class UserApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return (User) ApiInvoker.deserialize(response, "", User.class); return (User) ApiInvoker.deserialize(response, "", User.class);
} }
@ -372,12 +408,18 @@ public class UserApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -391,7 +433,7 @@ public class UserApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "PUT", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return ; return ;
} }
@ -428,12 +470,18 @@ public class UserApi {
Map<String, String> formParams = new HashMap<String, String>(); Map<String, String> formParams = new HashMap<String, String>();
String[] contentTypes = { final String[] accepts = {
"application/json", "application/xml"
};
final String accept = ApiInvoker.selectHeaderAccept(accepts);
final String[] contentTypes = {
}; };
final String contentType = ApiInvoker.selectHeaderContentType(contentTypes);
String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json";
if(contentType.startsWith("multipart/form-data")) { if(contentType.startsWith("multipart/form-data")) {
boolean hasFields = false; boolean hasFields = false;
@ -447,7 +495,7 @@ public class UserApi {
} }
try { try {
String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, contentType); String response = apiInvoker.invokeAPI(basePath, path, "DELETE", queryParams, postBody, headerParams, formParams, accept, contentType);
if(response != null){ if(response != null){
return ; return ;
} }