forked from loafle/openapi-generator-original
added support in feign for binary uploads
This commit is contained in:
parent
538ccb3f12
commit
1723078508
@ -4,21 +4,31 @@ import java.io.*;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
|
import feign.codec.EncodeException;
|
||||||
import feign.codec.Encoder;
|
import feign.codec.Encoder;
|
||||||
import feign.RequestTemplate;
|
import feign.RequestTemplate;
|
||||||
|
|
||||||
{{>generatedAnnotation}}
|
{{>generatedAnnotation}}
|
||||||
public class FormAwareEncoder implements Encoder {
|
public class FormAwareEncoder implements Encoder {
|
||||||
|
public static final String UTF_8 = "utf-8";
|
||||||
private static final String LINE_FEED = "\r\n";
|
private static final String LINE_FEED = "\r\n";
|
||||||
|
private static final String TWO_DASH = "--";
|
||||||
private static final String BOUNDARY = "----------------314159265358979323846";
|
private static final String BOUNDARY = "----------------314159265358979323846";
|
||||||
|
|
||||||
|
private byte[] lineFeedBytes;
|
||||||
|
private byte[] boundaryBytes;
|
||||||
|
private byte[] twoDashBytes;
|
||||||
|
private byte[] atBytes;
|
||||||
|
private byte[] eqBytes;
|
||||||
|
|
||||||
private final Encoder delegate;
|
private final Encoder delegate;
|
||||||
private DateFormat dateFormat;
|
private final DateFormat dateFormat;
|
||||||
|
|
||||||
public FormAwareEncoder(Encoder delegate) {
|
public FormAwareEncoder(Encoder delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
@ -28,93 +38,121 @@ public class FormAwareEncoder implements Encoder {
|
|||||||
|
|
||||||
// Use UTC as the default time zone.
|
// Use UTC as the default time zone.
|
||||||
this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
try {
|
||||||
|
this.lineFeedBytes = LINE_FEED.getBytes(UTF_8);
|
||||||
|
this.boundaryBytes = BOUNDARY.getBytes(UTF_8);
|
||||||
|
this.twoDashBytes = TWO_DASH.getBytes(UTF_8);
|
||||||
|
this.atBytes = "&".getBytes(UTF_8);
|
||||||
|
this.eqBytes = "=".getBytes(UTF_8);
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void encode(Object object, Type bodyType, RequestTemplate template) {
|
public void encode(Object object, Type bodyType, RequestTemplate template) throws EncodeException {
|
||||||
if (object instanceof Map) {
|
if (object instanceof Map) {
|
||||||
StringBuilder formParamBuilder = new StringBuilder();
|
try {
|
||||||
Map<String, Object> formParams = (Map<String, Object>) object;
|
encodeFormParams(template, (Map<String, Object>) object);
|
||||||
boolean isMultiPart = isMultiPart(formParams);
|
} catch (IOException e) {
|
||||||
for (Map.Entry<String, Object> param : formParams.entrySet()) {
|
throw new EncodeException("Failed to create request", e);
|
||||||
String keyStr = param.getKey();
|
|
||||||
if (param.getValue() instanceof File) {
|
|
||||||
addFilePart(formParamBuilder, keyStr, (File) param.getValue());
|
|
||||||
} else {
|
|
||||||
String valueStr = parameterToString(param.getValue());
|
|
||||||
if (isMultiPart) {
|
|
||||||
addMultiPartFormField(formParamBuilder, keyStr, valueStr);
|
|
||||||
} else {
|
|
||||||
addEncodedFormField(formParamBuilder, keyStr, valueStr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMultiPart) {
|
|
||||||
formParamBuilder.append(LINE_FEED);
|
|
||||||
formParamBuilder.append("--").append(BOUNDARY).append("--").append(LINE_FEED);
|
|
||||||
}
|
|
||||||
|
|
||||||
String contentType = isMultiPart ? "multipart/form-data; boundary=" + BOUNDARY : "application/x-www-form-urlencoded";
|
|
||||||
template.header("Content-type");
|
|
||||||
template.header("Content-type", contentType);
|
|
||||||
template.header("MIME-Version", "1.0");
|
|
||||||
template.body(formParamBuilder.toString());
|
|
||||||
} else {
|
} else {
|
||||||
delegate.encode(object, bodyType, template);
|
delegate.encode(object, bodyType, template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void encodeFormParams(RequestTemplate template, Map<String, Object> formParams) throws IOException {
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
boolean isMultiPart = isMultiPart(formParams);
|
||||||
|
boolean isFirstField = true;
|
||||||
|
for (Map.Entry<String, Object> param : formParams.entrySet()) {
|
||||||
|
String keyStr = param.getKey();
|
||||||
|
if (param.getValue() instanceof File) {
|
||||||
|
addFilePart(baos, keyStr, (File) param.getValue());
|
||||||
|
} else {
|
||||||
|
String valueStr = parameterToString(param.getValue());
|
||||||
|
if (isMultiPart) {
|
||||||
|
addMultiPartFormField(baos, keyStr, valueStr);
|
||||||
|
} else {
|
||||||
|
addEncodedFormField(baos, keyStr, valueStr, isFirstField);
|
||||||
|
isFirstField = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isMultiPart) {
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
|
baos.write(twoDashBytes);
|
||||||
|
baos.write(boundaryBytes);
|
||||||
|
baos.write(twoDashBytes);
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
String contentType = isMultiPart ? "multipart/form-data; boundary=" + BOUNDARY : "application/x-www-form-urlencoded";
|
||||||
|
template.header("Content-type");
|
||||||
|
template.header("Content-type", contentType);
|
||||||
|
template.header("MIME-Version", "1.0");
|
||||||
|
template.body(baos.toByteArray(), Charset.forName(UTF_8));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Currently only supports text files
|
* Currently only supports text files
|
||||||
*/
|
*/
|
||||||
private void addFilePart(StringBuilder formParamBuilder, String fieldName, File uploadFile) {
|
private void addFilePart(ByteArrayOutputStream baos, String fieldName, File uploadFile) throws IOException {
|
||||||
try {
|
String fileName = uploadFile.getName();
|
||||||
String fileName = uploadFile.getName();
|
baos.write(twoDashBytes);
|
||||||
formParamBuilder.append("--").append(BOUNDARY).append(LINE_FEED);
|
baos.write(boundaryBytes);
|
||||||
formParamBuilder.append(
|
baos.write(lineFeedBytes);
|
||||||
"Content-Disposition: form-data; name=\"" + fieldName
|
|
||||||
+ "\"; filename=\"" + fileName + "\"")
|
|
||||||
.append(LINE_FEED);
|
|
||||||
formParamBuilder.append(
|
|
||||||
"Content-Type: "
|
|
||||||
+ URLConnection.guessContentTypeFromName(fileName))
|
|
||||||
.append(LINE_FEED);
|
|
||||||
formParamBuilder.append(LINE_FEED);
|
|
||||||
|
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(uploadFile));
|
String contentDisposition = "Content-Disposition: form-data; name=\"" + fieldName
|
||||||
String line = "";
|
+ "\"; filename=\"" + fileName + "\"";
|
||||||
while ((line = reader.readLine()) != null) {
|
baos.write(contentDisposition.getBytes(UTF_8));
|
||||||
formParamBuilder.append(line).append(LINE_FEED);
|
baos.write(lineFeedBytes);
|
||||||
}
|
String contentType = "Content-Type: " + URLConnection.guessContentTypeFromName(fileName);
|
||||||
|
baos.write(contentType.getBytes(UTF_8));
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
|
|
||||||
formParamBuilder.append(LINE_FEED);
|
BufferedReader reader = new BufferedReader(new FileReader(uploadFile));
|
||||||
} catch (IOException e) {
|
InputStream input = new FileInputStream(uploadFile);
|
||||||
e.printStackTrace();
|
byte[] bytes = new byte[4096];
|
||||||
|
int len = bytes.length;
|
||||||
|
while ((len = input.read(bytes)) != -1) {
|
||||||
|
baos.write(bytes, 0, len);
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addEncodedFormField(StringBuilder formParamBuilder, String name, String value) {
|
private void addEncodedFormField(ByteArrayOutputStream baos, String name, String value, boolean isFirstField) throws IOException {
|
||||||
if (formParamBuilder.length() > 0) {
|
if (!isFirstField) {
|
||||||
formParamBuilder.append("&");
|
baos.write(atBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
String encodedName = URLEncoder.encode(name, UTF_8);
|
||||||
formParamBuilder.append(URLEncoder.encode(name, "utf8"))
|
String encodedValue = URLEncoder.encode(value, UTF_8);
|
||||||
.append("=")
|
baos.write(encodedName.getBytes(UTF_8));
|
||||||
.append(URLEncoder.encode(value, "utf8"));
|
baos.write("=".getBytes(UTF_8));
|
||||||
} catch (UnsupportedEncodingException e) {
|
baos.write(encodedValue.getBytes(UTF_8));
|
||||||
// move on to next
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMultiPartFormField(StringBuilder formParamBuilder, String name, String value) {
|
private void addMultiPartFormField(ByteArrayOutputStream baos, String name, String value) throws IOException {
|
||||||
formParamBuilder.append("--").append(BOUNDARY).append(LINE_FEED);
|
baos.write(twoDashBytes);
|
||||||
formParamBuilder.append("Content-Disposition: form-data; name=\"" + name + "\"")
|
baos.write(boundaryBytes);
|
||||||
.append(LINE_FEED);
|
baos.write(lineFeedBytes);
|
||||||
formParamBuilder.append("Content-Type: text/plain; charset=utf-8").append(
|
|
||||||
LINE_FEED);
|
String contentDisposition = "Content-Disposition: form-data; name=\"" + name + "\"";
|
||||||
formParamBuilder.append(LINE_FEED);
|
String contentType = "Content-Type: text/plain; charset=utf-8";
|
||||||
formParamBuilder.append(value).append(LINE_FEED);
|
|
||||||
|
baos.write(contentDisposition.getBytes(UTF_8));
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
|
baos.write(contentType.getBytes(UTF_8));
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
|
baos.write(value.getBytes(UTF_8));
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMultiPart(Map<String, Object> formParams) {
|
private boolean isMultiPart(Map<String, Object> formParams) {
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
package {{package}};
|
package {{package}};
|
||||||
|
|
||||||
import {{invokerPackage}}.ApiException;
|
|
||||||
import {{invokerPackage}}.ApiClient;
|
import {{invokerPackage}}.ApiClient;
|
||||||
import {{invokerPackage}}.Configuration;
|
|
||||||
import {{invokerPackage}}.Pair;
|
|
||||||
import {{invokerPackage}}.TypeRef;
|
|
||||||
|
|
||||||
{{#imports}}import {{import}};
|
{{#imports}}import {{import}};
|
||||||
{{/imports}}
|
{{/imports}}
|
||||||
@ -14,7 +10,7 @@ import {{invokerPackage}}.TypeRef;
|
|||||||
import feign.*;
|
import feign.*;
|
||||||
|
|
||||||
{{>generatedAnnotation}}
|
{{>generatedAnnotation}}
|
||||||
public interface {{classname}} extends {{invokerPackage}}.ApiClient.Api {
|
public interface {{classname}} extends ApiClient.Api {
|
||||||
|
|
||||||
{{#operations}}{{#operation}}
|
{{#operations}}{{#operation}}
|
||||||
/**
|
/**
|
||||||
@ -30,7 +26,7 @@ public interface {{classname}} extends {{invokerPackage}}.ApiClient.Api {
|
|||||||
"{{paramName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{#hasMore}},
|
"{{paramName}}: {{=<% %>=}}{<%paramName%>}<%={{ }}=%>"{{#hasMore}},
|
||||||
{{/hasMore}}{{/headerParams}}
|
{{/hasMore}}{{/headerParams}}
|
||||||
})
|
})
|
||||||
{{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#allParams}}{{^vendorExtensions.x-isBody}}@Param("{{paramName}}") {{/vendorExtensions.x-isBody}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException;
|
{{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{nickname}}({{#allParams}}{{^vendorExtensions.x-isBody}}@Param("{{paramName}}") {{/vendorExtensions.x-isBody}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
{{/operations}}
|
{{/operations}}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# swagger-petstore-feign
|
# swagger-java-client
|
||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ After the client libarary is installed/deployed, you can use it in your Maven pr
|
|||||||
```xml
|
```xml
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-petstore-feign</artifactId>
|
<artifactId>swagger-java-client</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>io.swagger</groupId>
|
<groupId>io.swagger</groupId>
|
||||||
<artifactId>swagger-petstore-feign</artifactId>
|
<artifactId>swagger-java-client</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>swagger-petstore-feign</name>
|
<name>swagger-java-client</name>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git@github.com:swagger-api/swagger-mustache.git</connection>
|
<connection>scm:git:git@github.com:swagger-api/swagger-mustache.git</connection>
|
||||||
|
@ -1 +1 @@
|
|||||||
rootProject.name = "swagger-petstore-feign"
|
rootProject.name = "swagger-java-client"
|
@ -8,7 +8,7 @@ import feign.jackson.JacksonDecoder;
|
|||||||
import feign.jackson.JacksonEncoder;
|
import feign.jackson.JacksonEncoder;
|
||||||
import feign.slf4j.Slf4jLogger;
|
import feign.slf4j.Slf4jLogger;
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T01:11:21.159-05:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T22:27:06.680-05:00")
|
||||||
public class ApiClient {
|
public class ApiClient {
|
||||||
public interface Api {}
|
public interface Api {}
|
||||||
|
|
||||||
|
@ -4,21 +4,31 @@ import java.io.*;
|
|||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
|
import feign.codec.EncodeException;
|
||||||
import feign.codec.Encoder;
|
import feign.codec.Encoder;
|
||||||
import feign.RequestTemplate;
|
import feign.RequestTemplate;
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T01:11:21.159-05:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T22:27:06.680-05:00")
|
||||||
public class FormAwareEncoder implements Encoder {
|
public class FormAwareEncoder implements Encoder {
|
||||||
|
public static final String UTF_8 = "utf-8";
|
||||||
private static final String LINE_FEED = "\r\n";
|
private static final String LINE_FEED = "\r\n";
|
||||||
|
private static final String TWO_DASH = "--";
|
||||||
private static final String BOUNDARY = "----------------314159265358979323846";
|
private static final String BOUNDARY = "----------------314159265358979323846";
|
||||||
|
|
||||||
|
private byte[] lineFeedBytes;
|
||||||
|
private byte[] boundaryBytes;
|
||||||
|
private byte[] twoDashBytes;
|
||||||
|
private byte[] atBytes;
|
||||||
|
private byte[] eqBytes;
|
||||||
|
|
||||||
private final Encoder delegate;
|
private final Encoder delegate;
|
||||||
private DateFormat dateFormat;
|
private final DateFormat dateFormat;
|
||||||
|
|
||||||
public FormAwareEncoder(Encoder delegate) {
|
public FormAwareEncoder(Encoder delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
@ -28,93 +38,121 @@ public class FormAwareEncoder implements Encoder {
|
|||||||
|
|
||||||
// Use UTC as the default time zone.
|
// Use UTC as the default time zone.
|
||||||
this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
this.dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
|
try {
|
||||||
|
this.lineFeedBytes = LINE_FEED.getBytes(UTF_8);
|
||||||
|
this.boundaryBytes = BOUNDARY.getBytes(UTF_8);
|
||||||
|
this.twoDashBytes = TWO_DASH.getBytes(UTF_8);
|
||||||
|
this.atBytes = "&".getBytes(UTF_8);
|
||||||
|
this.eqBytes = "=".getBytes(UTF_8);
|
||||||
|
} catch (UnsupportedEncodingException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void encode(Object object, Type bodyType, RequestTemplate template) {
|
public void encode(Object object, Type bodyType, RequestTemplate template) throws EncodeException {
|
||||||
if (object instanceof Map) {
|
if (object instanceof Map) {
|
||||||
StringBuilder formParamBuilder = new StringBuilder();
|
try {
|
||||||
Map<String, Object> formParams = (Map<String, Object>) object;
|
encodeFormParams(template, (Map<String, Object>) object);
|
||||||
boolean isMultiPart = isMultiPart(formParams);
|
} catch (IOException e) {
|
||||||
for (Map.Entry<String, Object> param : formParams.entrySet()) {
|
throw new EncodeException("Failed to create request", e);
|
||||||
String keyStr = param.getKey();
|
|
||||||
if (param.getValue() instanceof File) {
|
|
||||||
addFilePart(formParamBuilder, keyStr, (File) param.getValue());
|
|
||||||
} else {
|
|
||||||
String valueStr = parameterToString(param.getValue());
|
|
||||||
if (isMultiPart) {
|
|
||||||
addMultiPartFormField(formParamBuilder, keyStr, valueStr);
|
|
||||||
} else {
|
|
||||||
addEncodedFormField(formParamBuilder, keyStr, valueStr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMultiPart) {
|
|
||||||
formParamBuilder.append(LINE_FEED);
|
|
||||||
formParamBuilder.append("--").append(BOUNDARY).append("--").append(LINE_FEED);
|
|
||||||
}
|
|
||||||
|
|
||||||
String contentType = isMultiPart ? "multipart/form-data; boundary=" + BOUNDARY : "application/x-www-form-urlencoded";
|
|
||||||
template.header("Content-type");
|
|
||||||
template.header("Content-type", contentType);
|
|
||||||
template.header("MIME-Version", "1.0");
|
|
||||||
template.body(formParamBuilder.toString());
|
|
||||||
} else {
|
} else {
|
||||||
delegate.encode(object, bodyType, template);
|
delegate.encode(object, bodyType, template);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void encodeFormParams(RequestTemplate template, Map<String, Object> formParams) throws IOException {
|
||||||
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
|
|
||||||
|
boolean isMultiPart = isMultiPart(formParams);
|
||||||
|
boolean isFirstField = true;
|
||||||
|
for (Map.Entry<String, Object> param : formParams.entrySet()) {
|
||||||
|
String keyStr = param.getKey();
|
||||||
|
if (param.getValue() instanceof File) {
|
||||||
|
addFilePart(baos, keyStr, (File) param.getValue());
|
||||||
|
} else {
|
||||||
|
String valueStr = parameterToString(param.getValue());
|
||||||
|
if (isMultiPart) {
|
||||||
|
addMultiPartFormField(baos, keyStr, valueStr);
|
||||||
|
} else {
|
||||||
|
addEncodedFormField(baos, keyStr, valueStr, isFirstField);
|
||||||
|
isFirstField = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isMultiPart) {
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
|
baos.write(twoDashBytes);
|
||||||
|
baos.write(boundaryBytes);
|
||||||
|
baos.write(twoDashBytes);
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
String contentType = isMultiPart ? "multipart/form-data; boundary=" + BOUNDARY : "application/x-www-form-urlencoded";
|
||||||
|
template.header("Content-type");
|
||||||
|
template.header("Content-type", contentType);
|
||||||
|
template.header("MIME-Version", "1.0");
|
||||||
|
template.body(baos.toByteArray(), Charset.forName(UTF_8));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Currently only supports text files
|
* Currently only supports text files
|
||||||
*/
|
*/
|
||||||
private void addFilePart(StringBuilder formParamBuilder, String fieldName, File uploadFile) {
|
private void addFilePart(ByteArrayOutputStream baos, String fieldName, File uploadFile) throws IOException {
|
||||||
try {
|
String fileName = uploadFile.getName();
|
||||||
String fileName = uploadFile.getName();
|
baos.write(twoDashBytes);
|
||||||
formParamBuilder.append("--").append(BOUNDARY).append(LINE_FEED);
|
baos.write(boundaryBytes);
|
||||||
formParamBuilder.append(
|
baos.write(lineFeedBytes);
|
||||||
"Content-Disposition: form-data; name=\"" + fieldName
|
|
||||||
+ "\"; filename=\"" + fileName + "\"")
|
|
||||||
.append(LINE_FEED);
|
|
||||||
formParamBuilder.append(
|
|
||||||
"Content-Type: "
|
|
||||||
+ URLConnection.guessContentTypeFromName(fileName))
|
|
||||||
.append(LINE_FEED);
|
|
||||||
formParamBuilder.append(LINE_FEED);
|
|
||||||
|
|
||||||
BufferedReader reader = new BufferedReader(new FileReader(uploadFile));
|
String contentDisposition = "Content-Disposition: form-data; name=\"" + fieldName
|
||||||
String line = "";
|
+ "\"; filename=\"" + fileName + "\"";
|
||||||
while ((line = reader.readLine()) != null) {
|
baos.write(contentDisposition.getBytes(UTF_8));
|
||||||
formParamBuilder.append(line).append(LINE_FEED);
|
baos.write(lineFeedBytes);
|
||||||
}
|
String contentType = "Content-Type: " + URLConnection.guessContentTypeFromName(fileName);
|
||||||
|
baos.write(contentType.getBytes(UTF_8));
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
|
|
||||||
formParamBuilder.append(LINE_FEED);
|
BufferedReader reader = new BufferedReader(new FileReader(uploadFile));
|
||||||
} catch (IOException e) {
|
InputStream input = new FileInputStream(uploadFile);
|
||||||
e.printStackTrace();
|
byte[] bytes = new byte[4096];
|
||||||
|
int len = bytes.length;
|
||||||
|
while ((len = input.read(bytes)) != -1) {
|
||||||
|
baos.write(bytes, 0, len);
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addEncodedFormField(StringBuilder formParamBuilder, String name, String value) {
|
private void addEncodedFormField(ByteArrayOutputStream baos, String name, String value, boolean isFirstField) throws IOException {
|
||||||
if (formParamBuilder.length() > 0) {
|
if (!isFirstField) {
|
||||||
formParamBuilder.append("&");
|
baos.write(atBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
String encodedName = URLEncoder.encode(name, UTF_8);
|
||||||
formParamBuilder.append(URLEncoder.encode(name, "utf8"))
|
String encodedValue = URLEncoder.encode(value, UTF_8);
|
||||||
.append("=")
|
baos.write(encodedName.getBytes(UTF_8));
|
||||||
.append(URLEncoder.encode(value, "utf8"));
|
baos.write("=".getBytes(UTF_8));
|
||||||
} catch (UnsupportedEncodingException e) {
|
baos.write(encodedValue.getBytes(UTF_8));
|
||||||
// move on to next
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMultiPartFormField(StringBuilder formParamBuilder, String name, String value) {
|
private void addMultiPartFormField(ByteArrayOutputStream baos, String name, String value) throws IOException {
|
||||||
formParamBuilder.append("--").append(BOUNDARY).append(LINE_FEED);
|
baos.write(twoDashBytes);
|
||||||
formParamBuilder.append("Content-Disposition: form-data; name=\"" + name + "\"")
|
baos.write(boundaryBytes);
|
||||||
.append(LINE_FEED);
|
baos.write(lineFeedBytes);
|
||||||
formParamBuilder.append("Content-Type: text/plain; charset=utf-8").append(
|
|
||||||
LINE_FEED);
|
String contentDisposition = "Content-Disposition: form-data; name=\"" + name + "\"";
|
||||||
formParamBuilder.append(LINE_FEED);
|
String contentType = "Content-Type: text/plain; charset=utf-8";
|
||||||
formParamBuilder.append(value).append(LINE_FEED);
|
|
||||||
|
baos.write(contentDisposition.getBytes(UTF_8));
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
|
baos.write(contentType.getBytes(UTF_8));
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
|
baos.write(value.getBytes(UTF_8));
|
||||||
|
baos.write(lineFeedBytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMultiPart(Map<String, Object> formParams) {
|
private boolean isMultiPart(Map<String, Object> formParams) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package io.swagger.client;
|
package io.swagger.client;
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-01T16:10:23.565+08:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T22:27:06.680-05:00")
|
||||||
public class StringUtil {
|
public class StringUtil {
|
||||||
/**
|
/**
|
||||||
* Check if the given array contains the given value (with case-insensitive comparison).
|
* Check if the given array contains the given value (with case-insensitive comparison).
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
package io.swagger.client.api;
|
package io.swagger.client.api;
|
||||||
|
|
||||||
import io.swagger.client.ApiException;
|
|
||||||
import io.swagger.client.ApiClient;
|
import io.swagger.client.ApiClient;
|
||||||
import io.swagger.client.Configuration;
|
|
||||||
import io.swagger.client.Pair;
|
|
||||||
import io.swagger.client.TypeRef;
|
|
||||||
|
|
||||||
import io.swagger.client.model.Pet;
|
import io.swagger.client.model.Pet;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import io.swagger.client.model.ApiResponse;
|
import io.swagger.client.model.ApiResponse;
|
||||||
|
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import feign.*;
|
import feign.*;
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T01:11:21.159-05:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T22:27:06.680-05:00")
|
||||||
public interface PetApi extends io.swagger.client.ApiClient.Api {
|
public interface PetApi extends ApiClient.Api {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,7 +26,7 @@ public interface PetApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
void updatePet(Pet body) throws ApiException;
|
void updatePet(Pet body);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a new pet to the store
|
* Add a new pet to the store
|
||||||
@ -41,7 +39,7 @@ public interface PetApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
void addPet(Pet body) throws ApiException;
|
void addPet(Pet body);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds Pets by status
|
* Finds Pets by status
|
||||||
@ -54,7 +52,7 @@ public interface PetApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
List<Pet> findPetsByStatus(@Param("status") List<String> status) throws ApiException;
|
List<Pet> findPetsByStatus(@Param("status") List<String> status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Finds Pets by tags
|
* Finds Pets by tags
|
||||||
@ -67,7 +65,7 @@ public interface PetApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
List<Pet> findPetsByTags(@Param("tags") List<String> tags) throws ApiException;
|
List<Pet> findPetsByTags(@Param("tags") List<String> tags);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find pet by ID
|
* Find pet by ID
|
||||||
@ -80,7 +78,7 @@ public interface PetApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
Pet getPetById(@Param("petId") Long petId) throws ApiException;
|
Pet getPetById(@Param("petId") Long petId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates a pet in the store with form data
|
* Updates a pet in the store with form data
|
||||||
@ -95,7 +93,7 @@ public interface PetApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/x-www-form-urlencoded",
|
"Content-type: application/x-www-form-urlencoded",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
void updatePetWithForm(@Param("petId") Long petId, @Param("name") String name, @Param("status") String status) throws ApiException;
|
void updatePetWithForm(@Param("petId") Long petId, @Param("name") String name, @Param("status") String status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes a pet
|
* Deletes a pet
|
||||||
@ -110,7 +108,7 @@ public interface PetApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
"apiKey: {apiKey}"
|
"apiKey: {apiKey}"
|
||||||
})
|
})
|
||||||
void deletePet(@Param("petId") Long petId, @Param("apiKey") String apiKey) throws ApiException;
|
void deletePet(@Param("petId") Long petId, @Param("apiKey") String apiKey);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* uploads an image
|
* uploads an image
|
||||||
@ -125,7 +123,7 @@ public interface PetApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: multipart/form-data",
|
"Content-type: multipart/form-data",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
ApiResponse uploadFile(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file) throws ApiException;
|
ApiResponse uploadFile(@Param("petId") Long petId, @Param("additionalMetadata") String additionalMetadata, @Param("file") File file);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
package io.swagger.client.api;
|
package io.swagger.client.api;
|
||||||
|
|
||||||
import io.swagger.client.ApiException;
|
|
||||||
import io.swagger.client.ApiClient;
|
import io.swagger.client.ApiClient;
|
||||||
import io.swagger.client.Configuration;
|
|
||||||
import io.swagger.client.Pair;
|
|
||||||
import io.swagger.client.TypeRef;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import io.swagger.client.model.Order;
|
import io.swagger.client.model.Order;
|
||||||
@ -14,8 +10,8 @@ import java.util.*;
|
|||||||
|
|
||||||
import feign.*;
|
import feign.*;
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T01:11:21.159-05:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T22:27:06.680-05:00")
|
||||||
public interface StoreApi extends io.swagger.client.ApiClient.Api {
|
public interface StoreApi extends ApiClient.Api {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -28,7 +24,7 @@ public interface StoreApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
Map<String, Integer> getInventory() throws ApiException;
|
Map<String, Integer> getInventory();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Place an order for a pet
|
* Place an order for a pet
|
||||||
@ -41,7 +37,7 @@ public interface StoreApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
Order placeOrder(Order body) throws ApiException;
|
Order placeOrder(Order body);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find purchase order by ID
|
* Find purchase order by ID
|
||||||
@ -54,7 +50,7 @@ public interface StoreApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
Order getOrderById(@Param("orderId") Long orderId) throws ApiException;
|
Order getOrderById(@Param("orderId") Long orderId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete purchase order by ID
|
* Delete purchase order by ID
|
||||||
@ -67,7 +63,7 @@ public interface StoreApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
void deleteOrder(@Param("orderId") String orderId) throws ApiException;
|
void deleteOrder(@Param("orderId") String orderId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,6 @@
|
|||||||
package io.swagger.client.api;
|
package io.swagger.client.api;
|
||||||
|
|
||||||
import io.swagger.client.ApiException;
|
|
||||||
import io.swagger.client.ApiClient;
|
import io.swagger.client.ApiClient;
|
||||||
import io.swagger.client.Configuration;
|
|
||||||
import io.swagger.client.Pair;
|
|
||||||
import io.swagger.client.TypeRef;
|
|
||||||
|
|
||||||
import io.swagger.client.model.User;
|
import io.swagger.client.model.User;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@ -14,8 +10,8 @@ import java.util.*;
|
|||||||
|
|
||||||
import feign.*;
|
import feign.*;
|
||||||
|
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T01:11:21.159-05:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T22:27:06.680-05:00")
|
||||||
public interface UserApi extends io.swagger.client.ApiClient.Api {
|
public interface UserApi extends ApiClient.Api {
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,7 +25,7 @@ public interface UserApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
void createUser(User body) throws ApiException;
|
void createUser(User body);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
@ -42,7 +38,7 @@ public interface UserApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
void createUsersWithArrayInput(List<User> body) throws ApiException;
|
void createUsersWithArrayInput(List<User> body);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates list of users with given input array
|
* Creates list of users with given input array
|
||||||
@ -55,7 +51,7 @@ public interface UserApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
void createUsersWithListInput(List<User> body) throws ApiException;
|
void createUsersWithListInput(List<User> body);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs user into the system
|
* Logs user into the system
|
||||||
@ -69,7 +65,7 @@ public interface UserApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
String loginUser(@Param("username") String username, @Param("password") String password) throws ApiException;
|
String loginUser(@Param("username") String username, @Param("password") String password);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logs out current logged in user session
|
* Logs out current logged in user session
|
||||||
@ -81,7 +77,7 @@ public interface UserApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
void logoutUser() throws ApiException;
|
void logoutUser();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get user by user name
|
* Get user by user name
|
||||||
@ -94,7 +90,7 @@ public interface UserApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
User getUserByName(@Param("username") String username) throws ApiException;
|
User getUserByName(@Param("username") String username);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updated user
|
* Updated user
|
||||||
@ -108,7 +104,7 @@ public interface UserApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
void updateUser(@Param("username") String username, User body) throws ApiException;
|
void updateUser(@Param("username") String username, User body);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete user
|
* Delete user
|
||||||
@ -121,7 +117,7 @@ public interface UserApi extends io.swagger.client.ApiClient.Api {
|
|||||||
"Content-type: application/json",
|
"Content-type: application/json",
|
||||||
"Accepts: application/json",
|
"Accepts: application/json",
|
||||||
})
|
})
|
||||||
void deleteUser(@Param("username") String username) throws ApiException;
|
void deleteUser(@Param("username") String username);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T01:11:21.159-05:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T22:27:06.680-05:00")
|
||||||
public class ApiResponse {
|
public class ApiResponse {
|
||||||
|
|
||||||
private Integer code = null;
|
private Integer code = null;
|
||||||
|
@ -12,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T01:11:21.159-05:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T22:27:06.680-05:00")
|
||||||
public class Category {
|
public class Category {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -13,7 +13,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T01:11:21.159-05:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T22:27:06.680-05:00")
|
||||||
public class Order {
|
public class Order {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -15,7 +15,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T01:11:21.159-05:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T22:27:06.680-05:00")
|
||||||
public class Pet {
|
public class Pet {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -12,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T01:11:21.159-05:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T22:27:06.680-05:00")
|
||||||
public class Tag {
|
public class Tag {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -12,7 +12,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
|
|||||||
|
|
||||||
|
|
||||||
@ApiModel(description = "")
|
@ApiModel(description = "")
|
||||||
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T01:11:21.159-05:00")
|
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T22:27:06.680-05:00")
|
||||||
public class User {
|
public class User {
|
||||||
|
|
||||||
private Long id = null;
|
private Long id = null;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package io.swagger.petstore.test;
|
package io.swagger.petstore.test;
|
||||||
|
|
||||||
import io.swagger.client.ApiException;
|
|
||||||
|
|
||||||
import io.swagger.client.*;
|
import io.swagger.client.*;
|
||||||
import io.swagger.client.api.*;
|
import io.swagger.client.api.*;
|
||||||
import io.swagger.client.model.*;
|
import io.swagger.client.model.*;
|
||||||
@ -48,12 +46,8 @@ public class StoreApiTest {
|
|||||||
|
|
||||||
api.deleteOrder(String.valueOf(order.getId()));
|
api.deleteOrder(String.valueOf(order.getId()));
|
||||||
|
|
||||||
try {
|
api.getOrderById(order.getId());
|
||||||
api.getOrderById(order.getId());
|
// fail("expected an error");
|
||||||
// fail("expected an error");
|
|
||||||
} catch (ApiException e) {
|
|
||||||
// ok
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Order createOrder() {
|
private Order createOrder() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user