Merge branch 'master' of github.com:swagger-api/swagger-codegen

This commit is contained in:
Tony Tam 2015-12-08 20:40:42 -08:00
commit 2e81bf34ce
56 changed files with 1667 additions and 483 deletions

62
CONTRIBUTING.md Normal file
View File

@ -0,0 +1,62 @@
# Guidelines For Contributing
## Before submitting an issue
- Before submitting an issue, search the [open issue](https://github.com/swagger-api/swagger-codegen/issues) and [closed issue](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aissue+is%3Aclosed) to ensure no one else has reported something similar before.
- The issue should contain details on how to repeat the issue, e.g.
- the Swagger spec for reproducing the issue (:bulb: use [Gist](https://gist.github.com) to share). If the Swagger spec cannot be shared publicly, it will be hard for the community to help
- version of Swagger Codegen
- language (`-l` in the command line, e.g. java, csharp, php)
- You can also make a suggestion or ask a question by opening an "issue"
## Before submitting a PR
- Search the [open issue](https://github.com/swagger-api/swagger-codegen/issues) to ensure no one else has reported something similar and no one is actively working on similar proposed change.
- If no one has suggested something similar, open an ["issue"](https://github.com/swagger-api/swagger-codegen/issues) with your suggestion to gather feedback from the community.
## How to contribute
### Code generators
All the code generators can be found in [modules/swagger-codegen/src/main/java/io/swagger/codegen/languages](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages)
### Templates
All the templates ([mustache](https://mustache.github.io/)) can be found in [modules/swagger-codegen/src/main/resources](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources).
For a list of variables available in the template, please refer to this [page](https://github.com/swagger-api/swagger-codegen/wiki/Mustache-Template-Variables)
### Style guide
Code change should conform to the programming style guide of the respective langauages:
- C#: https://msdn.microsoft.com/en-us/library/vstudio/ff926074.aspx
- Java: https://google.github.io/styleguide/javaguide.html
- ObjC: https://github.com/NYTimes/objective-c-style-guide
- PHP: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
- Python: https://www.python.org/dev/peps/pep-0008/
- Ruby: https://github.com/bbatsov/ruby-style-guide
- TypeScript: https://github.com/Microsoft/TypeScript/wiki/Coding-guidelines
For other languages, feel free to suggest.
You may find the current code base not 100% conform to the coding style and we welcome contributions to fix those.
### Testing
To add test cases (optional) covering the change in the code generator, please refer to [modules/swagger-codegen/src/test/java/io/swagger/codegen](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/test/java/io/swagger/codegen)
To test the templates, please perform the following:
- Update the [Petstore](http://petstore.swagger.io/) sample by running the shell script under `bin` folder. For example, run `./bin/ruby-petstore.sh` to update the Ruby PetStore API client under [`samples/client/petstore/ruby`](https://github.com/swagger-api/swagger-codegen/tree/master/samples/client/petstore/ruby) (For Windows, the batch files can be found under `bin\windows` folder)
- Run the tests in the sample folder, e.g. in `samples/client/petstore/ruby`, run `mvn integration-test -rf :RubyPetstoreClientTests`. (some languages may not contain unit testing for Petstore and we're looking for contribution from the community to implement those tests)
- Finally, git commit the updated samples files: `git commit -a`
(`git add -A` if added files with new test cases)
To start the CI tests, you can run `mvn verify -Psamples` (assuming you've all the required tools installed to run tests for different languages) or you can leverage http://travis-ci.org to run the CI tests by adding your own Swagger-Codegen repository.
### Tips
- Smaller changes are easier to review
- [Optional] For bug fixes, provide a Swagger spec to repeat the issue so that the reviewer can use it to confirm the fix
- Add test case(s) to cover the change
- Document the fix in the code to make the code more readable
- Make sure test cases passed after the change (one way is to leverage https://travis-ci.org/ to run the CI tests)

View File

@ -3,6 +3,8 @@
[![Build Status](https://travis-ci.org/swagger-api/swagger-codegen.png)](https://travis-ci.org/swagger-api/swagger-codegen)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-codegen-project/badge.svg?style=plastic)](https://maven-badges.herokuapp.com/maven-central/io.swagger/swagger-codegen-project)
:star::star::star: If you would like to contribute, please refer to [guidelines](https://github.com/swagger-api/swagger-codegen/blob/master/CONTRIBUTING.md) and a list of [open tasks](https://github.com/swagger-api/swagger-codegen/issues?q=is%3Aopen+is%3Aissue+label%3A%22Need+community+contribution%22).:star::star::star:
## Overview
This is the swagger codegen project, which allows generation of client libraries automatically from a Swagger-compliant server.

View File

@ -7,9 +7,7 @@ import io.swagger.codegen.DefaultCodegen;
import io.swagger.codegen.SupportingFile;
import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.CodegenModel;
import io.swagger.models.properties.ArrayProperty;
import io.swagger.models.properties.MapProperty;
import io.swagger.models.properties.Property;
import io.swagger.models.properties.*;
import io.swagger.codegen.CliOption;
import java.io.File;
@ -300,4 +298,51 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
}
return objs;
}
/**
* Return the default value of the property
*
* @param p Swagger property object
* @return string presentation of the default value of the property
*/
@Override
public String toDefaultValue(Property p) {
if (p instanceof StringProperty) {
StringProperty dp = (StringProperty) p;
if (dp.getDefault() != null) {
return "\"" + dp.getDefault().toString() + "\"";
}
} else if (p instanceof BooleanProperty) {
BooleanProperty dp = (BooleanProperty) p;
if (dp.getDefault() != null) {
return dp.getDefault().toString();
}
} else if (p instanceof DateProperty) {
// TODO
} else if (p instanceof DateTimeProperty) {
// TODO
} else if (p instanceof DoubleProperty) {
DoubleProperty dp = (DoubleProperty) p;
if (dp.getDefault() != null) {
return dp.getDefault().toString();
}
} else if (p instanceof FloatProperty) {
FloatProperty dp = (FloatProperty) p;
if (dp.getDefault() != null) {
return dp.getDefault().toString();
}
} else if (p instanceof IntegerProperty) {
IntegerProperty dp = (IntegerProperty) p;
if (dp.getDefault() != null) {
return dp.getDefault().toString();
}
} else if (p instanceof LongProperty) {
LongProperty dp = (LongProperty) p;
if (dp.getDefault() != null) {
return dp.getDefault().toString();
}
}
return null;
}
}

View File

@ -232,6 +232,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
if ("okhttp-gson".equals(getLibrary())) {
// the "okhttp-gson" library template requires "ApiCallback.mustache" for async call
supportingFiles.add(new SupportingFile("ApiCallback.mustache", invokerFolder, "ApiCallback.java"));
supportingFiles.add(new SupportingFile("ApiResponse.mustache", invokerFolder, "ApiResponse.java"));
supportingFiles.add(new SupportingFile("ProgressRequestBody.mustache", invokerFolder, "ProgressRequestBody.java"));
supportingFiles.add(new SupportingFile("ProgressResponseBody.mustache", invokerFolder, "ProgressResponseBody.java"));
// "build.sbt" is for development with SBT

View File

@ -104,9 +104,6 @@ public class ApiClient {
private Map<String, Authentication> authentications;
private int statusCode;
private Map<String, List<String>> responseHeaders;
private DateFormat dateFormat;
private DateFormat datetimeFormat;
private boolean lenientDatetimeFormat;
@ -177,24 +174,6 @@ public class ApiClient {
return this;
}
/**
* Gets the status code of the previous request.
* NOTE: Status code of last async response is not recorded here, it is
* passed to the callback methods instead.
*/
public int getStatusCode() {
return statusCode;
}
/**
* Gets the response headers of the previous request.
* NOTE: Headers of last async response is not recorded here, it is passed
* to callback methods instead.
*/
public Map<String, List<String>> getResponseHeaders() {
return responseHeaders;
}
public boolean isVerifyingSsl() {
return verifyingSsl;
}
@ -618,6 +597,8 @@ public class ApiClient {
* @param response HTTP response
* @param returnType The type of the Java object
* @return The deserialized Java object
* @throws ApiException If fail to deserialize response body, i.e. cannot read response body
* or the Content-Type of the response is not supported.
*/
public <T> T deserialize(Response response, Type returnType) throws ApiException {
if (response == null || returnType == null)
@ -666,6 +647,7 @@ public class ApiClient {
* @param obj The Java object
* @param contentType The request Content-Type
* @return The serialized string
* @throws ApiException If fail to serialize the given object
*/
public String serialize(Object obj, String contentType) throws ApiException {
if (contentType.startsWith("application/json")) {
@ -680,6 +662,7 @@ public class ApiClient {
/**
* Download file from the given response.
* @throws ApiException If fail to read file content from response and write to disk
*/
public File downloadFileFromResponse(Response response) throws ApiException {
try {
@ -731,7 +714,7 @@ public class ApiClient {
/**
* @see #execute(Call, Type)
*/
public <T> T execute(Call call) throws ApiException {
public <T> ApiResponse<T> execute(Call call) throws ApiException {
return execute(call, null);
}
@ -740,14 +723,16 @@ public class ApiClient {
*
* @param returnType The return type used to deserialize HTTP response body
* @param <T> The return type corresponding to (same with) returnType
* @return The Java object deserialized from response body. Returns null if returnType is null.
* @return <code>ApiResponse</code> object containing response status, headers and
* data, which is a Java object deserialized from response body and would be null
* when returnType is null.
* @throws ApiException If fail to execute the call
*/
public <T> T execute(Call call, Type returnType) throws ApiException {
public <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiException {
try {
Response response = call.execute();
this.statusCode = response.code();
this.responseHeaders = response.headers().toMultimap();
return handleResponse(response, returnType);
T data = handleResponse(response, returnType);
return new ApiResponse<T>(response.code(), response.headers().toMultimap(), data);
} catch (IOException e) {
throw new ApiException(e);
}
@ -756,7 +741,7 @@ public class ApiClient {
/**
* #see executeAsync(Call, Type, ApiCallback)
*/
public <T> void executeAsync(Call call, ApiCallback<T> callback) throws ApiException {
public <T> void executeAsync(Call call, ApiCallback<T> callback) {
executeAsync(call, null, callback);
}
@ -787,6 +772,12 @@ public class ApiClient {
});
}
/**
* Handle the given response, return the deserialized object when the response is successful.
*
* @throws ApiException If the response has a unsuccessful status code or
* fail to deserialize the response body
*/
public <T> T handleResponse(Response response, Type returnType) throws ApiException {
if (response.isSuccessful()) {
if (returnType == null || response.code() == 204) {
@ -820,6 +811,7 @@ public class ApiClient {
* @param formParams The form parameters
* @param authNames The authentications to apply
* @return The HTTP call
* @throws ApiException If fail to serialize the request body object
*/
public Call buildCall(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
updateParamsForAuth(authNames, queryParams, headerParams);

View File

@ -0,0 +1,46 @@
package {{invokerPackage}};
import java.util.List;
import java.util.Map;
/**
* API response returned by API call.
*
* @param T The type of data that is deserialized from response body
*/
public class ApiResponse<T> {
final private int statusCode;
final private Map<String, List<String>> headers;
final private T data;
/**
* @param statusCode The status code of HTTP response
* @param headers The headers of HTTP response
*/
public ApiResponse(int statusCode, Map<String, List<String>> headers) {
this(statusCode, headers, null);
}
/**
* @param statusCode The status code of HTTP response
* @param headers The headers of HTTP response
* @param data The object deserialized from response bod
*/
public ApiResponse(int statusCode, Map<String, List<String>> headers, T data) {
this.statusCode = statusCode;
this.headers = headers;
this.data = data;
}
public int getStatusCode() {
return statusCode;
}
public Map<String, List<String>> getHeaders() {
return headers;
}
public T getData() {
return data;
}
}

View File

@ -3,6 +3,7 @@ package {{package}};
import {{invokerPackage}}.ApiCallback;
import {{invokerPackage}}.ApiClient;
import {{invokerPackage}}.ApiException;
import {{invokerPackage}}.ApiResponse;
import {{invokerPackage}}.Configuration;
import {{invokerPackage}}.Pair;
import {{invokerPackage}}.ProgressRequestBody;
@ -104,11 +105,24 @@ public class {{classname}} {
* {{notes}}{{#allParams}}
* @param {{paramName}} {{description}}{{/allParams}}{{#returnType}}
* @return {{{returnType}}}{{/returnType}}
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public {{#returnType}}{{{returnType}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
{{#returnType}}ApiResponse<{{{returnType}}}> {{localVariablePrefix}}resp = {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{#returnType}}
return {{localVariablePrefix}}resp.getData();{{/returnType}}
}
/**
* {{summary}}
* {{notes}}{{#allParams}}
* @param {{paramName}} {{description}}{{/allParams}}
* @return ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) throws ApiException {
Call {{localVariablePrefix}}call = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}null, null);
{{#returnType}}Type {{localVariablePrefix}}returnType = new TypeToken<{{{returnType}}}>(){}.getType();
return {{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call, {{localVariablePrefix}}returnType);{{/returnType}}{{^returnType}}{{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call);{{/returnType}}
return {{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call, {{localVariablePrefix}}returnType);{{/returnType}}{{^returnType}}return {{localVariablePrefix}}apiClient.execute({{localVariablePrefix}}call);{{/returnType}}
}
/**
@ -117,6 +131,7 @@ public class {{classname}} {
* @param {{paramName}} {{description}}{{/allParams}}
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{localVariablePrefix}}callback) throws ApiException {

View File

@ -169,15 +169,17 @@
(map (fn [[k v]] [k (normalize-param v)]))
(into {})))
(defn json-mime? [mime]
(defn json-mime?
"Check if the given MIME is a standard JSON MIME or :json."
[mime]
(if mime
(or (= :json mime)
(re-matches #"application/json(;.*)?" (name mime)))))
(defn json-preferred-mime [mimes]
(defn json-preferred-mime
"Choose a MIME from the given MIMEs with JSON preferred,
i.e. return JSON if included, otherwise return the first one."
[mimes]
(-> (filter json-mime? mimes)
first
(or (first mimes))))

View File

@ -18,6 +18,15 @@ namespace {{packageName}}.Model
[DataContract]
public class {{classname}} : IEquatable<{{classname}}>{{#parent}}, {{{parent}}}{{/parent}}
{
/// <summary>
/// Initializes a new instance of the <see cref="{{classname}}" /> class.
/// </summary>
public {{classname}}()
{
{{#vars}}{{#defaultValue}}this.{{name}} = {{{defaultValue}}};
{{/defaultValue}}{{/vars}}
}
{{#vars}}
/// <summary>
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}

View File

@ -131,7 +131,7 @@ class ApiClient
* @throws \{{invokerPackage}}\ApiException on a non 2xx response
* @return mixed
*/
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType=null)
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null)
{
$headers = array();
@ -149,7 +149,7 @@ class ApiClient
// form data
if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers)) {
$postData = http_build_query($postData);
} else if ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model
} elseif ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model
$postData = json_encode($this->serializer->sanitizeForSerialization($postData));
}
@ -160,7 +160,7 @@ class ApiClient
if ($this->config->getCurlTimeout() != 0) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout());
}
// return the result on success, rather than just TRUE
// return the result on success, rather than just true
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
@ -178,21 +178,21 @@ class ApiClient
if ($method == self::$POST) {
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$HEAD) {
} elseif ($method == self::$HEAD) {
curl_setopt($curl, CURLOPT_NOBODY, true);
} else if ($method == self::$OPTIONS) {
} elseif ($method == self::$OPTIONS) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "OPTIONS");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$PATCH) {
} elseif ($method == self::$PATCH) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$PUT) {
} elseif ($method == self::$PUT) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$DELETE) {
} elseif ($method == self::$DELETE) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method != self::$GET) {
} elseif ($method != self::$GET) {
throw new ApiException('Method ' . $method . ' is not recognized.');
}
curl_setopt($curl, CURLOPT_URL, $url);
@ -216,7 +216,7 @@ class ApiClient
// Make the request
$response = curl_exec($curl);
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$http_header = substr($response, 0, $http_header_size);
$http_header = $this->http_parse_headers(substr($response, 0, $http_header_size));
$http_body = substr($response, $http_header_size);
$response_info = curl_getinfo($curl);
@ -228,10 +228,10 @@ class ApiClient
// Handle the response
if ($response_info['http_code'] == 0) {
throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null);
} else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
} elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
// return raw body if response is a file
if ($responseType == '\SplFileObject') {
return array($http_body, $http_header);
return array($http_body, $response_info['http_code'], $http_header);
}
$data = json_decode($http_body);
@ -249,7 +249,7 @@ class ApiClient
$response_info['http_code'], $http_header, $data
);
}
return array($data, $http_header);
return array($data, $response_info['http_code'], $http_header);
}
/**
@ -287,4 +287,52 @@ class ApiClient
return implode(',', $content_type);
}
}
/**
* Return an array of HTTP response headers
*
* @param string $raw_headers A string of raw HTTP response headers
*
* @return string[] Array of HTTP response heaers
*/
protected function http_parse_headers($raw_headers)
{
// ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986
$headers = array();
$key = ''; // [+]
foreach(explode("\n", $raw_headers) as $i => $h)
{
$h = explode(':', $h, 2);
if (isset($h[1]))
{
if (!isset($headers[$h[0]]))
$headers[$h[0]] = trim($h[1]);
elseif (is_array($headers[$h[0]]))
{
// $tmp = array_merge($headers[$h[0]], array(trim($h[1]))); // [-]
// $headers[$h[0]] = $tmp; // [-]
$headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); // [+]
}
else
{
// $tmp = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [-]
// $headers[$h[0]] = $tmp; // [-]
$headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [+]
}
$key = $h[0]; // [+]
}
else // [+]
{ // [+]
if (substr($h[0], 0, 1) == "\t") // [+]
$headers[$key] .= "\r\n\t".trim($h[0]); // [+]
elseif (!$key) // [+]
$headers[0] = trim($h[0]);trim($h[0]); // [+]
} // [+]
}
return $headers;
}
}

View File

@ -56,14 +56,14 @@ class ObjectSerializer
{
if (is_scalar($data) || null === $data) {
$sanitized = $data;
} else if ($data instanceof \DateTime) {
} elseif ($data instanceof \DateTime) {
$sanitized = $data->format(\DateTime::ISO8601);
} else if (is_array($data)) {
} elseif (is_array($data)) {
foreach ($data as $property => $value) {
$data[$property] = $this->sanitizeForSerialization($value);
}
$sanitized = $data;
} else if (is_object($data)) {
} elseif (is_object($data)) {
$values = array();
foreach (array_keys($data::$swaggerTypes) as $property) {
$getter = $data::$getters[$property];
@ -198,7 +198,7 @@ class ObjectSerializer
$deserialized = $data;
} elseif ($class === '\SplFileObject') {
// determine file name
if (preg_match('/Content-Disposition: inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeader, $match)) {
if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeader['Content-Disposition'], $match)) {
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath().$match[1];
} else {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');

View File

@ -92,7 +92,7 @@ use \{{invokerPackage}}\ObjectSerializer;
{{#operation}}
/**
* {{{nickname}}}
* {{{operationId}}}
*
* {{{summary}}}
*
@ -100,12 +100,28 @@ use \{{invokerPackage}}\ObjectSerializer;
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
* @throws \{{invokerPackage}}\ApiException on non-2xx response
*/
public function {{nickname}}({{#allParams}}${{paramName}}{{^required}}=null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
public function {{operationId}}({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
{
list($response, $statusCode, $httpHeader) = $this->{{operationId}}WithHttpInfo ({{#allParams}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
return $response;
}
/**
* {{{operationId}}}WithHttpInfo
*
* {{{summary}}}
*
{{#allParams}} * @param {{dataType}} ${{paramName}} {{description}} {{#required}}(required){{/required}}{{^required}}(optional){{/required}}
{{/allParams}} * @return Array of {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}null{{/returnType}}, HTTP status code, HTTP response headers (array of strings)
* @throws \{{invokerPackage}}\ApiException on non-2xx response
*/
public function {{operationId}}WithHttpInfo({{#allParams}}${{paramName}}{{^required}} = null{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
{
{{#allParams}}{{#required}}
// verify the required parameter '{{paramName}}' is set
if (${{paramName}} === null) {
throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{nickname}}');
throw new \InvalidArgumentException('Missing the required parameter ${{paramName}} when calling {{operationId}}');
}{{/required}}{{/allParams}}
// parse inputs
@ -162,7 +178,7 @@ use \{{invokerPackage}}\ObjectSerializer;
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
{{#authMethods}}{{#isApiKey}}
@ -180,19 +196,20 @@ use \{{invokerPackage}}\ObjectSerializer;
}{{/isOAuth}}
{{/authMethods}}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams{{#returnType}}, '{{returnType}}'{{/returnType}}
);
{{#returnType}}
if (!$response) {
return null;
return array(null, $statusCode, $httpHeader);
}
return $this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader);
return array($this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader), $statusCode, $httpHeader);
{{/returnType}}{{^returnType}}
return array(null, $statusCode, $httpHeader);
{{/returnType}}
} catch (ApiException $e) {
switch ($e->getCode()) { {{#responses}}{{#dataType}}
@ -204,9 +221,6 @@ use \{{invokerPackage}}\ObjectSerializer;
throw $e;
}
{{#returnType}}
return null;
{{/returnType}}
}
{{/operation}}
}

View File

@ -1,9 +1,9 @@
#include "SWGHelpers.h"
#include "SWGModelFactory.h"
#include "SWGObject.h"
#import <QDebug>
#import <QJsonArray>
#import <QJsonValue>
#include <QDebug>
#include <QJsonArray>
#include <QJsonValue>
namespace Swagger {

View File

@ -17,6 +17,17 @@ module {{moduleName}}
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}
{{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}]
def {{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {})
{{#returnType}}data, status_code, headers = {{/returnType}}{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts)
{{#returnType}}return data{{/returnType}}{{^returnType}}return nil{{/returnType}}
end
# {{summary}}
# {{notes}}
{{#allParams}}{{#required}} # @param {{paramName}} {{description}}
{{/required}}{{/allParams}} # @param [Hash] opts the optional parameters
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}
{{/required}}{{/allParams}} # @return [Array<({{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}, Fixnum, Hash)>] {{#returnType}}{{{returnType}}} data{{/returnType}}{{^returnType}}nil{{/returnType}}, response status code and response headers
def {{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: {{classname}}#{{operationId}} ..."
end
@ -63,26 +74,17 @@ module {{moduleName}}
{{/bodyParam}}
auth_names = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}]
{{#returnType}}result = @api_client.call_api(:{{httpMethod}}, path,
data, status_code, headers = @api_client.call_api(:{{httpMethod}}, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => '{{{returnType}}}')
:auth_names => auth_names{{#returnType}},
:return_type => '{{{returnType}}}'{{/returnType}})
if Configuration.debugging
Configuration.logger.debug "API called: {{classname}}#{{operationId}}. Result: #{result.inspect}"
Configuration.logger.debug "API called: {{classname}}#{{operationId}}\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return result{{/returnType}}{{^returnType}}@api_client.call_api(:{{httpMethod}}, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: {{classname}}#{{operationId}}"
end
return nil{{/returnType}}
return data, status_code, headers
end
{{/operation}}
end

View File

@ -15,9 +15,6 @@ module {{moduleName}}
# @return [Hash]
attr_accessor :default_headers
# Stores the HTTP response from the last API call using this API client.
attr_accessor :last_response
def initialize(host = nil)
@host = host || Configuration.base_url
@format = 'json'
@ -28,13 +25,14 @@ module {{moduleName}}
}
end
# Call an API with given options.
#
# @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
# the data deserialized from response body (could be nil), response status code and response headers.
def call_api(http_method, path, opts = {})
request = build_request(http_method, path, opts)
response = request.run
# record as last response
@last_response = response
if Configuration.debugging
Configuration.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
end
@ -47,10 +45,11 @@ module {{moduleName}}
end
if opts[:return_type]
deserialize(response, opts[:return_type])
data = deserialize(response, opts[:return_type])
else
nil
data = nil
end
return data, response.code, response.headers
end
def build_request(http_method, path, opts = {})

View File

@ -169,15 +169,17 @@
(map (fn [[k v]] [k (normalize-param v)]))
(into {})))
(defn json-mime? [mime]
(defn json-mime?
"Check if the given MIME is a standard JSON MIME or :json."
[mime]
(if mime
(or (= :json mime)
(re-matches #"application/json(;.*)?" (name mime)))))
(defn json-preferred-mime [mimes]
(defn json-preferred-mime
"Choose a MIME from the given MIMEs with JSON preferred,
i.e. return JSON if included, otherwise return the first one."
[mimes]
(-> (filter json-mime? mimes)
first
(or (first mimes))))

View File

@ -16,6 +16,14 @@ namespace IO.Swagger.Model
[DataContract]
public class Category : IEquatable<Category>
{
/// <summary>
/// Initializes a new instance of the <see cref="Category" /> class.
/// </summary>
public Category()
{
}
/// <summary>
/// Gets or Sets Id

View File

@ -16,6 +16,14 @@ namespace IO.Swagger.Model
[DataContract]
public class Order : IEquatable<Order>
{
/// <summary>
/// Initializes a new instance of the <see cref="Order" /> class.
/// </summary>
public Order()
{
}
/// <summary>
/// Gets or Sets Id

View File

@ -16,6 +16,14 @@ namespace IO.Swagger.Model
[DataContract]
public class Pet : IEquatable<Pet>
{
/// <summary>
/// Initializes a new instance of the <see cref="Pet" /> class.
/// </summary>
public Pet()
{
}
/// <summary>
/// Gets or Sets Id

View File

@ -16,6 +16,14 @@ namespace IO.Swagger.Model
[DataContract]
public class Tag : IEquatable<Tag>
{
/// <summary>
/// Initializes a new instance of the <see cref="Tag" /> class.
/// </summary>
public Tag()
{
}
/// <summary>
/// Gets or Sets Id

View File

@ -16,6 +16,14 @@ namespace IO.Swagger.Model
[DataContract]
public class User : IEquatable<User>
{
/// <summary>
/// Initializes a new instance of the <see cref="User" /> class.
/// </summary>
public User()
{
}
/// <summary>
/// Gets or Sets Id

View File

@ -1,30 +1,11 @@
<Properties StartupItem="SwaggerClientTest.csproj">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs">
<MonoDevelop.Ide.Workbench ActiveDocument="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs">
<Files>
<File FileName="TestConfiguration.cs" Line="17" Column="33" />
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs" Line="523" Column="49" />
<File FileName="TestPet.cs" Line="87" Column="4" />
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs" Line="1" Column="1" />
<File FileName="TestApiClient.cs" Line="22" Column="4" />
<File FileName="TestPet.cs" Line="81" Column="17" />
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs" Line="12" Column="18" />
</Files>
<Pads>
<Pad Id="MonoDevelop.NUnit.TestPad">
<State name="__root__">
<Node name="SwaggerClientTest" expanded="True">
<Node name="SwaggerClientTest" expanded="True">
<Node name="SwaggerClient" expanded="True">
<Node name="TestPet" expanded="True">
<Node name="TestPet" expanded="True">
<Node name="TestGetPetByIdAsyncWithHttpInfo" selected="True" />
</Node>
</Node>
</Node>
</Node>
</Node>
</State>
</Pad>
</Pads>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />

View File

@ -104,9 +104,6 @@ public class ApiClient {
private Map<String, Authentication> authentications;
private int statusCode;
private Map<String, List<String>> responseHeaders;
private DateFormat dateFormat;
private DateFormat datetimeFormat;
private boolean lenientDatetimeFormat;
@ -143,8 +140,8 @@ public class ApiClient {
// Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>();
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
authentications.put("petstore_auth", new OAuth());
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
// Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications);
}
@ -176,24 +173,6 @@ public class ApiClient {
return this;
}
/**
* Gets the status code of the previous request.
* NOTE: Status code of last async response is not recorded here, it is
* passed to the callback methods instead.
*/
public int getStatusCode() {
return statusCode;
}
/**
* Gets the response headers of the previous request.
* NOTE: Headers of last async response is not recorded here, it is passed
* to callback methods instead.
*/
public Map<String, List<String>> getResponseHeaders() {
return responseHeaders;
}
public boolean isVerifyingSsl() {
return verifyingSsl;
}
@ -617,6 +596,8 @@ public class ApiClient {
* @param response HTTP response
* @param returnType The type of the Java object
* @return The deserialized Java object
* @throws ApiException If fail to deserialize response body, i.e. cannot read response body
* or the Content-Type of the response is not supported.
*/
public <T> T deserialize(Response response, Type returnType) throws ApiException {
if (response == null || returnType == null)
@ -665,6 +646,7 @@ public class ApiClient {
* @param obj The Java object
* @param contentType The request Content-Type
* @return The serialized string
* @throws ApiException If fail to serialize the given object
*/
public String serialize(Object obj, String contentType) throws ApiException {
if (contentType.startsWith("application/json")) {
@ -679,6 +661,7 @@ public class ApiClient {
/**
* Download file from the given response.
* @throws ApiException If fail to read file content from response and write to disk
*/
public File downloadFileFromResponse(Response response) throws ApiException {
try {
@ -730,7 +713,7 @@ public class ApiClient {
/**
* @see #execute(Call, Type)
*/
public <T> T execute(Call call) throws ApiException {
public <T> ApiResponse<T> execute(Call call) throws ApiException {
return execute(call, null);
}
@ -739,14 +722,16 @@ public class ApiClient {
*
* @param returnType The return type used to deserialize HTTP response body
* @param <T> The return type corresponding to (same with) returnType
* @return The Java object deserialized from response body. Returns null if returnType is null.
* @return <code>ApiResponse</code> object containing response status, headers and
* data, which is a Java object deserialized from response body and would be null
* when returnType is null.
* @throws ApiException If fail to execute the call
*/
public <T> T execute(Call call, Type returnType) throws ApiException {
public <T> ApiResponse<T> execute(Call call, Type returnType) throws ApiException {
try {
Response response = call.execute();
this.statusCode = response.code();
this.responseHeaders = response.headers().toMultimap();
return handleResponse(response, returnType);
T data = handleResponse(response, returnType);
return new ApiResponse<T>(response.code(), response.headers().toMultimap(), data);
} catch (IOException e) {
throw new ApiException(e);
}
@ -755,7 +740,7 @@ public class ApiClient {
/**
* #see executeAsync(Call, Type, ApiCallback)
*/
public <T> void executeAsync(Call call, ApiCallback<T> callback) throws ApiException {
public <T> void executeAsync(Call call, ApiCallback<T> callback) {
executeAsync(call, null, callback);
}
@ -786,6 +771,12 @@ public class ApiClient {
});
}
/**
* Handle the given response, return the deserialized object when the response is successful.
*
* @throws ApiException If the response has a unsuccessful status code or
* fail to deserialize the response body
*/
public <T> T handleResponse(Response response, Type returnType) throws ApiException {
if (response.isSuccessful()) {
if (returnType == null || response.code() == 204) {
@ -819,6 +810,7 @@ public class ApiClient {
* @param formParams The form parameters
* @param authNames The authentications to apply
* @return The HTTP call
* @throws ApiException If fail to serialize the request body object
*/
public Call buildCall(String path, String method, List<Pair> queryParams, Object body, Map<String, String> headerParams, Map<String, Object> formParams, String[] authNames, ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
updateParamsForAuth(authNames, queryParams, headerParams);

View File

@ -3,7 +3,7 @@ package io.swagger.client;
import java.util.Map;
import java.util.List;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T12:21:33.403+08:00")
public class ApiException extends Exception {
private int code = 0;
private Map<String, List<String>> responseHeaders = null;

View File

@ -0,0 +1,46 @@
package io.swagger.client;
import java.util.List;
import java.util.Map;
/**
* API response returned by API call.
*
* @param T The type of data that is deserialized from response body
*/
public class ApiResponse<T> {
final private int statusCode;
final private Map<String, List<String>> headers;
final private T data;
/**
* @param statusCode The status code of HTTP response
* @param headers The headers of HTTP response
*/
public ApiResponse(int statusCode, Map<String, List<String>> headers) {
this(statusCode, headers, null);
}
/**
* @param statusCode The status code of HTTP response
* @param headers The headers of HTTP response
* @param data The object deserialized from response bod
*/
public ApiResponse(int statusCode, Map<String, List<String>> headers, T data) {
this.statusCode = statusCode;
this.headers = headers;
this.data = data;
}
public int getStatusCode() {
return statusCode;
}
public Map<String, List<String>> getHeaders() {
return headers;
}
public T getData() {
return data;
}
}

View File

@ -1,6 +1,6 @@
package io.swagger.client;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T12:21:33.403+08:00")
public class Configuration {
private static ApiClient defaultApiClient = new ApiClient();

View File

@ -1,6 +1,6 @@
package io.swagger.client;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T12:21:33.403+08:00")
public class Pair {
private String name = "";
private String value = "";

View File

@ -1,6 +1,6 @@
package io.swagger.client;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T12:21:33.403+08:00")
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).

View File

@ -3,6 +3,7 @@ package io.swagger.client.api;
import io.swagger.client.ApiCallback;
import io.swagger.client.ApiClient;
import io.swagger.client.ApiException;
import io.swagger.client.ApiResponse;
import io.swagger.client.Configuration;
import io.swagger.client.Pair;
import io.swagger.client.ProgressRequestBody;
@ -88,10 +89,22 @@ public class PetApi {
* Update an existing pet
*
* @param body Pet object that needs to be added to the store
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public void updatePet(Pet body) throws ApiException {
updatePetWithHttpInfo(body);
}
/**
* Update an existing pet
*
* @param body Pet object that needs to be added to the store
* @return ApiResponse<Void>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Void> updatePetWithHttpInfo(Pet body) throws ApiException {
Call call = updatePetCall(body, null, null);
apiClient.execute(call);
return apiClient.execute(call);
}
/**
@ -100,13 +113,14 @@ public class PetApi {
* @param body Pet object that needs to be added to the store
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call updatePetAsync(Pet body, final ApiCallback<Void> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -173,10 +187,22 @@ public class PetApi {
* Add a new pet to the store
*
* @param body Pet object that needs to be added to the store
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public void addPet(Pet body) throws ApiException {
addPetWithHttpInfo(body);
}
/**
* Add a new pet to the store
*
* @param body Pet object that needs to be added to the store
* @return ApiResponse<Void>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Void> addPetWithHttpInfo(Pet body) throws ApiException {
Call call = addPetCall(body, null, null);
apiClient.execute(call);
return apiClient.execute(call);
}
/**
@ -185,13 +211,14 @@ public class PetApi {
* @param body Pet object that needs to be added to the store
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call addPetAsync(Pet body, final ApiCallback<Void> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -261,8 +288,21 @@ public class PetApi {
* Multiple status values can be provided with comma seperated strings
* @param status Status values that need to be considered for filter
* @return List<Pet>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public List<Pet> findPetsByStatus(List<String> status) throws ApiException {
ApiResponse<List<Pet>> resp = findPetsByStatusWithHttpInfo(status);
return resp.getData();
}
/**
* Finds Pets by status
* Multiple status values can be provided with comma seperated strings
* @param status Status values that need to be considered for filter
* @return ApiResponse<List<Pet>>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<List<Pet>> findPetsByStatusWithHttpInfo(List<String> status) throws ApiException {
Call call = findPetsByStatusCall(status, null, null);
Type returnType = new TypeToken<List<Pet>>(){}.getType();
return apiClient.execute(call, returnType);
@ -274,13 +314,14 @@ public class PetApi {
* @param status Status values that need to be considered for filter
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call findPetsByStatusAsync(List<String> status, final ApiCallback<List<Pet>> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -351,8 +392,21 @@ public class PetApi {
* Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by
* @return List<Pet>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public List<Pet> findPetsByTags(List<String> tags) throws ApiException {
ApiResponse<List<Pet>> resp = findPetsByTagsWithHttpInfo(tags);
return resp.getData();
}
/**
* Finds Pets by tags
* Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by
* @return ApiResponse<List<Pet>>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<List<Pet>> findPetsByTagsWithHttpInfo(List<String> tags) throws ApiException {
Call call = findPetsByTagsCall(tags, null, null);
Type returnType = new TypeToken<List<Pet>>(){}.getType();
return apiClient.execute(call, returnType);
@ -364,13 +418,14 @@ public class PetApi {
* @param tags Tags to filter by
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call findPetsByTagsAsync(List<String> tags, final ApiCallback<List<Pet>> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -445,8 +500,21 @@ public class PetApi {
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* @return Pet
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public Pet getPetById(Long petId) throws ApiException {
ApiResponse<Pet> resp = getPetByIdWithHttpInfo(petId);
return resp.getData();
}
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* @return ApiResponse<Pet>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Pet> getPetByIdWithHttpInfo(Long petId) throws ApiException {
Call call = getPetByIdCall(petId, null, null);
Type returnType = new TypeToken<Pet>(){}.getType();
return apiClient.execute(call, returnType);
@ -458,13 +526,14 @@ public class PetApi {
* @param petId ID of pet that needs to be fetched
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call getPetByIdAsync(Long petId, final ApiCallback<Pet> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -487,7 +556,7 @@ public class PetApi {
}
/* Build call for updatePetWithForm */
private Call updatePetWithFormCall(String petId,String name,String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
private Call updatePetWithFormCall(String petId, String name, String status, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object postBody = null;
// verify the required parameter 'petId' is set
@ -544,10 +613,24 @@ public class PetApi {
* @param petId ID of pet that needs to be updated
* @param name Updated name of the pet
* @param status Updated status of the pet
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public void updatePetWithForm(String petId, String name, String status) throws ApiException {
Call call = updatePetWithFormCall(petId,name,status, null, null);
apiClient.execute(call);
updatePetWithFormWithHttpInfo(petId, name, status);
}
/**
* Updates a pet in the store with form data
*
* @param petId ID of pet that needs to be updated
* @param name Updated name of the pet
* @param status Updated status of the pet
* @return ApiResponse<Void>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Void> updatePetWithFormWithHttpInfo(String petId, String name, String status) throws ApiException {
Call call = updatePetWithFormCall(petId, name, status, null, null);
return apiClient.execute(call);
}
/**
@ -558,13 +641,14 @@ public class PetApi {
* @param status Updated status of the pet
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call updatePetWithFormAsync(String petId, String name, String status, final ApiCallback<Void> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -580,13 +664,13 @@ public class PetApi {
};
}
Call call = updatePetWithFormCall(petId,name,status, progressListener, progressRequestListener);
Call call = updatePetWithFormCall(petId, name, status, progressListener, progressRequestListener);
apiClient.executeAsync(call, callback);
return call;
}
/* Build call for deletePet */
private Call deletePetCall(Long petId,String apiKey, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
private Call deletePetCall(Long petId, String apiKey, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object postBody = null;
// verify the required parameter 'petId' is set
@ -640,10 +724,23 @@ public class PetApi {
*
* @param petId Pet id to delete
* @param apiKey
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public void deletePet(Long petId, String apiKey) throws ApiException {
Call call = deletePetCall(petId,apiKey, null, null);
apiClient.execute(call);
deletePetWithHttpInfo(petId, apiKey);
}
/**
* Deletes a pet
*
* @param petId Pet id to delete
* @param apiKey
* @return ApiResponse<Void>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Void> deletePetWithHttpInfo(Long petId, String apiKey) throws ApiException {
Call call = deletePetCall(petId, apiKey, null, null);
return apiClient.execute(call);
}
/**
@ -653,13 +750,14 @@ public class PetApi {
* @param apiKey
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call deletePetAsync(Long petId, String apiKey, final ApiCallback<Void> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -675,13 +773,13 @@ public class PetApi {
};
}
Call call = deletePetCall(petId,apiKey, progressListener, progressRequestListener);
Call call = deletePetCall(petId, apiKey, progressListener, progressRequestListener);
apiClient.executeAsync(call, callback);
return call;
}
/* Build call for uploadFile */
private Call uploadFileCall(Long petId,String additionalMetadata,File file, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
private Call uploadFileCall(Long petId, String additionalMetadata, File file, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object postBody = null;
// verify the required parameter 'petId' is set
@ -738,10 +836,24 @@ public class PetApi {
* @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server
* @param file file to upload
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public void uploadFile(Long petId, String additionalMetadata, File file) throws ApiException {
Call call = uploadFileCall(petId,additionalMetadata,file, null, null);
apiClient.execute(call);
uploadFileWithHttpInfo(petId, additionalMetadata, file);
}
/**
* uploads an image
*
* @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server
* @param file file to upload
* @return ApiResponse<Void>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Void> uploadFileWithHttpInfo(Long petId, String additionalMetadata, File file) throws ApiException {
Call call = uploadFileCall(petId, additionalMetadata, file, null, null);
return apiClient.execute(call);
}
/**
@ -752,13 +864,14 @@ public class PetApi {
* @param file file to upload
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call uploadFileAsync(Long petId, String additionalMetadata, File file, final ApiCallback<Void> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -774,7 +887,7 @@ public class PetApi {
};
}
Call call = uploadFileCall(petId,additionalMetadata,file, progressListener, progressRequestListener);
Call call = uploadFileCall(petId, additionalMetadata, file, progressListener, progressRequestListener);
apiClient.executeAsync(call, callback);
return call;
}

View File

@ -3,6 +3,7 @@ package io.swagger.client.api;
import io.swagger.client.ApiCallback;
import io.swagger.client.ApiClient;
import io.swagger.client.ApiException;
import io.swagger.client.ApiResponse;
import io.swagger.client.Configuration;
import io.swagger.client.Pair;
import io.swagger.client.ProgressRequestBody;
@ -43,7 +44,7 @@ public class StoreApi {
/* Build call for getInventory */
private Call getInventoryCall( final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
private Call getInventoryCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object postBody = null;
@ -88,9 +89,21 @@ public class StoreApi {
* Returns pet inventories by status
* Returns a map of status codes to quantities
* @return Map<String, Integer>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public Map<String, Integer> getInventory() throws ApiException {
Call call = getInventoryCall( null, null);
ApiResponse<Map<String, Integer>> resp = getInventoryWithHttpInfo();
return resp.getData();
}
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
* @return ApiResponse<Map<String, Integer>>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Map<String, Integer>> getInventoryWithHttpInfo() throws ApiException {
Call call = getInventoryCall(null, null);
Type returnType = new TypeToken<Map<String, Integer>>(){}.getType();
return apiClient.execute(call, returnType);
}
@ -100,13 +113,14 @@ public class StoreApi {
* Returns a map of status codes to quantities
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call getInventoryAsync(final ApiCallback<Map<String, Integer>> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -122,7 +136,7 @@ public class StoreApi {
};
}
Call call = getInventoryCall( progressListener, progressRequestListener);
Call call = getInventoryCall(progressListener, progressRequestListener);
Type returnType = new TypeToken<Map<String, Integer>>(){}.getType();
apiClient.executeAsync(call, returnType, callback);
return call;
@ -175,8 +189,21 @@ public class StoreApi {
*
* @param body order placed for purchasing the pet
* @return Order
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public Order placeOrder(Order body) throws ApiException {
ApiResponse<Order> resp = placeOrderWithHttpInfo(body);
return resp.getData();
}
/**
* Place an order for a pet
*
* @param body order placed for purchasing the pet
* @return ApiResponse<Order>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Order> placeOrderWithHttpInfo(Order body) throws ApiException {
Call call = placeOrderCall(body, null, null);
Type returnType = new TypeToken<Order>(){}.getType();
return apiClient.execute(call, returnType);
@ -188,13 +215,14 @@ public class StoreApi {
* @param body order placed for purchasing the pet
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call placeOrderAsync(Order body, final ApiCallback<Order> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -269,8 +297,21 @@ public class StoreApi {
* For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched
* @return Order
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public Order getOrderById(String orderId) throws ApiException {
ApiResponse<Order> resp = getOrderByIdWithHttpInfo(orderId);
return resp.getData();
}
/**
* Find purchase order by ID
* For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched
* @return ApiResponse<Order>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Order> getOrderByIdWithHttpInfo(String orderId) throws ApiException {
Call call = getOrderByIdCall(orderId, null, null);
Type returnType = new TypeToken<Order>(){}.getType();
return apiClient.execute(call, returnType);
@ -282,13 +323,14 @@ public class StoreApi {
* @param orderId ID of pet that needs to be fetched
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call getOrderByIdAsync(String orderId, final ApiCallback<Order> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -362,10 +404,22 @@ public class StoreApi {
* Delete purchase order by ID
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
* @param orderId ID of the order that needs to be deleted
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public void deleteOrder(String orderId) throws ApiException {
deleteOrderWithHttpInfo(orderId);
}
/**
* Delete purchase order by ID
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
* @param orderId ID of the order that needs to be deleted
* @return ApiResponse<Void>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Void> deleteOrderWithHttpInfo(String orderId) throws ApiException {
Call call = deleteOrderCall(orderId, null, null);
apiClient.execute(call);
return apiClient.execute(call);
}
/**
@ -374,13 +428,14 @@ public class StoreApi {
* @param orderId ID of the order that needs to be deleted
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call deleteOrderAsync(String orderId, final ApiCallback<Void> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {

View File

@ -3,6 +3,7 @@ package io.swagger.client.api;
import io.swagger.client.ApiCallback;
import io.swagger.client.ApiClient;
import io.swagger.client.ApiException;
import io.swagger.client.ApiResponse;
import io.swagger.client.Configuration;
import io.swagger.client.Pair;
import io.swagger.client.ProgressRequestBody;
@ -88,10 +89,22 @@ public class UserApi {
* Create user
* This can only be done by the logged in user.
* @param body Created user object
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public void createUser(User body) throws ApiException {
createUserWithHttpInfo(body);
}
/**
* Create user
* This can only be done by the logged in user.
* @param body Created user object
* @return ApiResponse<Void>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Void> createUserWithHttpInfo(User body) throws ApiException {
Call call = createUserCall(body, null, null);
apiClient.execute(call);
return apiClient.execute(call);
}
/**
@ -100,13 +113,14 @@ public class UserApi {
* @param body Created user object
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call createUserAsync(User body, final ApiCallback<Void> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -173,10 +187,22 @@ public class UserApi {
* Creates list of users with given input array
*
* @param body List of user object
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public void createUsersWithArrayInput(List<User> body) throws ApiException {
createUsersWithArrayInputWithHttpInfo(body);
}
/**
* Creates list of users with given input array
*
* @param body List of user object
* @return ApiResponse<Void>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Void> createUsersWithArrayInputWithHttpInfo(List<User> body) throws ApiException {
Call call = createUsersWithArrayInputCall(body, null, null);
apiClient.execute(call);
return apiClient.execute(call);
}
/**
@ -185,13 +211,14 @@ public class UserApi {
* @param body List of user object
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call createUsersWithArrayInputAsync(List<User> body, final ApiCallback<Void> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -258,10 +285,22 @@ public class UserApi {
* Creates list of users with given input array
*
* @param body List of user object
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public void createUsersWithListInput(List<User> body) throws ApiException {
createUsersWithListInputWithHttpInfo(body);
}
/**
* Creates list of users with given input array
*
* @param body List of user object
* @return ApiResponse<Void>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Void> createUsersWithListInputWithHttpInfo(List<User> body) throws ApiException {
Call call = createUsersWithListInputCall(body, null, null);
apiClient.execute(call);
return apiClient.execute(call);
}
/**
@ -270,13 +309,14 @@ public class UserApi {
* @param body List of user object
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call createUsersWithListInputAsync(List<User> body, final ApiCallback<Void> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -298,7 +338,7 @@ public class UserApi {
}
/* Build call for loginUser */
private Call loginUserCall(String username,String password, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
private Call loginUserCall(String username, String password, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object postBody = null;
@ -349,9 +389,23 @@ public class UserApi {
* @param username The user name for login
* @param password The password for login in clear text
* @return String
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public String loginUser(String username, String password) throws ApiException {
Call call = loginUserCall(username,password, null, null);
ApiResponse<String> resp = loginUserWithHttpInfo(username, password);
return resp.getData();
}
/**
* Logs user into the system
*
* @param username The user name for login
* @param password The password for login in clear text
* @return ApiResponse<String>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<String> loginUserWithHttpInfo(String username, String password) throws ApiException {
Call call = loginUserCall(username, password, null, null);
Type returnType = new TypeToken<String>(){}.getType();
return apiClient.execute(call, returnType);
}
@ -363,13 +417,14 @@ public class UserApi {
* @param password The password for login in clear text
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call loginUserAsync(String username, String password, final ApiCallback<String> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -385,14 +440,14 @@ public class UserApi {
};
}
Call call = loginUserCall(username,password, progressListener, progressRequestListener);
Call call = loginUserCall(username, password, progressListener, progressRequestListener);
Type returnType = new TypeToken<String>(){}.getType();
apiClient.executeAsync(call, returnType, callback);
return call;
}
/* Build call for logoutUser */
private Call logoutUserCall( final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
private Call logoutUserCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object postBody = null;
@ -436,10 +491,21 @@ public class UserApi {
/**
* Logs out current logged in user session
*
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public void logoutUser() throws ApiException {
Call call = logoutUserCall( null, null);
apiClient.execute(call);
logoutUserWithHttpInfo();
}
/**
* Logs out current logged in user session
*
* @return ApiResponse<Void>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Void> logoutUserWithHttpInfo() throws ApiException {
Call call = logoutUserCall(null, null);
return apiClient.execute(call);
}
/**
@ -447,13 +513,14 @@ public class UserApi {
*
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call logoutUserAsync(final ApiCallback<Void> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -469,7 +536,7 @@ public class UserApi {
};
}
Call call = logoutUserCall( progressListener, progressRequestListener);
Call call = logoutUserCall(progressListener, progressRequestListener);
apiClient.executeAsync(call, callback);
return call;
}
@ -527,8 +594,21 @@ public class UserApi {
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @return User
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public User getUserByName(String username) throws ApiException {
ApiResponse<User> resp = getUserByNameWithHttpInfo(username);
return resp.getData();
}
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing.
* @return ApiResponse<User>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<User> getUserByNameWithHttpInfo(String username) throws ApiException {
Call call = getUserByNameCall(username, null, null);
Type returnType = new TypeToken<User>(){}.getType();
return apiClient.execute(call, returnType);
@ -540,13 +620,14 @@ public class UserApi {
* @param username The name that needs to be fetched. Use user1 for testing.
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call getUserByNameAsync(String username, final ApiCallback<User> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -569,7 +650,7 @@ public class UserApi {
}
/* Build call for updateUser */
private Call updateUserCall(String username,User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
private Call updateUserCall(String username, User body, final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
Object postBody = body;
// verify the required parameter 'username' is set
@ -621,10 +702,23 @@ public class UserApi {
* This can only be done by the logged in user.
* @param username name that need to be deleted
* @param body Updated user object
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public void updateUser(String username, User body) throws ApiException {
Call call = updateUserCall(username,body, null, null);
apiClient.execute(call);
updateUserWithHttpInfo(username, body);
}
/**
* Updated user
* This can only be done by the logged in user.
* @param username name that need to be deleted
* @param body Updated user object
* @return ApiResponse<Void>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Void> updateUserWithHttpInfo(String username, User body) throws ApiException {
Call call = updateUserCall(username, body, null, null);
return apiClient.execute(call);
}
/**
@ -634,13 +728,14 @@ public class UserApi {
* @param body Updated user object
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call updateUserAsync(String username, User body, final ApiCallback<Void> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {
@ -656,7 +751,7 @@ public class UserApi {
};
}
Call call = updateUserCall(username,body, progressListener, progressRequestListener);
Call call = updateUserCall(username, body, progressListener, progressRequestListener);
apiClient.executeAsync(call, callback);
return call;
}
@ -713,10 +808,22 @@ public class UserApi {
* Delete user
* This can only be done by the logged in user.
* @param username The name that needs to be deleted
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public void deleteUser(String username) throws ApiException {
deleteUserWithHttpInfo(username);
}
/**
* Delete user
* This can only be done by the logged in user.
* @param username The name that needs to be deleted
* @return ApiResponse<Void>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
*/
public ApiResponse<Void> deleteUserWithHttpInfo(String username) throws ApiException {
Call call = deleteUserCall(username, null, null);
apiClient.execute(call);
return apiClient.execute(call);
}
/**
@ -725,13 +832,14 @@ public class UserApi {
* @param username The name that needs to be deleted
* @param callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
*/
public Call deleteUserAsync(String username, final ApiCallback<Void> callback) throws ApiException {
ProgressResponseBody.ProgressListener progressListener = null;
ProgressRequestBody.ProgressRequestListener progressRequestListener = null;
if(callback != null) {
if (callback != null) {
progressListener = new ProgressResponseBody.ProgressListener() {
@Override
public void update(long bytesRead, long contentLength, boolean done) {

View File

@ -5,7 +5,7 @@ import io.swagger.client.Pair;
import java.util.Map;
import java.util.List;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T12:21:33.403+08:00")
public class ApiKeyAuth implements Authentication {
private final String location;
private final String paramName;

View File

@ -5,7 +5,7 @@ import io.swagger.client.Pair;
import java.util.Map;
import java.util.List;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T12:21:33.403+08:00")
public interface Authentication {
/** Apply authentication settings to header and query params. */
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams);

View File

@ -5,7 +5,7 @@ import io.swagger.client.Pair;
import java.util.Map;
import java.util.List;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-11-29T00:18:08.052+08:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaClientCodegen", date = "2015-12-07T12:21:33.403+08:00")
public class OAuth implements Authentication {
private String accessToken;

View File

@ -2,8 +2,8 @@ package io.swagger.client.model;
import io.swagger.client.StringUtil;
import io.swagger.client.model.Category;
import io.swagger.client.model.Tag;
import java.util.*;
import io.swagger.client.model.Tag;
import com.google.gson.annotations.SerializedName;

View File

@ -1,10 +1,6 @@
package io.swagger.petstore.test;
import io.swagger.client.ApiClient;
import io.swagger.client.ApiException;
import io.swagger.client.Configuration;
import io.swagger.client.ApiCallback;
import io.swagger.client.*;
import io.swagger.client.api.*;
import io.swagger.client.auth.*;
import io.swagger.client.model.*;
@ -71,6 +67,21 @@ public class PetApiTest {
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
}
@Test
public void testCreateAndGetPetWithHttpInfo() throws Exception {
Pet pet = createRandomPet();
api.addPetWithHttpInfo(pet);
ApiResponse<Pet> resp = api.getPetByIdWithHttpInfo(pet.getId());
assertEquals(200, resp.getStatusCode());
assertEquals("application/json", resp.getHeaders().get("Content-Type").get(0));
Pet fetched = resp.getData();
assertNotNull(fetched);
assertEquals(pet.getId(), fetched.getId());
assertNotNull(fetched.getCategory());
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName());
}
@Test
public void testCreateAndGetPetAsync() throws Exception {
Pet pet = createRandomPet();

View File

@ -100,7 +100,23 @@ class PetApi
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function updatePet($body=null)
public function updatePet($body = null)
{
list($response, $statusCode, $httpHeader) = $this->updatePetWithHttpInfo ($body);
return $response;
}
/**
* updatePetWithHttpInfo
*
* Update an existing pet
*
* @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (optional)
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function updatePetWithHttpInfo($body = null)
{
@ -131,7 +147,7 @@ class PetApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
@ -141,21 +157,21 @@ class PetApi
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
/**
@ -167,7 +183,23 @@ class PetApi
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function addPet($body=null)
public function addPet($body = null)
{
list($response, $statusCode, $httpHeader) = $this->addPetWithHttpInfo ($body);
return $response;
}
/**
* addPetWithHttpInfo
*
* Add a new pet to the store
*
* @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (optional)
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function addPetWithHttpInfo($body = null)
{
@ -198,7 +230,7 @@ class PetApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
@ -208,21 +240,21 @@ class PetApi
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
/**
@ -234,7 +266,23 @@ class PetApi
* @return \Swagger\Client\Model\Pet[]
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function findPetsByStatus($status=null)
public function findPetsByStatus($status = null)
{
list($response, $statusCode, $httpHeader) = $this->findPetsByStatusWithHttpInfo ($status);
return $response;
}
/**
* findPetsByStatusWithHttpInfo
*
* Finds Pets by status
*
* @param string[] $status Status values that need to be considered for filter (optional)
* @return Array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function findPetsByStatusWithHttpInfo($status = null)
{
@ -264,7 +312,7 @@ class PetApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
@ -274,19 +322,18 @@ class PetApi
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Pet[]'
);
if (!$response) {
return null;
return array(null, $statusCode, $httpHeader);
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader);
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
@ -298,9 +345,6 @@ class PetApi
throw $e;
}
return null;
}
/**
@ -312,7 +356,23 @@ class PetApi
* @return \Swagger\Client\Model\Pet[]
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function findPetsByTags($tags=null)
public function findPetsByTags($tags = null)
{
list($response, $statusCode, $httpHeader) = $this->findPetsByTagsWithHttpInfo ($tags);
return $response;
}
/**
* findPetsByTagsWithHttpInfo
*
* Finds Pets by tags
*
* @param string[] $tags Tags to filter by (optional)
* @return Array of \Swagger\Client\Model\Pet[], HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function findPetsByTagsWithHttpInfo($tags = null)
{
@ -342,7 +402,7 @@ class PetApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
@ -352,19 +412,18 @@ class PetApi
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Pet[]'
);
if (!$response) {
return null;
return array(null, $statusCode, $httpHeader);
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader);
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
@ -376,9 +435,6 @@ class PetApi
throw $e;
}
return null;
}
/**
@ -391,6 +447,22 @@ class PetApi
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getPetById($pet_id)
{
list($response, $statusCode, $httpHeader) = $this->getPetByIdWithHttpInfo ($pet_id);
return $response;
}
/**
* getPetByIdWithHttpInfo
*
* Find pet by ID
*
* @param int $pet_id ID of pet that needs to be fetched (required)
* @return Array of \Swagger\Client\Model\Pet, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getPetByIdWithHttpInfo($pet_id)
{
// verify the required parameter 'pet_id' is set
@ -428,7 +500,7 @@ class PetApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
@ -440,19 +512,18 @@ class PetApi
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Pet'
);
if (!$response) {
return null;
return array(null, $statusCode, $httpHeader);
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader);
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
@ -464,9 +535,6 @@ class PetApi
throw $e;
}
return null;
}
/**
@ -480,7 +548,25 @@ class PetApi
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function updatePetWithForm($pet_id, $name=null, $status=null)
public function updatePetWithForm($pet_id, $name = null, $status = null)
{
list($response, $statusCode, $httpHeader) = $this->updatePetWithFormWithHttpInfo ($pet_id, $name, $status);
return $response;
}
/**
* updatePetWithFormWithHttpInfo
*
* Updates a pet in the store with form data
*
* @param string $pet_id ID of pet that needs to be updated (required)
* @param string $name Updated name of the pet (optional)
* @param string $status Updated status of the pet (optional)
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function updatePetWithFormWithHttpInfo($pet_id, $name = null, $status = null)
{
// verify the required parameter 'pet_id' is set
@ -530,7 +616,7 @@ class PetApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
@ -540,21 +626,21 @@ class PetApi
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
/**
@ -567,7 +653,24 @@ class PetApi
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function deletePet($pet_id, $api_key=null)
public function deletePet($pet_id, $api_key = null)
{
list($response, $statusCode, $httpHeader) = $this->deletePetWithHttpInfo ($pet_id, $api_key);
return $response;
}
/**
* deletePetWithHttpInfo
*
* Deletes a pet
*
* @param int $pet_id Pet id to delete (required)
* @param string $api_key (optional)
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function deletePetWithHttpInfo($pet_id, $api_key = null)
{
// verify the required parameter 'pet_id' is set
@ -608,7 +711,7 @@ class PetApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
@ -618,21 +721,21 @@ class PetApi
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
/**
@ -646,7 +749,25 @@ class PetApi
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function uploadFile($pet_id, $additional_metadata=null, $file=null)
public function uploadFile($pet_id, $additional_metadata = null, $file = null)
{
list($response, $statusCode, $httpHeader) = $this->uploadFileWithHttpInfo ($pet_id, $additional_metadata, $file);
return $response;
}
/**
* uploadFileWithHttpInfo
*
* uploads an image
*
* @param int $pet_id ID of pet to update (required)
* @param string $additional_metadata Additional data to pass to server (optional)
* @param \SplFileObject $file file to upload (optional)
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $file = null)
{
// verify the required parameter 'pet_id' is set
@ -702,7 +823,7 @@ class PetApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
@ -712,21 +833,21 @@ class PetApi
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
}

View File

@ -100,6 +100,21 @@ class StoreApi
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getInventory()
{
list($response, $statusCode, $httpHeader) = $this->getInventoryWithHttpInfo ();
return $response;
}
/**
* getInventoryWithHttpInfo
*
* Returns pet inventories by status
*
* @return Array of map[string,int], HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getInventoryWithHttpInfo()
{
@ -126,7 +141,7 @@ class StoreApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
@ -138,19 +153,18 @@ class StoreApi
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams, 'map[string,int]'
);
if (!$response) {
return null;
return array(null, $statusCode, $httpHeader);
}
return $this->apiClient->getSerializer()->deserialize($response, 'map[string,int]', $httpHeader);
return array($this->apiClient->getSerializer()->deserialize($response, 'map[string,int]', $httpHeader), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
@ -162,9 +176,6 @@ class StoreApi
throw $e;
}
return null;
}
/**
@ -176,7 +187,23 @@ class StoreApi
* @return \Swagger\Client\Model\Order
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function placeOrder($body=null)
public function placeOrder($body = null)
{
list($response, $statusCode, $httpHeader) = $this->placeOrderWithHttpInfo ($body);
return $response;
}
/**
* placeOrderWithHttpInfo
*
* Place an order for a pet
*
* @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (optional)
* @return Array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function placeOrderWithHttpInfo($body = null)
{
@ -207,24 +234,23 @@ class StoreApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Order'
);
if (!$response) {
return null;
return array(null, $statusCode, $httpHeader);
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader);
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
@ -236,9 +262,6 @@ class StoreApi
throw $e;
}
return null;
}
/**
@ -251,6 +274,22 @@ class StoreApi
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getOrderById($order_id)
{
list($response, $statusCode, $httpHeader) = $this->getOrderByIdWithHttpInfo ($order_id);
return $response;
}
/**
* getOrderByIdWithHttpInfo
*
* Find purchase order by ID
*
* @param string $order_id ID of pet that needs to be fetched (required)
* @return Array of \Swagger\Client\Model\Order, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getOrderByIdWithHttpInfo($order_id)
{
// verify the required parameter 'order_id' is set
@ -288,24 +327,23 @@ class StoreApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Order'
);
if (!$response) {
return null;
return array(null, $statusCode, $httpHeader);
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader);
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
@ -317,9 +355,6 @@ class StoreApi
throw $e;
}
return null;
}
/**
@ -332,6 +367,22 @@ class StoreApi
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function deleteOrder($order_id)
{
list($response, $statusCode, $httpHeader) = $this->deleteOrderWithHttpInfo ($order_id);
return $response;
}
/**
* deleteOrderWithHttpInfo
*
* Delete purchase order by ID
*
* @param string $order_id ID of the order that needs to be deleted (required)
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function deleteOrderWithHttpInfo($order_id)
{
// verify the required parameter 'order_id' is set
@ -369,26 +420,26 @@ class StoreApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
}

View File

@ -100,7 +100,23 @@ class UserApi
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function createUser($body=null)
public function createUser($body = null)
{
list($response, $statusCode, $httpHeader) = $this->createUserWithHttpInfo ($body);
return $response;
}
/**
* createUserWithHttpInfo
*
* Create user
*
* @param \Swagger\Client\Model\User $body Created user object (optional)
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function createUserWithHttpInfo($body = null)
{
@ -131,26 +147,26 @@ class UserApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
/**
@ -162,7 +178,23 @@ class UserApi
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function createUsersWithArrayInput($body=null)
public function createUsersWithArrayInput($body = null)
{
list($response, $statusCode, $httpHeader) = $this->createUsersWithArrayInputWithHttpInfo ($body);
return $response;
}
/**
* createUsersWithArrayInputWithHttpInfo
*
* Creates list of users with given input array
*
* @param \Swagger\Client\Model\User[] $body List of user object (optional)
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function createUsersWithArrayInputWithHttpInfo($body = null)
{
@ -193,26 +225,26 @@ class UserApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
/**
@ -224,7 +256,23 @@ class UserApi
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function createUsersWithListInput($body=null)
public function createUsersWithListInput($body = null)
{
list($response, $statusCode, $httpHeader) = $this->createUsersWithListInputWithHttpInfo ($body);
return $response;
}
/**
* createUsersWithListInputWithHttpInfo
*
* Creates list of users with given input array
*
* @param \Swagger\Client\Model\User[] $body List of user object (optional)
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function createUsersWithListInputWithHttpInfo($body = null)
{
@ -255,26 +303,26 @@ class UserApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
/**
@ -287,7 +335,24 @@ class UserApi
* @return string
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function loginUser($username=null, $password=null)
public function loginUser($username = null, $password = null)
{
list($response, $statusCode, $httpHeader) = $this->loginUserWithHttpInfo ($username, $password);
return $response;
}
/**
* loginUserWithHttpInfo
*
* Logs user into the system
*
* @param string $username The user name for login (optional)
* @param string $password The password for login in clear text (optional)
* @return Array of string, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function loginUserWithHttpInfo($username = null, $password = null)
{
@ -320,24 +385,23 @@ class UserApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams, 'string'
);
if (!$response) {
return null;
return array(null, $statusCode, $httpHeader);
}
return $this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader);
return array($this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
@ -349,9 +413,6 @@ class UserApi
throw $e;
}
return null;
}
/**
@ -363,6 +424,21 @@ class UserApi
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function logoutUser()
{
list($response, $statusCode, $httpHeader) = $this->logoutUserWithHttpInfo ();
return $response;
}
/**
* logoutUserWithHttpInfo
*
* Logs out current logged in user session
*
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function logoutUserWithHttpInfo()
{
@ -389,26 +465,26 @@ class UserApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
/**
@ -421,6 +497,22 @@ class UserApi
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getUserByName($username)
{
list($response, $statusCode, $httpHeader) = $this->getUserByNameWithHttpInfo ($username);
return $response;
}
/**
* getUserByNameWithHttpInfo
*
* Get user by user name
*
* @param string $username The name that needs to be fetched. Use user1 for testing. (required)
* @return Array of \Swagger\Client\Model\User, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getUserByNameWithHttpInfo($username)
{
// verify the required parameter 'username' is set
@ -458,24 +550,23 @@ class UserApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\User'
);
if (!$response) {
return null;
return array(null, $statusCode, $httpHeader);
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User', $httpHeader);
return array($this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User', $httpHeader), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
@ -487,9 +578,6 @@ class UserApi
throw $e;
}
return null;
}
/**
@ -502,7 +590,24 @@ class UserApi
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function updateUser($username, $body=null)
public function updateUser($username, $body = null)
{
list($response, $statusCode, $httpHeader) = $this->updateUserWithHttpInfo ($username, $body);
return $response;
}
/**
* updateUserWithHttpInfo
*
* Updated user
*
* @param string $username name that need to be deleted (required)
* @param \Swagger\Client\Model\User $body Updated user object (optional)
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function updateUserWithHttpInfo($username, $body = null)
{
// verify the required parameter 'username' is set
@ -544,26 +649,26 @@ class UserApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
/**
@ -576,6 +681,22 @@ class UserApi
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function deleteUser($username)
{
list($response, $statusCode, $httpHeader) = $this->deleteUserWithHttpInfo ($username);
return $response;
}
/**
* deleteUserWithHttpInfo
*
* Delete user
*
* @param string $username The name that needs to be deleted (required)
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function deleteUserWithHttpInfo($username)
{
// verify the required parameter 'username' is set
@ -613,26 +734,26 @@ class UserApi
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} else if (count($formParams) > 0) {
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
// make the API Call
try
{
list($response, $httpHeader) = $this->apiClient->callApi(
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method,
$queryParams, $httpBody,
$headerParams
);
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
}
throw $e;
}
}
}

View File

@ -131,7 +131,7 @@ class ApiClient
* @throws \Swagger\Client\ApiException on a non 2xx response
* @return mixed
*/
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType=null)
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams, $responseType = null)
{
$headers = array();
@ -149,7 +149,7 @@ class ApiClient
// form data
if ($postData and in_array('Content-Type: application/x-www-form-urlencoded', $headers)) {
$postData = http_build_query($postData);
} else if ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model
} elseif ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model
$postData = json_encode($this->serializer->sanitizeForSerialization($postData));
}
@ -160,7 +160,7 @@ class ApiClient
if ($this->config->getCurlTimeout() != 0) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout());
}
// return the result on success, rather than just TRUE
// return the result on success, rather than just true
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
@ -178,21 +178,21 @@ class ApiClient
if ($method == self::$POST) {
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$HEAD) {
} elseif ($method == self::$HEAD) {
curl_setopt($curl, CURLOPT_NOBODY, true);
} else if ($method == self::$OPTIONS) {
} elseif ($method == self::$OPTIONS) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "OPTIONS");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$PATCH) {
} elseif ($method == self::$PATCH) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PATCH");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$PUT) {
} elseif ($method == self::$PUT) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method == self::$DELETE) {
} elseif ($method == self::$DELETE) {
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
} else if ($method != self::$GET) {
} elseif ($method != self::$GET) {
throw new ApiException('Method ' . $method . ' is not recognized.');
}
curl_setopt($curl, CURLOPT_URL, $url);
@ -216,7 +216,7 @@ class ApiClient
// Make the request
$response = curl_exec($curl);
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$http_header = substr($response, 0, $http_header_size);
$http_header = $this->http_parse_headers(substr($response, 0, $http_header_size));
$http_body = substr($response, $http_header_size);
$response_info = curl_getinfo($curl);
@ -228,10 +228,10 @@ class ApiClient
// Handle the response
if ($response_info['http_code'] == 0) {
throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null);
} else if ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
} elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
// return raw body if response is a file
if ($responseType == '\SplFileObject') {
return array($http_body, $http_header);
return array($http_body, $response_info['http_code'], $http_header);
}
$data = json_decode($http_body);
@ -249,7 +249,7 @@ class ApiClient
$response_info['http_code'], $http_header, $data
);
}
return array($data, $http_header);
return array($data, $response_info['http_code'], $http_header);
}
/**
@ -287,4 +287,52 @@ class ApiClient
return implode(',', $content_type);
}
}
/**
* Return an array of HTTP response headers
*
* @param string $raw_headers A string of raw HTTP response headers
*
* @return string[] Array of HTTP response heaers
*/
protected function http_parse_headers($raw_headers)
{
// ref/credit: http://php.net/manual/en/function.http-parse-headers.php#112986
$headers = array();
$key = ''; // [+]
foreach(explode("\n", $raw_headers) as $i => $h)
{
$h = explode(':', $h, 2);
if (isset($h[1]))
{
if (!isset($headers[$h[0]]))
$headers[$h[0]] = trim($h[1]);
elseif (is_array($headers[$h[0]]))
{
// $tmp = array_merge($headers[$h[0]], array(trim($h[1]))); // [-]
// $headers[$h[0]] = $tmp; // [-]
$headers[$h[0]] = array_merge($headers[$h[0]], array(trim($h[1]))); // [+]
}
else
{
// $tmp = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [-]
// $headers[$h[0]] = $tmp; // [-]
$headers[$h[0]] = array_merge(array($headers[$h[0]]), array(trim($h[1]))); // [+]
}
$key = $h[0]; // [+]
}
else // [+]
{ // [+]
if (substr($h[0], 0, 1) == "\t") // [+]
$headers[$key] .= "\r\n\t".trim($h[0]); // [+]
elseif (!$key) // [+]
$headers[0] = trim($h[0]);trim($h[0]); // [+]
} // [+]
}
return $headers;
}
}

View File

@ -56,14 +56,14 @@ class ObjectSerializer
{
if (is_scalar($data) || null === $data) {
$sanitized = $data;
} else if ($data instanceof \DateTime) {
} elseif ($data instanceof \DateTime) {
$sanitized = $data->format(\DateTime::ISO8601);
} else if (is_array($data)) {
} elseif (is_array($data)) {
foreach ($data as $property => $value) {
$data[$property] = $this->sanitizeForSerialization($value);
}
$sanitized = $data;
} else if (is_object($data)) {
} elseif (is_object($data)) {
$values = array();
foreach (array_keys($data::$swaggerTypes) as $property) {
$getter = $data::$getters[$property];
@ -198,7 +198,7 @@ class ObjectSerializer
$deserialized = $data;
} elseif ($class === '\SplFileObject') {
// determine file name
if (preg_match('/Content-Disposition: inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeader, $match)) {
if (array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeader['Content-Disposition'], $match)) {
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath().$match[1];
} else {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');

View File

@ -105,6 +105,25 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
$this->assertSame($response->getTags()[0]->getName(), 'test php tag');
}
// test getPetById with a Pet object (id 10005)
public function testGetPetByIdWithHttpInfo()
{
// initialize the API client without host
$pet_id = 10005; // ID of pet that needs to be fetched
$pet_api = new Swagger\Client\Api\PetAPI();
$pet_api->getApiClient()->getConfig()->setApiKey('api_key', '111222333444555');
// return Pet (model)
list($response, $status_code, $response_headers) = $pet_api->getPetByIdWithHttpInfo($pet_id);
$this->assertSame($response->getId(), $pet_id);
$this->assertSame($response->getName(), 'PHP Unit Test');
$this->assertSame($response->getCategory()->getId(), $pet_id);
$this->assertSame($response->getCategory()->getName(), 'test php category');
$this->assertSame($response->getTags()[0]->getId(), $pet_id);
$this->assertSame($response->getTags()[0]->getName(), 'test php tag');
$this->assertSame($status_code, 200);
$this->assertSame($response_headers['Content-Type'], 'application/json');
}
// test getPetByStatus and verify by the "id" of the response
public function testFindPetByStatus()
{
@ -149,7 +168,26 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
$this->assertSame($response->getName(), 'updatePet');
}
// test updatePet and verify by the "id" of the response
// test updatePetWithFormWithHttpInfo and verify by the "name" of the response
public function testUpdatePetWithFormWithHttpInfo()
{
// initialize the API client
$config = (new Swagger\Client\Configuration())->setHost('http://petstore.swagger.io/v2');
$api_client = new Swagger\Client\ApiClient($config);
$pet_id = 10001; // ID of pet that needs to be fetched
$pet_api = new Swagger\Client\Api\PetAPI($api_client);
// update Pet (form)
list($update_response, $status_code, $http_headers) = $pet_api->updatePetWithFormWithHttpInfo($pet_id, 'update pet with form with http info');
// return nothing (void)
$this->assertNull($update_response);
$this->assertSame($status_code, 200);
$this->assertSame($http_headers['Content-Type'], 'application/json');
$response = $pet_api->getPetById($pet_id);
$this->assertSame($response->getId(), $pet_id);
$this->assertSame($response->getName(), 'update pet with form with http info');
}
// test updatePetWithForm and verify by the "name" and "status" of the response
public function testUpdatePetWithForm()
{
// initialize the API client

View File

@ -35,34 +35,12 @@ void PetApiTests::runTests() {
delete tests;
}
void PetApiTests::getPetByIdTest() {
SWGPetApi* api = getApi();
static QEventLoop loop;
QTimer timer;
timer.setInterval(1000);
timer.setSingleShot(true);
auto validator = [](SWGPet* pet) {
QVERIFY(pet->getId() == 3);
loop.quit();
};
connect(api, &SWGPetApi::getPetByIdSignal, this, validator);
connect(&timer, &QTimer::timeout, &loop, &QEventLoop::quit);
api->getPetById(3);
timer.start();
loop.exec();
QVERIFY2(timer.isActive(), "didn't finish within timeout");
delete api;
}
void PetApiTests::findPetsByStatusTest() {
SWGPetApi* api = getApi();
static QEventLoop loop;
QTimer timer;
timer.setInterval(1000);
timer.setInterval(4000);
timer.setSingleShot(true);
auto validator = [](QList<SWGPet*>* pets) {

View File

@ -25,7 +25,6 @@ signals:
bool success();
private slots:
void getPetByIdTest();
void findPetsByStatusTest();
void createAndGetPetTest();
void updatePetTest();

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.3.2, 2015-05-15T11:02:11. -->
<!-- Written by QtCreator 3.5.1, 2015-12-08T17:23:46. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
<value type="QByteArray">{e1009bf2-3b8d-440a-a972-23a1fd0a9453}</value>
<value type="QByteArray">{20946a4e-8558-4260-a72e-14a8108ad944}</value>
</data>
<data>
<variable>ProjectExplorer.Project.ActiveTarget</variable>
@ -58,14 +58,14 @@
<data>
<variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.4.1 clang 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.4.1 clang 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.54.clang_64_kit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.5.1 clang 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">Desktop Qt 5.5.1 clang 64bit</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">qt.55.clang_64_kit</value>
<value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/tony/dev/projects/swagger-api/swagger-codegen/samples/client/petstore/qt5cpp/build-PetStore-Desktop_Qt_5_4_1_clang_64bit-Debug</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/qt5cpp/build-PetStore-Desktop_Qt_5_5_1_clang_64bit-Debug</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -76,6 +76,7 @@
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
@ -125,7 +126,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1">
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/tony/dev/projects/swagger-api/swagger-codegen/samples/client/petstore/qt5cpp/build-PetStore-Desktop_Qt_5_4_1_clang_64bit-Release</value>
<value type="QString" key="ProjectExplorer.BuildConfiguration.BuildDirectory">/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/qt5cpp/build-PetStore-Desktop_Qt_5_5_1_clang_64bit-Release</value>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -136,6 +137,7 @@
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.SeparateDebugInfo">false</value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
@ -216,12 +218,10 @@
<value type="bool" key="Analyzer.Valgrind.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">/usr/local/bin/valgrind</value>
<value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
<valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">11</value>
<value type="int">14</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">0</value>
<value type="int">1</value>
<value type="int">2</value>
<value type="int">3</value>
<value type="int">4</value>
@ -231,14 +231,16 @@
<value type="int">8</value>
<value type="int">9</value>
<value type="int">10</value>
<value type="int">0</value>
<value type="int">1</value>
<value type="int">11</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">PetStore</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/Users/tony/dev/projects/swagger-api/swagger-codegen/samples/client/petstore/qt5cpp/PetStore/PetStore.pro</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">Qt4ProjectManager.Qt4RunConfiguration:/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/qt5cpp/PetStore/PetStore.pro</value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">PetStore.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>

View File

@ -1,9 +1,9 @@
#include "SWGHelpers.h"
#include "SWGModelFactory.h"
#include "SWGObject.h"
#import <QDebug>
#import <QJsonArray>
#import <QJsonValue>
#include <QDebug>
#include <QJsonArray>
#include <QJsonValue>
namespace Swagger {
@ -25,6 +25,14 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
qint64 *val = static_cast<qint64*>(value);
*val = obj.toVariant().toLongLong();
}
else if(QStringLiteral("float").compare(type) == 0) {
float *val = static_cast<float*>(value);
*val = obj.toDouble();
}
else if(QStringLiteral("double").compare(type) == 0) {
double *val = static_cast<double*>(value);
*val = obj.toDouble();
}
else if (QStringLiteral("QString").compare(type) == 0) {
QString **val = static_cast<QString**>(value);
@ -86,6 +94,16 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
setValue(&val, jval, QStringLiteral("bool"), QStringLiteral(""));
output->append((void*)&val);
}
else if(QStringLiteral("float").compare(complexType) == 0) {
float val;
setValue(&val, jval, QStringLiteral("float"), QStringLiteral(""));
output->append((void*)&val);
}
else if(QStringLiteral("double").compare(complexType) == 0) {
double val;
setValue(&val, jval, QStringLiteral("double"), QStringLiteral(""));
output->append((void*)&val);
}
}
}
QList<void*> **val = static_cast<QList<void*>**>(value);
@ -131,6 +149,14 @@ toJsonValue(QString name, void* value, QJsonObject* output, QString type) {
bool* str = static_cast<bool*>(value);
output->insert(name, QJsonValue(*str));
}
else if(QStringLiteral("float").compare(type) == 0) {
float* str = static_cast<float*>(value);
output->insert(name, QJsonValue((double)*str));
}
else if(QStringLiteral("double").compare(type) == 0) {
double* str = static_cast<double*>(value);
output->insert(name, QJsonValue(*str));
}
}
void

View File

@ -10,10 +10,10 @@
#include <QJsonObject>
#include "SWGTag.h"
#include <QList>
#include "SWGCategory.h"
#include <QString>
#include "SWGCategory.h"
#include <QList>
#include "SWGTag.h"
#include "SWGObject.h"

View File

@ -14,6 +14,16 @@ module Petstore
# @option opts [Pet] :body Pet object that needs to be added to the store
# @return [nil]
def update_pet(opts = {})
update_pet_with_http_info(opts)
return nil
end
# Update an existing pet
#
# @param [Hash] opts the optional parameters
# @option opts [Pet] :body Pet object that needs to be added to the store
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def update_pet_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#update_pet ..."
end
@ -43,16 +53,16 @@ module Petstore
auth_names = ['petstore_auth']
@api_client.call_api(:PUT, path,
data, status_code, headers = @api_client.call_api(:PUT, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: PetApi#update_pet"
Configuration.logger.debug "API called: PetApi#update_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return nil
return data, status_code, headers
end
# Add a new pet to the store
@ -61,6 +71,16 @@ module Petstore
# @option opts [Pet] :body Pet object that needs to be added to the store
# @return [nil]
def add_pet(opts = {})
add_pet_with_http_info(opts)
return nil
end
# Add a new pet to the store
#
# @param [Hash] opts the optional parameters
# @option opts [Pet] :body Pet object that needs to be added to the store
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def add_pet_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#add_pet ..."
end
@ -90,16 +110,16 @@ module Petstore
auth_names = ['petstore_auth']
@api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: PetApi#add_pet"
Configuration.logger.debug "API called: PetApi#add_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return nil
return data, status_code, headers
end
# Finds Pets by status
@ -108,6 +128,16 @@ module Petstore
# @option opts [Array<String>] :status Status values that need to be considered for filter
# @return [Array<Pet>]
def find_pets_by_status(opts = {})
data, status_code, headers = find_pets_by_status_with_http_info(opts)
return data
end
# Finds Pets by status
# Multiple status values can be provided with comma seperated strings
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :status Status values that need to be considered for filter
# @return [Array<(Array<Pet>, Fixnum, Hash)>] Array<Pet> data, response status code and response headers
def find_pets_by_status_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#find_pets_by_status ..."
end
@ -138,7 +168,7 @@ module Petstore
auth_names = ['petstore_auth']
result = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -146,9 +176,9 @@ module Petstore
:auth_names => auth_names,
:return_type => 'Array<Pet>')
if Configuration.debugging
Configuration.logger.debug "API called: PetApi#find_pets_by_status. Result: #{result.inspect}"
Configuration.logger.debug "API called: PetApi#find_pets_by_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return result
return data, status_code, headers
end
# Finds Pets by tags
@ -157,6 +187,16 @@ module Petstore
# @option opts [Array<String>] :tags Tags to filter by
# @return [Array<Pet>]
def find_pets_by_tags(opts = {})
data, status_code, headers = find_pets_by_tags_with_http_info(opts)
return data
end
# Finds Pets by tags
# Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :tags Tags to filter by
# @return [Array<(Array<Pet>, Fixnum, Hash)>] Array<Pet> data, response status code and response headers
def find_pets_by_tags_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#find_pets_by_tags ..."
end
@ -187,7 +227,7 @@ module Petstore
auth_names = ['petstore_auth']
result = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -195,9 +235,9 @@ module Petstore
:auth_names => auth_names,
:return_type => 'Array<Pet>')
if Configuration.debugging
Configuration.logger.debug "API called: PetApi#find_pets_by_tags. Result: #{result.inspect}"
Configuration.logger.debug "API called: PetApi#find_pets_by_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return result
return data, status_code, headers
end
# Find pet by ID
@ -206,6 +246,16 @@ module Petstore
# @param [Hash] opts the optional parameters
# @return [Pet]
def get_pet_by_id(pet_id, opts = {})
data, status_code, headers = get_pet_by_id_with_http_info(pet_id, opts)
return data
end
# Find pet by ID
# Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
# @param pet_id ID of pet that needs to be fetched
# @param [Hash] opts the optional parameters
# @return [Array<(Pet, Fixnum, Hash)>] Pet data, response status code and response headers
def get_pet_by_id_with_http_info(pet_id, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#get_pet_by_id ..."
end
@ -238,7 +288,7 @@ module Petstore
auth_names = ['api_key']
result = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -246,9 +296,9 @@ module Petstore
:auth_names => auth_names,
:return_type => 'Pet')
if Configuration.debugging
Configuration.logger.debug "API called: PetApi#get_pet_by_id. Result: #{result.inspect}"
Configuration.logger.debug "API called: PetApi#get_pet_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return result
return data, status_code, headers
end
# Updates a pet in the store with form data
@ -259,6 +309,18 @@ module Petstore
# @option opts [String] :status Updated status of the pet
# @return [nil]
def update_pet_with_form(pet_id, opts = {})
update_pet_with_form_with_http_info(pet_id, opts)
return nil
end
# Updates a pet in the store with form data
#
# @param pet_id ID of pet that needs to be updated
# @param [Hash] opts the optional parameters
# @option opts [String] :name Updated name of the pet
# @option opts [String] :status Updated status of the pet
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def update_pet_with_form_with_http_info(pet_id, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#update_pet_with_form ..."
end
@ -293,16 +355,16 @@ module Petstore
auth_names = ['petstore_auth']
@api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: PetApi#update_pet_with_form"
Configuration.logger.debug "API called: PetApi#update_pet_with_form\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return nil
return data, status_code, headers
end
# Deletes a pet
@ -312,6 +374,17 @@ module Petstore
# @option opts [String] :api_key
# @return [nil]
def delete_pet(pet_id, opts = {})
delete_pet_with_http_info(pet_id, opts)
return nil
end
# Deletes a pet
#
# @param pet_id Pet id to delete
# @param [Hash] opts the optional parameters
# @option opts [String] :api_key
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_pet_with_http_info(pet_id, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#delete_pet ..."
end
@ -345,16 +418,16 @@ module Petstore
auth_names = ['petstore_auth']
@api_client.call_api(:DELETE, path,
data, status_code, headers = @api_client.call_api(:DELETE, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: PetApi#delete_pet"
Configuration.logger.debug "API called: PetApi#delete_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return nil
return data, status_code, headers
end
# uploads an image
@ -365,6 +438,18 @@ module Petstore
# @option opts [File] :file file to upload
# @return [nil]
def upload_file(pet_id, opts = {})
upload_file_with_http_info(pet_id, opts)
return nil
end
# uploads an image
#
# @param pet_id ID of pet to update
# @param [Hash] opts the optional parameters
# @option opts [String] :additional_metadata Additional data to pass to server
# @option opts [File] :file file to upload
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def upload_file_with_http_info(pet_id, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#upload_file ..."
end
@ -399,16 +484,16 @@ module Petstore
auth_names = ['petstore_auth']
@api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: PetApi#upload_file"
Configuration.logger.debug "API called: PetApi#upload_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return nil
return data, status_code, headers
end
end
end

View File

@ -13,6 +13,15 @@ module Petstore
# @param [Hash] opts the optional parameters
# @return [Hash<String, Integer>]
def get_inventory(opts = {})
data, status_code, headers = get_inventory_with_http_info(opts)
return data
end
# Returns pet inventories by status
# Returns a map of status codes to quantities
# @param [Hash] opts the optional parameters
# @return [Array<(Hash<String, Integer>, Fixnum, Hash)>] Hash<String, Integer> data, response status code and response headers
def get_inventory_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: StoreApi#get_inventory ..."
end
@ -42,7 +51,7 @@ module Petstore
auth_names = ['api_key']
result = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -50,9 +59,9 @@ module Petstore
:auth_names => auth_names,
:return_type => 'Hash<String, Integer>')
if Configuration.debugging
Configuration.logger.debug "API called: StoreApi#get_inventory. Result: #{result.inspect}"
Configuration.logger.debug "API called: StoreApi#get_inventory\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return result
return data, status_code, headers
end
# Place an order for a pet
@ -61,6 +70,16 @@ module Petstore
# @option opts [Order] :body order placed for purchasing the pet
# @return [Order]
def place_order(opts = {})
data, status_code, headers = place_order_with_http_info(opts)
return data
end
# Place an order for a pet
#
# @param [Hash] opts the optional parameters
# @option opts [Order] :body order placed for purchasing the pet
# @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers
def place_order_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: StoreApi#place_order ..."
end
@ -90,7 +109,7 @@ module Petstore
auth_names = []
result = @api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -98,9 +117,9 @@ module Petstore
:auth_names => auth_names,
:return_type => 'Order')
if Configuration.debugging
Configuration.logger.debug "API called: StoreApi#place_order. Result: #{result.inspect}"
Configuration.logger.debug "API called: StoreApi#place_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return result
return data, status_code, headers
end
# Find purchase order by ID
@ -109,6 +128,16 @@ module Petstore
# @param [Hash] opts the optional parameters
# @return [Order]
def get_order_by_id(order_id, opts = {})
data, status_code, headers = get_order_by_id_with_http_info(order_id, opts)
return data
end
# Find purchase order by ID
# For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions
# @param order_id ID of pet that needs to be fetched
# @param [Hash] opts the optional parameters
# @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers
def get_order_by_id_with_http_info(order_id, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: StoreApi#get_order_by_id ..."
end
@ -141,7 +170,7 @@ module Petstore
auth_names = []
result = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -149,9 +178,9 @@ module Petstore
:auth_names => auth_names,
:return_type => 'Order')
if Configuration.debugging
Configuration.logger.debug "API called: StoreApi#get_order_by_id. Result: #{result.inspect}"
Configuration.logger.debug "API called: StoreApi#get_order_by_id\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return result
return data, status_code, headers
end
# Delete purchase order by ID
@ -160,6 +189,16 @@ module Petstore
# @param [Hash] opts the optional parameters
# @return [nil]
def delete_order(order_id, opts = {})
delete_order_with_http_info(order_id, opts)
return nil
end
# Delete purchase order by ID
# For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
# @param order_id ID of the order that needs to be deleted
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_order_with_http_info(order_id, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: StoreApi#delete_order ..."
end
@ -192,16 +231,16 @@ module Petstore
auth_names = []
@api_client.call_api(:DELETE, path,
data, status_code, headers = @api_client.call_api(:DELETE, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: StoreApi#delete_order"
Configuration.logger.debug "API called: StoreApi#delete_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return nil
return data, status_code, headers
end
end
end

View File

@ -14,6 +14,16 @@ module Petstore
# @option opts [User] :body Created user object
# @return [nil]
def create_user(opts = {})
create_user_with_http_info(opts)
return nil
end
# Create user
# This can only be done by the logged in user.
# @param [Hash] opts the optional parameters
# @option opts [User] :body Created user object
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def create_user_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#create_user ..."
end
@ -43,16 +53,16 @@ module Petstore
auth_names = []
@api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: UserApi#create_user"
Configuration.logger.debug "API called: UserApi#create_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return nil
return data, status_code, headers
end
# Creates list of users with given input array
@ -61,6 +71,16 @@ module Petstore
# @option opts [Array<User>] :body List of user object
# @return [nil]
def create_users_with_array_input(opts = {})
create_users_with_array_input_with_http_info(opts)
return nil
end
# Creates list of users with given input array
#
# @param [Hash] opts the optional parameters
# @option opts [Array<User>] :body List of user object
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def create_users_with_array_input_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#create_users_with_array_input ..."
end
@ -90,16 +110,16 @@ module Petstore
auth_names = []
@api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: UserApi#create_users_with_array_input"
Configuration.logger.debug "API called: UserApi#create_users_with_array_input\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return nil
return data, status_code, headers
end
# Creates list of users with given input array
@ -108,6 +128,16 @@ module Petstore
# @option opts [Array<User>] :body List of user object
# @return [nil]
def create_users_with_list_input(opts = {})
create_users_with_list_input_with_http_info(opts)
return nil
end
# Creates list of users with given input array
#
# @param [Hash] opts the optional parameters
# @option opts [Array<User>] :body List of user object
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def create_users_with_list_input_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#create_users_with_list_input ..."
end
@ -137,16 +167,16 @@ module Petstore
auth_names = []
@api_client.call_api(:POST, path,
data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: UserApi#create_users_with_list_input"
Configuration.logger.debug "API called: UserApi#create_users_with_list_input\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return nil
return data, status_code, headers
end
# Logs user into the system
@ -156,6 +186,17 @@ module Petstore
# @option opts [String] :password The password for login in clear text
# @return [String]
def login_user(opts = {})
data, status_code, headers = login_user_with_http_info(opts)
return data
end
# Logs user into the system
#
# @param [Hash] opts the optional parameters
# @option opts [String] :username The user name for login
# @option opts [String] :password The password for login in clear text
# @return [Array<(String, Fixnum, Hash)>] String data, response status code and response headers
def login_user_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#login_user ..."
end
@ -187,7 +228,7 @@ module Petstore
auth_names = []
result = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -195,9 +236,9 @@ module Petstore
:auth_names => auth_names,
:return_type => 'String')
if Configuration.debugging
Configuration.logger.debug "API called: UserApi#login_user. Result: #{result.inspect}"
Configuration.logger.debug "API called: UserApi#login_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return result
return data, status_code, headers
end
# Logs out current logged in user session
@ -205,6 +246,15 @@ module Petstore
# @param [Hash] opts the optional parameters
# @return [nil]
def logout_user(opts = {})
logout_user_with_http_info(opts)
return nil
end
# Logs out current logged in user session
#
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def logout_user_with_http_info(opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#logout_user ..."
end
@ -234,16 +284,16 @@ module Petstore
auth_names = []
@api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: UserApi#logout_user"
Configuration.logger.debug "API called: UserApi#logout_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return nil
return data, status_code, headers
end
# Get user by user name
@ -252,6 +302,16 @@ module Petstore
# @param [Hash] opts the optional parameters
# @return [User]
def get_user_by_name(username, opts = {})
data, status_code, headers = get_user_by_name_with_http_info(username, opts)
return data
end
# Get user by user name
#
# @param username The name that needs to be fetched. Use user1 for testing.
# @param [Hash] opts the optional parameters
# @return [Array<(User, Fixnum, Hash)>] User data, response status code and response headers
def get_user_by_name_with_http_info(username, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#get_user_by_name ..."
end
@ -284,7 +344,7 @@ module Petstore
auth_names = []
result = @api_client.call_api(:GET, path,
data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
@ -292,9 +352,9 @@ module Petstore
:auth_names => auth_names,
:return_type => 'User')
if Configuration.debugging
Configuration.logger.debug "API called: UserApi#get_user_by_name. Result: #{result.inspect}"
Configuration.logger.debug "API called: UserApi#get_user_by_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return result
return data, status_code, headers
end
# Updated user
@ -304,6 +364,17 @@ module Petstore
# @option opts [User] :body Updated user object
# @return [nil]
def update_user(username, opts = {})
update_user_with_http_info(username, opts)
return nil
end
# Updated user
# This can only be done by the logged in user.
# @param username name that need to be deleted
# @param [Hash] opts the optional parameters
# @option opts [User] :body Updated user object
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def update_user_with_http_info(username, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#update_user ..."
end
@ -336,16 +407,16 @@ module Petstore
auth_names = []
@api_client.call_api(:PUT, path,
data, status_code, headers = @api_client.call_api(:PUT, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: UserApi#update_user"
Configuration.logger.debug "API called: UserApi#update_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return nil
return data, status_code, headers
end
# Delete user
@ -354,6 +425,16 @@ module Petstore
# @param [Hash] opts the optional parameters
# @return [nil]
def delete_user(username, opts = {})
delete_user_with_http_info(username, opts)
return nil
end
# Delete user
# This can only be done by the logged in user.
# @param username The name that needs to be deleted
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_user_with_http_info(username, opts = {})
if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#delete_user ..."
end
@ -386,16 +467,16 @@ module Petstore
auth_names = []
@api_client.call_api(:DELETE, path,
data, status_code, headers = @api_client.call_api(:DELETE, path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if Configuration.debugging
Configuration.logger.debug "API called: UserApi#delete_user"
Configuration.logger.debug "API called: UserApi#delete_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return nil
return data, status_code, headers
end
end
end

View File

@ -15,9 +15,6 @@ module Petstore
# @return [Hash]
attr_accessor :default_headers
# Stores the HTTP response from the last API call using this API client.
attr_accessor :last_response
def initialize(host = nil)
@host = host || Configuration.base_url
@format = 'json'
@ -28,13 +25,14 @@ module Petstore
}
end
# Call an API with given options.
#
# @return [Array<(Object, Fixnum, Hash)>] an array of 3 elements:
# the data deserialized from response body (could be nil), response status code and response headers.
def call_api(http_method, path, opts = {})
request = build_request(http_method, path, opts)
response = request.run
# record as last response
@last_response = response
if Configuration.debugging
Configuration.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
end
@ -47,10 +45,11 @@ module Petstore
end
if opts[:return_type]
deserialize(response, opts[:return_type])
data = deserialize(response, opts[:return_type])
else
nil
data = nil
end
return data, response.code, response.headers
end
def build_request(http_method, path, opts = {})

View File

@ -50,6 +50,17 @@ describe "Pet" do
pet.category.name.should == "category test"
end
it "should fetch a pet object with http info" do
pet, status_code, headers = @pet_api.get_pet_by_id_with_http_info(10002)
status_code.should == 200
headers['Content-Type'].should == 'application/json'
pet.should be_a(Petstore::Pet)
pet.id.should == 10002
pet.name.should == "RUBY UNIT TESTING"
pet.tags[0].name.should == "tag test"
pet.category.name.should == "category test"
end
it "should not find a pet that does not exist" do
begin
@pet_api.get_pet_by_id(-10002)