forked from loafle/openapi-generator-original
Merge branch 'develop_2.0' into develop_2.0_objc_jsonmodel
Conflicts: pom.xml
This commit is contained in:
commit
19c05eefab
@ -1,3 +1,4 @@
|
|||||||
|
sudo: false
|
||||||
language: java
|
language: java
|
||||||
script: mvn verify
|
script: mvn verify
|
||||||
jdk:
|
jdk:
|
||||||
|
@ -11,6 +11,7 @@ import java.util.*;
|
|||||||
{{/imports}}
|
{{/imports}}
|
||||||
|
|
||||||
import com.sun.jersey.multipart.FormDataMultiPart;
|
import com.sun.jersey.multipart.FormDataMultiPart;
|
||||||
|
import com.sun.jersey.multipart.file.FileDataBodyPart;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
@ -77,7 +78,8 @@ public class {{classname}} {
|
|||||||
mp.field("{{baseName}}", ApiInvoker.parameterToString({{paramName}}), MediaType.MULTIPART_FORM_DATA_TYPE);
|
mp.field("{{baseName}}", ApiInvoker.parameterToString({{paramName}}), MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||||
{{/notFile}}{{#isFile}}
|
{{/notFile}}{{#isFile}}
|
||||||
hasFields = true;
|
hasFields = true;
|
||||||
mp.field("{{baseName}}", {{paramName}}, MediaType.MULTIPART_FORM_DATA_TYPE);
|
mp.field("{{baseName}}", file.getName());
|
||||||
|
mp.bodyPart(new FileDataBodyPart("{{baseName}}", {{paramName}}, MediaType.MULTIPART_FORM_DATA_TYPE));
|
||||||
{{/isFile}}{{/formParams}}
|
{{/isFile}}{{/formParams}}
|
||||||
if(hasFields)
|
if(hasFields)
|
||||||
postBody = mp;
|
postBody = mp;
|
||||||
@ -96,12 +98,7 @@ public class {{classname}} {
|
|||||||
return {{#returnType}}null{{/returnType}};
|
return {{#returnType}}null{{/returnType}};
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return {{#returnType}} null{{/returnType}};
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
|
@ -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.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -83,11 +84,19 @@ public class ApiInvoker {
|
|||||||
return "";
|
return "";
|
||||||
} else if (param instanceof Date) {
|
} else if (param instanceof Date) {
|
||||||
return formatDateTime((Date) param);
|
return formatDateTime((Date) param);
|
||||||
|
} else if (param instanceof Collection) {
|
||||||
|
StringBuilder b = new StringBuilder();
|
||||||
|
for(Object o : (Collection)param) {
|
||||||
|
if(b.length() > 0) {
|
||||||
|
b.append(",");
|
||||||
|
}
|
||||||
|
b.append(String.valueOf(o));
|
||||||
|
}
|
||||||
|
return b.toString();
|
||||||
} else {
|
} else {
|
||||||
return String.valueOf(param);
|
return String.valueOf(param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableDebug() {
|
public void enableDebug() {
|
||||||
isDebug = true;
|
isDebug = true;
|
||||||
}
|
}
|
||||||
@ -217,7 +226,7 @@ public class ApiInvoker {
|
|||||||
}
|
}
|
||||||
else if ("DELETE".equals(method)) {
|
else if ("DELETE".equals(method)) {
|
||||||
if(body == null)
|
if(body == null)
|
||||||
response = builder.delete(ClientResponse.class, serialize(body));
|
response = builder.delete(ClientResponse.class);
|
||||||
else
|
else
|
||||||
response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
|
response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
|
||||||
}
|
}
|
||||||
@ -228,12 +237,26 @@ public class ApiInvoker {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) {
|
else if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) {
|
||||||
return (String) response.getEntity(String.class);
|
if(response.hasEntity()) {
|
||||||
|
return (String) response.getEntity(String.class);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
String message = "error";
|
||||||
|
if(response.hasEntity()) {
|
||||||
|
try{
|
||||||
|
message = String.valueOf(response.getEntity(String.class));
|
||||||
|
}
|
||||||
|
catch (RuntimeException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
throw new ApiException(
|
throw new ApiException(
|
||||||
response.getClientResponseStatus().getStatusCode(),
|
response.getClientResponseStatus().getStatusCode(),
|
||||||
response.getEntity(String.class));
|
message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,11 +157,10 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<swagger-annotations-version>1.5.0-M1</swagger-annotations-version>
|
<swagger-annotations-version>1.5.3-M1</swagger-annotations-version>
|
||||||
<jersey-version>1.7</jersey-version>
|
<jersey-version>1.18</jersey-version>
|
||||||
<jackson-version>2.1.4</jackson-version>
|
<jackson-version>2.4.2</jackson-version>
|
||||||
<jodatime-version>2.3</jodatime-version>
|
<jodatime-version>2.3</jodatime-version>
|
||||||
<junit-version>4.8.1</junit-version>
|
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<junit-version>4.8.1</junit-version>
|
<junit-version>4.8.1</junit-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -104,7 +104,7 @@
|
|||||||
<id>start-jetty</id>
|
<id>start-jetty</id>
|
||||||
<phase>pre-integration-test</phase>
|
<phase>pre-integration-test</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>run</goal>
|
<goal>start</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<scanIntervalSeconds>0</scanIntervalSeconds>
|
<scanIntervalSeconds>0</scanIntervalSeconds>
|
||||||
@ -226,7 +226,7 @@
|
|||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<servlet-api-version>2.5</servlet-api-version>
|
<servlet-api-version>2.5</servlet-api-version>
|
||||||
<zip-version>1.3.2</zip-version>
|
<zip-version>1.3.2</zip-version>
|
||||||
<jetty-version>9.0.7.v20131107</jetty-version>
|
<jetty-version>9.2.9.v20150224</jetty-version>
|
||||||
<jersey2-version>2.4.1</jersey2-version>
|
<jersey2-version>2.4.1</jersey2-version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
3
pom.xml
3
pom.xml
@ -288,6 +288,7 @@
|
|||||||
</activation>
|
</activation>
|
||||||
<modules>
|
<modules>
|
||||||
<module>samples/client/petstore/objc</module>
|
<module>samples/client/petstore/objc</module>
|
||||||
|
<module>samples/client/petstore/java</module>
|
||||||
</modules>
|
</modules>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
@ -363,7 +364,7 @@
|
|||||||
<swagger-parser-version>1.0.3</swagger-parser-version>
|
<swagger-parser-version>1.0.3</swagger-parser-version>
|
||||||
<scala-version>2.11.1</scala-version>
|
<scala-version>2.11.1</scala-version>
|
||||||
<felix-version>2.3.4</felix-version>
|
<felix-version>2.3.4</felix-version>
|
||||||
<swagger-core-version>1.5.4-M1-SNAPSHOT</swagger-core-version>
|
<swagger-core-version>1.5.3-M1</swagger-core-version>
|
||||||
<scala-test-version>2.1.4</scala-test-version>
|
<scala-test-version>2.1.4</scala-test-version>
|
||||||
<commons-io-version>2.3</commons-io-version>
|
<commons-io-version>2.3</commons-io-version>
|
||||||
<commons-cli-version>1.2</commons-cli-version>
|
<commons-cli-version>1.2</commons-cli-version>
|
||||||
|
@ -157,11 +157,10 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<swagger-annotations-version>1.5.0-M1</swagger-annotations-version>
|
<swagger-annotations-version>1.5.3-M1</swagger-annotations-version>
|
||||||
<jersey-version>1.7</jersey-version>
|
<jersey-version>1.18</jersey-version>
|
||||||
<jackson-version>2.1.4</jackson-version>
|
<jackson-version>2.4.2</jackson-version>
|
||||||
<jodatime-version>2.3</jodatime-version>
|
<jodatime-version>2.3</jodatime-version>
|
||||||
<junit-version>4.8.1</junit-version>
|
|
||||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||||
<junit-version>4.8.1</junit-version>
|
<junit-version>4.8.1</junit-version>
|
||||||
</properties>
|
</properties>
|
||||||
|
@ -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.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -83,11 +84,19 @@ public class ApiInvoker {
|
|||||||
return "";
|
return "";
|
||||||
} else if (param instanceof Date) {
|
} else if (param instanceof Date) {
|
||||||
return formatDateTime((Date) param);
|
return formatDateTime((Date) param);
|
||||||
|
} else if (param instanceof Collection) {
|
||||||
|
StringBuilder b = new StringBuilder();
|
||||||
|
for(Object o : (Collection)param) {
|
||||||
|
if(b.length() > 0) {
|
||||||
|
b.append(",");
|
||||||
|
}
|
||||||
|
b.append(String.valueOf(o));
|
||||||
|
}
|
||||||
|
return b.toString();
|
||||||
} else {
|
} else {
|
||||||
return String.valueOf(param);
|
return String.valueOf(param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enableDebug() {
|
public void enableDebug() {
|
||||||
isDebug = true;
|
isDebug = true;
|
||||||
}
|
}
|
||||||
@ -217,7 +226,7 @@ public class ApiInvoker {
|
|||||||
}
|
}
|
||||||
else if ("DELETE".equals(method)) {
|
else if ("DELETE".equals(method)) {
|
||||||
if(body == null)
|
if(body == null)
|
||||||
response = builder.delete(ClientResponse.class, serialize(body));
|
response = builder.delete(ClientResponse.class);
|
||||||
else
|
else
|
||||||
response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
|
response = builder.type(contentType).delete(ClientResponse.class, serialize(body));
|
||||||
}
|
}
|
||||||
@ -228,12 +237,26 @@ public class ApiInvoker {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) {
|
else if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) {
|
||||||
return (String) response.getEntity(String.class);
|
if(response.hasEntity()) {
|
||||||
|
return (String) response.getEntity(String.class);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
String message = "error";
|
||||||
|
if(response.hasEntity()) {
|
||||||
|
try{
|
||||||
|
message = String.valueOf(response.getEntity(String.class));
|
||||||
|
}
|
||||||
|
catch (RuntimeException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
throw new ApiException(
|
throw new ApiException(
|
||||||
response.getClientResponseStatus().getStatusCode(),
|
response.getClientResponseStatus().getStatusCode(),
|
||||||
response.getEntity(String.class));
|
message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import io.swagger.client.model.Pet;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import com.sun.jersey.multipart.FormDataMultiPart;
|
import com.sun.jersey.multipart.FormDataMultiPart;
|
||||||
|
import com.sun.jersey.multipart.file.FileDataBodyPart;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
@ -76,12 +77,7 @@ public class PetApi {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,12 +122,7 @@ public class PetApi {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,12 +169,7 @@ public class PetApi {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,12 +216,7 @@ public class PetApi {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,12 +262,7 @@ public class PetApi {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,12 +316,7 @@ public class PetApi {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,12 +363,7 @@ public class PetApi {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -431,7 +397,8 @@ public class PetApi {
|
|||||||
mp.field("additionalMetadata", ApiInvoker.parameterToString(additionalMetadata), MediaType.MULTIPART_FORM_DATA_TYPE);
|
mp.field("additionalMetadata", ApiInvoker.parameterToString(additionalMetadata), MediaType.MULTIPART_FORM_DATA_TYPE);
|
||||||
|
|
||||||
hasFields = true;
|
hasFields = true;
|
||||||
mp.field("file", file, MediaType.MULTIPART_FORM_DATA_TYPE);
|
mp.field("file", file.getName());
|
||||||
|
mp.bodyPart(new FileDataBodyPart("file", file, MediaType.MULTIPART_FORM_DATA_TYPE));
|
||||||
|
|
||||||
if(hasFields)
|
if(hasFields)
|
||||||
postBody = mp;
|
postBody = mp;
|
||||||
@ -451,12 +418,7 @@ public class PetApi {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import java.util.Map;
|
|||||||
import io.swagger.client.model.Order;
|
import io.swagger.client.model.Order;
|
||||||
|
|
||||||
import com.sun.jersey.multipart.FormDataMultiPart;
|
import com.sun.jersey.multipart.FormDataMultiPart;
|
||||||
|
import com.sun.jersey.multipart.file.FileDataBodyPart;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
@ -76,12 +77,7 @@ public class StoreApi {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,12 +122,7 @@ public class StoreApi {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,12 +168,7 @@ public class StoreApi {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -228,12 +214,7 @@ public class StoreApi {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import io.swagger.client.model.User;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import com.sun.jersey.multipart.FormDataMultiPart;
|
import com.sun.jersey.multipart.FormDataMultiPart;
|
||||||
|
import com.sun.jersey.multipart.file.FileDataBodyPart;
|
||||||
|
|
||||||
import javax.ws.rs.core.MediaType;
|
import javax.ws.rs.core.MediaType;
|
||||||
|
|
||||||
@ -76,12 +77,7 @@ public class UserApi {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,12 +122,7 @@ public class UserApi {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,12 +167,7 @@ public class UserApi {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,12 +216,7 @@ public class UserApi {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -280,12 +261,7 @@ public class UserApi {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,12 +307,7 @@ public class UserApi {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -382,12 +353,7 @@ public class UserApi {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,12 +399,7 @@ public class UserApi {
|
|||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
} catch (ApiException ex) {
|
} catch (ApiException ex) {
|
||||||
if(ex.getCode() == 404) {
|
throw ex;
|
||||||
return ;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
package io.swagger.client.model;
|
||||||
|
|
||||||
|
|
||||||
|
import com.wordnik.swagger.annotations.*;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModel(description = "")
|
||||||
|
public class ApiResponse {
|
||||||
|
|
||||||
|
private Integer code = null;
|
||||||
|
private String type = null;
|
||||||
|
private String message = null;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(required = false, value = "")
|
||||||
|
@JsonProperty("code")
|
||||||
|
public Integer getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
public void setCode(Integer code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(required = false, value = "")
|
||||||
|
@JsonProperty("type")
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
**/
|
||||||
|
@ApiModelProperty(required = false, value = "")
|
||||||
|
@JsonProperty("message")
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append("class ApiResponse {\n");
|
||||||
|
|
||||||
|
sb.append(" code: ").append(code).append("\n");
|
||||||
|
sb.append(" type: ").append(type).append("\n");
|
||||||
|
sb.append(" message: ").append(message).append("\n");
|
||||||
|
sb.append("}\n");
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,155 @@
|
|||||||
|
package io.swagger.petstore.test;
|
||||||
|
|
||||||
|
import io.swagger.client.ApiException;
|
||||||
|
import io.swagger.client.api.*;
|
||||||
|
import io.swagger.client.model.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.*;
|
||||||
|
|
||||||
|
public class PetApiTest {
|
||||||
|
PetApi api = null;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
api = new PetApi();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateAndGetPet() throws Exception {
|
||||||
|
Pet pet = createRandomPet();
|
||||||
|
api.addPet(pet);
|
||||||
|
|
||||||
|
Pet fetched = api.getPetById(pet.getId());
|
||||||
|
assertNotNull(fetched);
|
||||||
|
assertEquals(pet.getId(), fetched.getId());
|
||||||
|
assertNotNull(fetched.getCategory());
|
||||||
|
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdatePet() throws Exception {
|
||||||
|
Pet pet = createRandomPet();
|
||||||
|
pet.setName("programmer");
|
||||||
|
|
||||||
|
api.updatePet(pet);
|
||||||
|
|
||||||
|
Pet fetched = api.getPetById(pet.getId());
|
||||||
|
assertNotNull(fetched);
|
||||||
|
assertEquals(pet.getId(), fetched.getId());
|
||||||
|
assertNotNull(fetched.getCategory());
|
||||||
|
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFindPetsByStatus() throws Exception {
|
||||||
|
Pet pet = createRandomPet();
|
||||||
|
pet.setName("programmer");
|
||||||
|
pet.setStatus(Pet.StatusEnum.available);
|
||||||
|
|
||||||
|
api.updatePet(pet);
|
||||||
|
|
||||||
|
List<Pet> pets = api.findPetsByStatus(Arrays.asList(new String[]{"available"}));
|
||||||
|
assertNotNull(pets);
|
||||||
|
|
||||||
|
boolean found = false;
|
||||||
|
for(Pet fetched : pets) {
|
||||||
|
if(fetched.getId().equals(pet.getId())) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertTrue(found);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testFindPetsByTags() throws Exception {
|
||||||
|
Pet pet = createRandomPet();
|
||||||
|
pet.setName("monster");
|
||||||
|
pet.setStatus(Pet.StatusEnum.available);
|
||||||
|
|
||||||
|
List<Tag> tags = new ArrayList<Tag>();
|
||||||
|
Tag tag1 = new Tag();
|
||||||
|
tag1.setName("friendly");
|
||||||
|
tags.add(tag1);
|
||||||
|
pet.setTags(tags);
|
||||||
|
|
||||||
|
api.updatePet(pet);
|
||||||
|
|
||||||
|
List<Pet> pets = api.findPetsByTags(Arrays.asList(new String[]{"friendly"}));
|
||||||
|
assertNotNull(pets);
|
||||||
|
|
||||||
|
boolean found = false;
|
||||||
|
for(Pet fetched : pets) {
|
||||||
|
if(fetched.getId().equals(pet.getId())) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertTrue(found);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpdatePetWithForm() throws Exception {
|
||||||
|
Pet pet = createRandomPet();
|
||||||
|
pet.setName("frank");
|
||||||
|
api.addPet(pet);
|
||||||
|
|
||||||
|
Pet fetched = api.getPetById(pet.getId());
|
||||||
|
|
||||||
|
api.updatePetWithForm(String.valueOf(fetched.getId()), "furt", null);
|
||||||
|
Pet updated = api.getPetById(fetched.getId());
|
||||||
|
|
||||||
|
assertEquals(updated.getName(), fetched.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeletePet() throws Exception {
|
||||||
|
Pet pet = createRandomPet();
|
||||||
|
api.addPet(pet);
|
||||||
|
|
||||||
|
Pet fetched = api.getPetById(pet.getId());
|
||||||
|
api.deletePet(null, fetched.getId());
|
||||||
|
|
||||||
|
try {
|
||||||
|
fetched = api.getPetById(fetched.getId());
|
||||||
|
fail("expected an error");
|
||||||
|
}
|
||||||
|
catch (ApiException e) {
|
||||||
|
assertEquals(404, e.getCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUploadFile() throws Exception {
|
||||||
|
Pet pet = createRandomPet();
|
||||||
|
api.addPet(pet);
|
||||||
|
|
||||||
|
File file = new File("hello.txt");
|
||||||
|
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
|
||||||
|
writer.write("Hello world!");
|
||||||
|
writer.close();
|
||||||
|
|
||||||
|
api.uploadFile(pet.getId(), "a test file", new File(file.getAbsolutePath()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Pet createRandomPet() {
|
||||||
|
Pet pet = new Pet();
|
||||||
|
pet.setId(System.currentTimeMillis());
|
||||||
|
pet.setName("gorilla");
|
||||||
|
|
||||||
|
Category category = new Category();
|
||||||
|
category.setName("really-happy");
|
||||||
|
|
||||||
|
pet.setCategory(category);
|
||||||
|
pet.setStatus(Pet.StatusEnum.available);
|
||||||
|
List<String> photos = Arrays.asList(new String[]{"http://foo.bar.com/1", "http://foo.bar.com/2"});
|
||||||
|
pet.setPhotoUrls(photos);
|
||||||
|
|
||||||
|
return pet;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package io.swagger.petstore.test;
|
||||||
|
|
||||||
|
import io.swagger.client.ApiException;
|
||||||
|
import io.swagger.client.api.*;
|
||||||
|
import io.swagger.client.model.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.*;
|
||||||
|
|
||||||
|
public class StoreApiTest {
|
||||||
|
StoreApi api = null;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
api = new StoreApi();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetInventory() throws Exception {
|
||||||
|
Map<String, Integer> inventory = api.getInventory();
|
||||||
|
assertTrue(inventory.keySet().size() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testPlaceOrder() throws Exception {
|
||||||
|
Order order = createOrder();
|
||||||
|
api.placeOrder(order);
|
||||||
|
|
||||||
|
Order fetched = api.getOrderById(String.valueOf(order.getId()));
|
||||||
|
assertEquals(order.getId(), fetched.getId());
|
||||||
|
assertEquals(order.getPetId(), fetched.getPetId());
|
||||||
|
assertEquals(order.getQuantity(), fetched.getQuantity());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testDeleteOrder() throws Exception {
|
||||||
|
Order order = createOrder();
|
||||||
|
api.placeOrder(order);
|
||||||
|
|
||||||
|
Order fetched = api.getOrderById(String.valueOf(order.getId()));
|
||||||
|
assertEquals(fetched.getId(), order.getId());
|
||||||
|
|
||||||
|
api.deleteOrder(String.valueOf(order.getId()));
|
||||||
|
|
||||||
|
try {
|
||||||
|
api.getOrderById(String.valueOf(order.getId()));
|
||||||
|
// fail("expected an error");
|
||||||
|
}
|
||||||
|
catch (ApiException e) {
|
||||||
|
// ok
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Order createOrder() {
|
||||||
|
Order order = new Order();
|
||||||
|
order.setId(new Long(System.currentTimeMillis()));
|
||||||
|
order.setPetId(new Long(200));
|
||||||
|
order.setQuantity(new Integer(13));
|
||||||
|
order.setShipDate(new java.util.Date());
|
||||||
|
order.setStatus(Order.StatusEnum.placed);
|
||||||
|
order.setComplete(true);
|
||||||
|
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
package io.swagger.petstore.test;
|
||||||
|
|
||||||
|
import io.swagger.client.ApiException;
|
||||||
|
import io.swagger.client.api.*;
|
||||||
|
import io.swagger.client.model.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
import java.io.*;
|
||||||
|
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import org.junit.*;
|
||||||
|
|
||||||
|
public class UserApiTest {
|
||||||
|
UserApi api = null;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void setup() {
|
||||||
|
api = new UserApi();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateUser() throws Exception {
|
||||||
|
User user = createUser();
|
||||||
|
|
||||||
|
api.createUser(user);
|
||||||
|
|
||||||
|
User fetched = api.getUserByName(user.getUsername());
|
||||||
|
assertEquals(user.getId(), fetched.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateUsersWithArray() throws Exception {
|
||||||
|
User user1 = createUser();
|
||||||
|
user1.setUsername("abc123");
|
||||||
|
User user2 = createUser();
|
||||||
|
user2.setUsername("123abc");
|
||||||
|
|
||||||
|
api.createUsersWithArrayInput(Arrays.asList(new User[]{user1, user2}));
|
||||||
|
|
||||||
|
User fetched = api.getUserByName(user1.getUsername());
|
||||||
|
assertEquals(user1.getId(), fetched.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateUsersWithList() throws Exception {
|
||||||
|
User user1 = createUser();
|
||||||
|
user1.setUsername("abc123");
|
||||||
|
User user2 = createUser();
|
||||||
|
user2.setUsername("123abc");
|
||||||
|
|
||||||
|
api.createUsersWithListInput(Arrays.asList(new User[]{user1, user2}));
|
||||||
|
|
||||||
|
User fetched = api.getUserByName(user1.getUsername());
|
||||||
|
assertEquals(user1.getId(), fetched.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testLoginUser() throws Exception {
|
||||||
|
User user = createUser();
|
||||||
|
api.createUser(user);
|
||||||
|
|
||||||
|
String token = api.loginUser(user.getUsername(), user.getPassword());
|
||||||
|
assertTrue(token.startsWith("logged in user session:"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void logoutUser() throws Exception {
|
||||||
|
api.logoutUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
private User createUser() {
|
||||||
|
User user = new User();
|
||||||
|
user.setId(System.currentTimeMillis());
|
||||||
|
user.setUsername("fred");
|
||||||
|
user.setFirstName("Fred");
|
||||||
|
user.setLastName("Meyer");
|
||||||
|
user.setEmail("fred@fredmeyer.com");
|
||||||
|
user.setPassword("xxXXxx");
|
||||||
|
user.setPhone("408-867-5309");
|
||||||
|
user.setUserStatus(123);
|
||||||
|
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
}
|
@ -6,8 +6,7 @@
|
|||||||
- (void)setUp {
|
- (void)setUp {
|
||||||
[super setUp];
|
[super setUp];
|
||||||
api = [[SWGPetApi alloc ]init];
|
api = [[SWGPetApi alloc ]init];
|
||||||
// [[SWGApiClient sharedClientFromPool]setLoggingEnabled:true];
|
[SWGPetApi setBasePath:@"http://localhost:8080/api"];
|
||||||
[SWGPetApi setBasePath:@"http://localhost:8002/api"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)tearDown {
|
- (void)tearDown {
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
<stopKey>alpha</stopKey>
|
<stopKey>alpha</stopKey>
|
||||||
<stopPort>9099</stopPort>
|
<stopPort>9099</stopPort>
|
||||||
<httpConnector>
|
<httpConnector>
|
||||||
<port>8002</port>
|
<port>8080</port>
|
||||||
</httpConnector>
|
</httpConnector>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
@ -41,8 +41,8 @@
|
|||||||
<goal>deploy-war</goal>
|
<goal>deploy-war</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>exec-maven-plugin</artifactId>
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
@ -1,197 +0,0 @@
|
|||||||
require "uri"
|
|
||||||
|
|
||||||
class StoreApi
|
|
||||||
basePath = "http://petstore.swagger.io/v2"
|
|
||||||
# apiInvoker = APIInvoker
|
|
||||||
|
|
||||||
def self.escapeString(string)
|
|
||||||
URI.encode(string.to_s)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def self.getInventory ( opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/store/inventory".sub('{format}','json')
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters, if any
|
|
||||||
headers = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
|
||||||
post_body = nil
|
|
||||||
|
|
||||||
|
|
||||||
# form parameters
|
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make.body
|
|
||||||
|
|
||||||
response.map {|response| map.new(response) }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def self.placeOrder (body, opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'body' => body
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/store/order".sub('{format}','json')
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters, if any
|
|
||||||
headers = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
|
||||||
post_body = nil
|
|
||||||
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
# form parameters
|
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make.body
|
|
||||||
Order.new(response)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def self.getOrderById (order_id, opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'order_id' => order_id
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(order_id))
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters, if any
|
|
||||||
headers = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
|
||||||
post_body = nil
|
|
||||||
|
|
||||||
|
|
||||||
# form parameters
|
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make.body
|
|
||||||
Order.new(response)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def self.deleteOrder (order_id, opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'order_id' => order_id
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(order_id))
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters, if any
|
|
||||||
headers = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
|
||||||
post_body = nil
|
|
||||||
|
|
||||||
|
|
||||||
# form parameters
|
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
Loading…
x
Reference in New Issue
Block a user