forked from loafle/openapi-generator-original
parent
5bb444ba6d
commit
d11a19d171
@ -467,7 +467,6 @@ public class ApiClient {
|
|||||||
for (Entry<String, Object> param: formParams.entrySet()) {
|
for (Entry<String, Object> param: formParams.entrySet()) {
|
||||||
if (param.getValue() instanceof File) {
|
if (param.getValue() instanceof File) {
|
||||||
File file = (File) param.getValue();
|
File file = (File) param.getValue();
|
||||||
mp.field(param.getKey(), file.getName());
|
|
||||||
mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.MULTIPART_FORM_DATA_TYPE));
|
mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.MULTIPART_FORM_DATA_TYPE));
|
||||||
} else {
|
} else {
|
||||||
mp.field(param.getKey(), parameterToString(param.getValue()), MediaType.MULTIPART_FORM_DATA_TYPE);
|
mp.field(param.getKey(), parameterToString(param.getValue()), MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||||
|
@ -13,10 +13,9 @@ import javax.ws.rs.core.Response.Status;
|
|||||||
import org.glassfish.jersey.client.ClientConfig;
|
import org.glassfish.jersey.client.ClientConfig;
|
||||||
import org.glassfish.jersey.filter.LoggingFilter;
|
import org.glassfish.jersey.filter.LoggingFilter;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
|
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
import org.glassfish.jersey.media.multipart.MultiPart;
|
import org.glassfish.jersey.media.multipart.MultiPart;
|
||||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||||
import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -478,23 +477,19 @@ public class ApiClient {
|
|||||||
Entity<?> formEntity = null;
|
Entity<?> formEntity = null;
|
||||||
|
|
||||||
if (contentType.startsWith("multipart/form-data")) {
|
if (contentType.startsWith("multipart/form-data")) {
|
||||||
MultiPart multipart = new MultiPart();
|
MultiPart multiPart = new MultiPart();
|
||||||
for (Entry<String, Object> param: formParams.entrySet()) {
|
for (Entry<String, Object> param: formParams.entrySet()) {
|
||||||
if (param.getValue() instanceof File) {
|
if (param.getValue() instanceof File) {
|
||||||
File file = (File) param.getValue();
|
File file = (File) param.getValue();
|
||||||
|
FormDataContentDisposition contentDisp = FormDataContentDisposition.name(param.getKey())
|
||||||
FormDataMultiPart mp = new FormDataMultiPart();
|
.fileName(file.getName()).size(file.length()).build();
|
||||||
mp.bodyPart(new FormDataBodyPart(param.getKey(), file.getName()));
|
multiPart.bodyPart(new FormDataBodyPart(contentDisp, file, MediaType.APPLICATION_OCTET_STREAM_TYPE));
|
||||||
multipart.bodyPart(mp, MediaType.MULTIPART_FORM_DATA_TYPE);
|
|
||||||
|
|
||||||
multipart.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.APPLICATION_OCTET_STREAM_TYPE));
|
|
||||||
} else {
|
} else {
|
||||||
FormDataMultiPart mp = new FormDataMultiPart();
|
FormDataContentDisposition contentDisp = FormDataContentDisposition.name(param.getKey()).build();
|
||||||
mp.bodyPart(new FormDataBodyPart(param.getKey(), parameterToString(param.getValue())));
|
multiPart.bodyPart(new FormDataBodyPart(contentDisp, parameterToString(param.getValue())));
|
||||||
multipart.bodyPart(mp, MediaType.MULTIPART_FORM_DATA_TYPE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
formEntity = Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE);
|
formEntity = Entity.entity(multiPart, MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||||
} else if (contentType.startsWith("application/x-www-form-urlencoded")) {
|
} else if (contentType.startsWith("application/x-www-form-urlencoded")) {
|
||||||
Form form = new Form();
|
Form form = new Form();
|
||||||
for (Entry<String, Object> param: formParams.entrySet()) {
|
for (Entry<String, Object> param: formParams.entrySet()) {
|
||||||
|
@ -39,7 +39,7 @@ import io.swagger.client.auth.HttpBasicAuth;
|
|||||||
import io.swagger.client.auth.ApiKeyAuth;
|
import io.swagger.client.auth.ApiKeyAuth;
|
||||||
import io.swagger.client.auth.OAuth;
|
import io.swagger.client.auth.OAuth;
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:25.953+08:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-02T18:29:05.463+08:00")
|
||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||||
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
private Map<String, String> defaultHeaderMap = new HashMap<String, String>();
|
||||||
@ -69,8 +69,8 @@ public class ApiClient {
|
|||||||
|
|
||||||
// Setup authentications (key: authentication name, value: authentication).
|
// Setup authentications (key: authentication name, value: authentication).
|
||||||
authentications = new HashMap<String, Authentication>();
|
authentications = new HashMap<String, Authentication>();
|
||||||
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
|
|
||||||
authentications.put("petstore_auth", new OAuth());
|
authentications.put("petstore_auth", new OAuth());
|
||||||
|
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
|
||||||
// Prevent the authentications from being modified.
|
// Prevent the authentications from being modified.
|
||||||
authentications = Collections.unmodifiableMap(authentications);
|
authentications = Collections.unmodifiableMap(authentications);
|
||||||
}
|
}
|
||||||
@ -466,7 +466,6 @@ public class ApiClient {
|
|||||||
for (Entry<String, Object> param: formParams.entrySet()) {
|
for (Entry<String, Object> param: formParams.entrySet()) {
|
||||||
if (param.getValue() instanceof File) {
|
if (param.getValue() instanceof File) {
|
||||||
File file = (File) param.getValue();
|
File file = (File) param.getValue();
|
||||||
mp.field(param.getKey(), file.getName());
|
|
||||||
mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.MULTIPART_FORM_DATA_TYPE));
|
mp.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.MULTIPART_FORM_DATA_TYPE));
|
||||||
} else {
|
} else {
|
||||||
mp.field(param.getKey(), parameterToString(param.getValue()), MediaType.MULTIPART_FORM_DATA_TYPE);
|
mp.field(param.getKey(), parameterToString(param.getValue()), MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||||
|
@ -13,10 +13,9 @@ import javax.ws.rs.core.Response.Status;
|
|||||||
import org.glassfish.jersey.client.ClientConfig;
|
import org.glassfish.jersey.client.ClientConfig;
|
||||||
import org.glassfish.jersey.filter.LoggingFilter;
|
import org.glassfish.jersey.filter.LoggingFilter;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
|
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
|
||||||
import org.glassfish.jersey.media.multipart.FormDataMultiPart;
|
import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
|
||||||
import org.glassfish.jersey.media.multipart.MultiPart;
|
import org.glassfish.jersey.media.multipart.MultiPart;
|
||||||
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
import org.glassfish.jersey.media.multipart.MultiPartFeature;
|
||||||
import org.glassfish.jersey.media.multipart.file.FileDataBodyPart;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -43,7 +42,7 @@ import io.swagger.client.auth.HttpBasicAuth;
|
|||||||
import io.swagger.client.auth.ApiKeyAuth;
|
import io.swagger.client.auth.ApiKeyAuth;
|
||||||
import io.swagger.client.auth.OAuth;
|
import io.swagger.client.auth.OAuth;
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:01.946+08:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-02T18:29:08.393+08:00")
|
||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
private Client client;
|
private Client client;
|
||||||
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
private Map<String, Client> hostMap = new HashMap<String, Client>();
|
||||||
@ -76,8 +75,8 @@ public class ApiClient {
|
|||||||
|
|
||||||
// Setup authentications (key: authentication name, value: authentication).
|
// Setup authentications (key: authentication name, value: authentication).
|
||||||
authentications = new HashMap<String, Authentication>();
|
authentications = new HashMap<String, Authentication>();
|
||||||
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
|
|
||||||
authentications.put("petstore_auth", new OAuth());
|
authentications.put("petstore_auth", new OAuth());
|
||||||
|
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
|
||||||
// Prevent the authentications from being modified.
|
// Prevent the authentications from being modified.
|
||||||
authentications = Collections.unmodifiableMap(authentications);
|
authentications = Collections.unmodifiableMap(authentications);
|
||||||
}
|
}
|
||||||
@ -477,23 +476,19 @@ public class ApiClient {
|
|||||||
Entity<?> formEntity = null;
|
Entity<?> formEntity = null;
|
||||||
|
|
||||||
if (contentType.startsWith("multipart/form-data")) {
|
if (contentType.startsWith("multipart/form-data")) {
|
||||||
MultiPart multipart = new MultiPart();
|
MultiPart multiPart = new MultiPart();
|
||||||
for (Entry<String, Object> param: formParams.entrySet()) {
|
for (Entry<String, Object> param: formParams.entrySet()) {
|
||||||
if (param.getValue() instanceof File) {
|
if (param.getValue() instanceof File) {
|
||||||
File file = (File) param.getValue();
|
File file = (File) param.getValue();
|
||||||
|
FormDataContentDisposition contentDisp = FormDataContentDisposition.name(param.getKey())
|
||||||
FormDataMultiPart mp = new FormDataMultiPart();
|
.fileName(file.getName()).size(file.length()).build();
|
||||||
mp.bodyPart(new FormDataBodyPart(param.getKey(), file.getName()));
|
multiPart.bodyPart(new FormDataBodyPart(contentDisp, file, MediaType.APPLICATION_OCTET_STREAM_TYPE));
|
||||||
multipart.bodyPart(mp, MediaType.MULTIPART_FORM_DATA_TYPE);
|
|
||||||
|
|
||||||
multipart.bodyPart(new FileDataBodyPart(param.getKey(), file, MediaType.APPLICATION_OCTET_STREAM_TYPE));
|
|
||||||
} else {
|
} else {
|
||||||
FormDataMultiPart mp = new FormDataMultiPart();
|
FormDataContentDisposition contentDisp = FormDataContentDisposition.name(param.getKey()).build();
|
||||||
mp.bodyPart(new FormDataBodyPart(param.getKey(), parameterToString(param.getValue())));
|
multiPart.bodyPart(new FormDataBodyPart(contentDisp, parameterToString(param.getValue())));
|
||||||
multipart.bodyPart(mp, MediaType.MULTIPART_FORM_DATA_TYPE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
formEntity = Entity.entity(multipart, MediaType.MULTIPART_FORM_DATA_TYPE);
|
formEntity = Entity.entity(multiPart, MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||||
} else if (contentType.startsWith("application/x-www-form-urlencoded")) {
|
} else if (contentType.startsWith("application/x-www-form-urlencoded")) {
|
||||||
Form form = new Form();
|
Form form = new Form();
|
||||||
for (Entry<String, Object> param: formParams.entrySet()) {
|
for (Entry<String, Object> param: formParams.entrySet()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user