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) [![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) [![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 ## Overview
This is the swagger codegen project, which allows generation of client libraries automatically from a Swagger-compliant server. 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.SupportingFile;
import io.swagger.codegen.CodegenProperty; import io.swagger.codegen.CodegenProperty;
import io.swagger.codegen.CodegenModel; import io.swagger.codegen.CodegenModel;
import io.swagger.models.properties.ArrayProperty; import io.swagger.models.properties.*;
import io.swagger.models.properties.MapProperty;
import io.swagger.models.properties.Property;
import io.swagger.codegen.CliOption; import io.swagger.codegen.CliOption;
import java.io.File; import java.io.File;
@ -300,4 +298,51 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
} }
return objs; 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())) { if ("okhttp-gson".equals(getLibrary())) {
// the "okhttp-gson" library template requires "ApiCallback.mustache" for async call // the "okhttp-gson" library template requires "ApiCallback.mustache" for async call
supportingFiles.add(new SupportingFile("ApiCallback.mustache", invokerFolder, "ApiCallback.java")); 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("ProgressRequestBody.mustache", invokerFolder, "ProgressRequestBody.java"));
supportingFiles.add(new SupportingFile("ProgressResponseBody.mustache", invokerFolder, "ProgressResponseBody.java")); supportingFiles.add(new SupportingFile("ProgressResponseBody.mustache", invokerFolder, "ProgressResponseBody.java"));
// "build.sbt" is for development with SBT // "build.sbt" is for development with SBT

View File

@ -104,9 +104,6 @@ public class ApiClient {
private Map<String, Authentication> authentications; private Map<String, Authentication> authentications;
private int statusCode;
private Map<String, List<String>> responseHeaders;
private DateFormat dateFormat; private DateFormat dateFormat;
private DateFormat datetimeFormat; private DateFormat datetimeFormat;
private boolean lenientDatetimeFormat; private boolean lenientDatetimeFormat;
@ -177,24 +174,6 @@ public class ApiClient {
return this; 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() { public boolean isVerifyingSsl() {
return verifyingSsl; return verifyingSsl;
} }
@ -618,6 +597,8 @@ public class ApiClient {
* @param response HTTP response * @param response HTTP response
* @param returnType The type of the Java object * @param returnType The type of the Java object
* @return The deserialized 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 { public <T> T deserialize(Response response, Type returnType) throws ApiException {
if (response == null || returnType == null) if (response == null || returnType == null)
@ -666,6 +647,7 @@ public class ApiClient {
* @param obj The Java object * @param obj The Java object
* @param contentType The request Content-Type * @param contentType The request Content-Type
* @return The serialized string * @return The serialized string
* @throws ApiException If fail to serialize the given object
*/ */
public String serialize(Object obj, String contentType) throws ApiException { public String serialize(Object obj, String contentType) throws ApiException {
if (contentType.startsWith("application/json")) { if (contentType.startsWith("application/json")) {
@ -680,6 +662,7 @@ public class ApiClient {
/** /**
* Download file from the given response. * 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 { public File downloadFileFromResponse(Response response) throws ApiException {
try { try {
@ -731,7 +714,7 @@ public class ApiClient {
/** /**
* @see #execute(Call, Type) * @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); return execute(call, null);
} }
@ -740,14 +723,16 @@ public class ApiClient {
* *
* @param returnType The return type used to deserialize HTTP response body * @param returnType The return type used to deserialize HTTP response body
* @param <T> The return type corresponding to (same with) returnType * @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 { try {
Response response = call.execute(); Response response = call.execute();
this.statusCode = response.code(); T data = handleResponse(response, returnType);
this.responseHeaders = response.headers().toMultimap(); return new ApiResponse<T>(response.code(), response.headers().toMultimap(), data);
return handleResponse(response, returnType);
} catch (IOException e) { } catch (IOException e) {
throw new ApiException(e); throw new ApiException(e);
} }
@ -756,7 +741,7 @@ public class ApiClient {
/** /**
* #see executeAsync(Call, Type, ApiCallback) * #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); 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 { public <T> T handleResponse(Response response, Type returnType) throws ApiException {
if (response.isSuccessful()) { if (response.isSuccessful()) {
if (returnType == null || response.code() == 204) { if (returnType == null || response.code() == 204) {
@ -820,6 +811,7 @@ public class ApiClient {
* @param formParams The form parameters * @param formParams The form parameters
* @param authNames The authentications to apply * @param authNames The authentications to apply
* @return The HTTP call * @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 { 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); 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}}.ApiCallback;
import {{invokerPackage}}.ApiClient; import {{invokerPackage}}.ApiClient;
import {{invokerPackage}}.ApiException; import {{invokerPackage}}.ApiException;
import {{invokerPackage}}.ApiResponse;
import {{invokerPackage}}.Configuration; import {{invokerPackage}}.Configuration;
import {{invokerPackage}}.Pair; import {{invokerPackage}}.Pair;
import {{invokerPackage}}.ProgressRequestBody; import {{invokerPackage}}.ProgressRequestBody;
@ -104,11 +105,24 @@ public class {{classname}} {
* {{notes}}{{#allParams}} * {{notes}}{{#allParams}}
* @param {{paramName}} {{description}}{{/allParams}}{{#returnType}} * @param {{paramName}} {{description}}{{/allParams}}{{#returnType}}
* @return {{{returnType}}}{{/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 { 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); Call {{localVariablePrefix}}call = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}null, null);
{{#returnType}}Type {{localVariablePrefix}}returnType = new TypeToken<{{{returnType}}}>(){}.getType(); {{#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 {{paramName}} {{description}}{{/allParams}}
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { 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)])) (map (fn [[k v]] [k (normalize-param v)]))
(into {}))) (into {})))
(defn json-mime? [mime] (defn json-mime?
"Check if the given MIME is a standard JSON MIME or :json." "Check if the given MIME is a standard JSON MIME or :json."
[mime]
(if mime (if mime
(or (= :json mime) (or (= :json mime)
(re-matches #"application/json(;.*)?" (name 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, "Choose a MIME from the given MIMEs with JSON preferred,
i.e. return JSON if included, otherwise return the first one." i.e. return JSON if included, otherwise return the first one."
[mimes]
(-> (filter json-mime? mimes) (-> (filter json-mime? mimes)
first first
(or (first mimes)))) (or (first mimes))))

View File

@ -18,6 +18,15 @@ namespace {{packageName}}.Model
[DataContract] [DataContract]
public class {{classname}} : IEquatable<{{classname}}>{{#parent}}, {{{parent}}}{{/parent}} 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}} {{#vars}}
/// <summary> /// <summary>
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}} /// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{{description}}}{{/description}}

View File

@ -160,7 +160,7 @@ class ApiClient
if ($this->config->getCurlTimeout() != 0) { if ($this->config->getCurlTimeout() != 0) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout()); 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_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
@ -216,7 +216,7 @@ class ApiClient
// Make the request // Make the request
$response = curl_exec($curl); $response = curl_exec($curl);
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE); $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); $http_body = substr($response, $http_header_size);
$response_info = curl_getinfo($curl); $response_info = curl_getinfo($curl);
@ -231,7 +231,7 @@ class ApiClient
} elseif ($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 // return raw body if response is a file
if ($responseType == '\SplFileObject') { if ($responseType == '\SplFileObject') {
return array($http_body, $http_header); return array($http_body, $response_info['http_code'], $http_header);
} }
$data = json_decode($http_body); $data = json_decode($http_body);
@ -249,7 +249,7 @@ class ApiClient
$response_info['http_code'], $http_header, $data $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 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

@ -198,7 +198,7 @@ class ObjectSerializer
$deserialized = $data; $deserialized = $data;
} elseif ($class === '\SplFileObject') { } elseif ($class === '\SplFileObject') {
// determine file name // 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]; $filename = Configuration::getDefaultConfiguration()->getTempFolderPath().$match[1];
} else { } else {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); $filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');

View File

@ -92,7 +92,7 @@ use \{{invokerPackage}}\ObjectSerializer;
{{#operation}} {{#operation}}
/** /**
* {{{nickname}}} * {{{operationId}}}
* *
* {{{summary}}} * {{{summary}}}
* *
@ -100,12 +100,28 @@ use \{{invokerPackage}}\ObjectSerializer;
{{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
* @throws \{{invokerPackage}}\ApiException on non-2xx response * @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}} {{#allParams}}{{#required}}
// verify the required parameter '{{paramName}}' is set // verify the required parameter '{{paramName}}' is set
if (${{paramName}} === null) { 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}} }{{/required}}{{/allParams}}
// parse inputs // parse inputs
@ -180,19 +196,20 @@ use \{{invokerPackage}}\ObjectSerializer;
}{{/isOAuth}} }{{/isOAuth}}
{{/authMethods}} {{/authMethods}}
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams{{#returnType}}, '{{returnType}}'{{/returnType}} $headerParams{{#returnType}}, '{{returnType}}'{{/returnType}}
); );
{{#returnType}} {{#returnType}}
if (!$response) { 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}} {{/returnType}}
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { {{#responses}}{{#dataType}} switch ($e->getCode()) { {{#responses}}{{#dataType}}
@ -204,9 +221,6 @@ use \{{invokerPackage}}\ObjectSerializer;
throw $e; throw $e;
} }
{{#returnType}}
return null;
{{/returnType}}
} }
{{/operation}} {{/operation}}
} }

View File

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

View File

@ -17,6 +17,17 @@ module {{moduleName}}
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}} {{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}
{{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}] {{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}]
def {{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: {{classname}}#{{operationId}} ..." Configuration.logger.debug "Calling API: {{classname}}#{{operationId}} ..."
end end
@ -63,26 +74,17 @@ module {{moduleName}}
{{/bodyParam}} {{/bodyParam}}
auth_names = [{{#authMethods}}'{{name}}'{{#hasMore}}, {{/hasMore}}{{/authMethods}}] 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, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
:body => post_body, :body => post_body,
:auth_names => auth_names, :auth_names => auth_names{{#returnType}},
:return_type => '{{{returnType}}}') :return_type => '{{{returnType}}}'{{/returnType}})
if Configuration.debugging 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 end
return result{{/returnType}}{{^returnType}}@api_client.call_api(:{{httpMethod}}, path, return data, status_code, headers
: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}}
end end
{{/operation}} {{/operation}}
end end

View File

@ -15,9 +15,6 @@ module {{moduleName}}
# @return [Hash] # @return [Hash]
attr_accessor :default_headers 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) def initialize(host = nil)
@host = host || Configuration.base_url @host = host || Configuration.base_url
@format = 'json' @format = 'json'
@ -28,13 +25,14 @@ module {{moduleName}}
} }
end 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 = {}) def call_api(http_method, path, opts = {})
request = build_request(http_method, path, opts) request = build_request(http_method, path, opts)
response = request.run response = request.run
# record as last response
@last_response = response
if Configuration.debugging if Configuration.debugging
Configuration.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n" Configuration.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
end end
@ -47,10 +45,11 @@ module {{moduleName}}
end end
if opts[:return_type] if opts[:return_type]
deserialize(response, opts[:return_type]) data = deserialize(response, opts[:return_type])
else else
nil data = nil
end end
return data, response.code, response.headers
end end
def build_request(http_method, path, opts = {}) def build_request(http_method, path, opts = {})

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,30 +1,11 @@
<Properties StartupItem="SwaggerClientTest.csproj"> <Properties StartupItem="SwaggerClientTest.csproj">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" /> <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> <Files>
<File FileName="TestConfiguration.cs" Line="17" Column="33" /> <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="81" Column="17" />
<File FileName="TestPet.cs" Line="87" Column="4" /> <File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs" Line="12" Column="18" />
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs" Line="1" Column="1" />
<File FileName="TestApiClient.cs" Line="22" Column="4" />
</Files> </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.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints> <MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore /> <BreakpointStore />

View File

@ -104,9 +104,6 @@ public class ApiClient {
private Map<String, Authentication> authentications; private Map<String, Authentication> authentications;
private int statusCode;
private Map<String, List<String>> responseHeaders;
private DateFormat dateFormat; private DateFormat dateFormat;
private DateFormat datetimeFormat; private DateFormat datetimeFormat;
private boolean lenientDatetimeFormat; private boolean lenientDatetimeFormat;
@ -143,8 +140,8 @@ public class ApiClient {
// Setup authentications (key: authentication name, value: authentication). // Setup authentications (key: authentication name, value: authentication).
authentications = new HashMap<String, Authentication>(); authentications = new HashMap<String, Authentication>();
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
authentications.put("petstore_auth", new OAuth()); authentications.put("petstore_auth", new OAuth());
authentications.put("api_key", new ApiKeyAuth("header", "api_key"));
// Prevent the authentications from being modified. // Prevent the authentications from being modified.
authentications = Collections.unmodifiableMap(authentications); authentications = Collections.unmodifiableMap(authentications);
} }
@ -176,24 +173,6 @@ public class ApiClient {
return this; 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() { public boolean isVerifyingSsl() {
return verifyingSsl; return verifyingSsl;
} }
@ -617,6 +596,8 @@ public class ApiClient {
* @param response HTTP response * @param response HTTP response
* @param returnType The type of the Java object * @param returnType The type of the Java object
* @return The deserialized 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 { public <T> T deserialize(Response response, Type returnType) throws ApiException {
if (response == null || returnType == null) if (response == null || returnType == null)
@ -665,6 +646,7 @@ public class ApiClient {
* @param obj The Java object * @param obj The Java object
* @param contentType The request Content-Type * @param contentType The request Content-Type
* @return The serialized string * @return The serialized string
* @throws ApiException If fail to serialize the given object
*/ */
public String serialize(Object obj, String contentType) throws ApiException { public String serialize(Object obj, String contentType) throws ApiException {
if (contentType.startsWith("application/json")) { if (contentType.startsWith("application/json")) {
@ -679,6 +661,7 @@ public class ApiClient {
/** /**
* Download file from the given response. * 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 { public File downloadFileFromResponse(Response response) throws ApiException {
try { try {
@ -730,7 +713,7 @@ public class ApiClient {
/** /**
* @see #execute(Call, Type) * @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); return execute(call, null);
} }
@ -739,14 +722,16 @@ public class ApiClient {
* *
* @param returnType The return type used to deserialize HTTP response body * @param returnType The return type used to deserialize HTTP response body
* @param <T> The return type corresponding to (same with) returnType * @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 { try {
Response response = call.execute(); Response response = call.execute();
this.statusCode = response.code(); T data = handleResponse(response, returnType);
this.responseHeaders = response.headers().toMultimap(); return new ApiResponse<T>(response.code(), response.headers().toMultimap(), data);
return handleResponse(response, returnType);
} catch (IOException e) { } catch (IOException e) {
throw new ApiException(e); throw new ApiException(e);
} }
@ -755,7 +740,7 @@ public class ApiClient {
/** /**
* #see executeAsync(Call, Type, ApiCallback) * #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); 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 { public <T> T handleResponse(Response response, Type returnType) throws ApiException {
if (response.isSuccessful()) { if (response.isSuccessful()) {
if (returnType == null || response.code() == 204) { if (returnType == null || response.code() == 204) {
@ -819,6 +810,7 @@ public class ApiClient {
* @param formParams The form parameters * @param formParams The form parameters
* @param authNames The authentications to apply * @param authNames The authentications to apply
* @return The HTTP call * @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 { 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); updateParamsForAuth(authNames, queryParams, headerParams);

View File

@ -3,7 +3,7 @@ package io.swagger.client;
import java.util.Map; import java.util.Map;
import java.util.List; 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 { public class ApiException extends Exception {
private int code = 0; private int code = 0;
private Map<String, List<String>> responseHeaders = null; 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; 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 { public class Configuration {
private static ApiClient defaultApiClient = new ApiClient(); private static ApiClient defaultApiClient = new ApiClient();

View File

@ -1,6 +1,6 @@
package io.swagger.client; 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 { public class Pair {
private String name = ""; private String name = "";
private String value = ""; private String value = "";

View File

@ -1,6 +1,6 @@
package io.swagger.client; 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 { public class StringUtil {
/** /**
* Check if the given array contains the given value (with case-insensitive comparison). * Check if the given array contains the given value (with case-insensitive comparison).

View File

@ -3,6 +3,7 @@ package io.swagger.client.api;
import io.swagger.client.ApiCallback; import io.swagger.client.ApiCallback;
import io.swagger.client.ApiClient; import io.swagger.client.ApiClient;
import io.swagger.client.ApiException; import io.swagger.client.ApiException;
import io.swagger.client.ApiResponse;
import io.swagger.client.Configuration; import io.swagger.client.Configuration;
import io.swagger.client.Pair; import io.swagger.client.Pair;
import io.swagger.client.ProgressRequestBody; import io.swagger.client.ProgressRequestBody;
@ -88,10 +89,22 @@ public class PetApi {
* Update an existing pet * Update an existing pet
* *
* @param body Pet object that needs to be added 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 updatePet(Pet body) throws ApiException { 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); Call call = updatePetCall(body, null, null);
apiClient.execute(call); return apiClient.execute(call);
} }
/** /**
@ -100,6 +113,7 @@ public class PetApi {
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call updatePetAsync(Pet body, final ApiCallback<Void> callback) throws ApiException {
@ -173,10 +187,22 @@ public class PetApi {
* Add a new pet to the store * Add a new pet to the store
* *
* @param body Pet object that needs to be added 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 { 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); Call call = addPetCall(body, null, null);
apiClient.execute(call); return apiClient.execute(call);
} }
/** /**
@ -185,6 +211,7 @@ public class PetApi {
* @param body Pet object that needs to be added to the store * @param body Pet object that needs to be added to the store
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call addPetAsync(Pet body, final ApiCallback<Void> callback) throws ApiException {
@ -261,8 +288,21 @@ public class PetApi {
* Multiple status values can be provided with comma seperated strings * Multiple status values can be provided with comma seperated strings
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
* @return List<Pet> * @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 { 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); Call call = findPetsByStatusCall(status, null, null);
Type returnType = new TypeToken<List<Pet>>(){}.getType(); Type returnType = new TypeToken<List<Pet>>(){}.getType();
return apiClient.execute(call, returnType); return apiClient.execute(call, returnType);
@ -274,6 +314,7 @@ public class PetApi {
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call findPetsByStatusAsync(List<String> status, final ApiCallback<List<Pet>> callback) throws ApiException {
@ -351,8 +392,21 @@ public class PetApi {
* Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
* @param tags Tags to filter by * @param tags Tags to filter by
* @return List<Pet> * @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 { 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); Call call = findPetsByTagsCall(tags, null, null);
Type returnType = new TypeToken<List<Pet>>(){}.getType(); Type returnType = new TypeToken<List<Pet>>(){}.getType();
return apiClient.execute(call, returnType); return apiClient.execute(call, returnType);
@ -364,6 +418,7 @@ public class PetApi {
* @param tags Tags to filter by * @param tags Tags to filter by
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call findPetsByTagsAsync(List<String> tags, final ApiCallback<List<Pet>> callback) throws ApiException {
@ -445,8 +500,21 @@ public class PetApi {
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions * 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 * @param petId ID of pet that needs to be fetched
* @return Pet * @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 { 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); Call call = getPetByIdCall(petId, null, null);
Type returnType = new TypeToken<Pet>(){}.getType(); Type returnType = new TypeToken<Pet>(){}.getType();
return apiClient.execute(call, returnType); return apiClient.execute(call, returnType);
@ -458,6 +526,7 @@ public class PetApi {
* @param petId ID of pet that needs to be fetched * @param petId ID of pet that needs to be fetched
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call getPetByIdAsync(Long petId, final ApiCallback<Pet> callback) throws ApiException {
@ -544,10 +613,24 @@ public class PetApi {
* @param petId ID of pet that needs to be updated * @param petId ID of pet that needs to be updated
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status 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 { public void updatePetWithForm(String petId, String name, String status) throws ApiException {
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); Call call = updatePetWithFormCall(petId, name, status, null, null);
apiClient.execute(call); return apiClient.execute(call);
} }
/** /**
@ -558,6 +641,7 @@ public class PetApi {
* @param status Updated status of the pet * @param status Updated status of the pet
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call updatePetWithFormAsync(String petId, String name, String status, final ApiCallback<Void> callback) throws ApiException {
@ -640,10 +724,23 @@ public class PetApi {
* *
* @param petId Pet id to delete * @param petId Pet id to delete
* @param apiKey * @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 { public void deletePet(Long petId, String apiKey) throws ApiException {
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); Call call = deletePetCall(petId, apiKey, null, null);
apiClient.execute(call); return apiClient.execute(call);
} }
/** /**
@ -653,6 +750,7 @@ public class PetApi {
* @param apiKey * @param apiKey
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call deletePetAsync(Long petId, String apiKey, final ApiCallback<Void> callback) throws ApiException {
@ -738,10 +836,24 @@ public class PetApi {
* @param petId ID of pet to update * @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server * @param additionalMetadata Additional data to pass to server
* @param file file to upload * @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 { public void uploadFile(Long petId, String additionalMetadata, File file) throws ApiException {
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); Call call = uploadFileCall(petId, additionalMetadata, file, null, null);
apiClient.execute(call); return apiClient.execute(call);
} }
/** /**
@ -752,6 +864,7 @@ public class PetApi {
* @param file file to upload * @param file file to upload
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call uploadFileAsync(Long petId, String additionalMetadata, File file, final ApiCallback<Void> callback) throws ApiException {

View File

@ -3,6 +3,7 @@ package io.swagger.client.api;
import io.swagger.client.ApiCallback; import io.swagger.client.ApiCallback;
import io.swagger.client.ApiClient; import io.swagger.client.ApiClient;
import io.swagger.client.ApiException; import io.swagger.client.ApiException;
import io.swagger.client.ApiResponse;
import io.swagger.client.Configuration; import io.swagger.client.Configuration;
import io.swagger.client.Pair; import io.swagger.client.Pair;
import io.swagger.client.ProgressRequestBody; import io.swagger.client.ProgressRequestBody;
@ -88,8 +89,20 @@ public class StoreApi {
* Returns pet inventories by status * Returns pet inventories by status
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
* @return Map<String, Integer> * @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 { public Map<String, Integer> getInventory() throws ApiException {
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); Call call = getInventoryCall(null, null);
Type returnType = new TypeToken<Map<String, Integer>>(){}.getType(); Type returnType = new TypeToken<Map<String, Integer>>(){}.getType();
return apiClient.execute(call, returnType); return apiClient.execute(call, returnType);
@ -100,6 +113,7 @@ public class StoreApi {
* Returns a map of status codes to quantities * Returns a map of status codes to quantities
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call getInventoryAsync(final ApiCallback<Map<String, Integer>> callback) throws ApiException {
@ -175,8 +189,21 @@ public class StoreApi {
* *
* @param body order placed for purchasing the pet * @param body order placed for purchasing the pet
* @return Order * @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 { 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); Call call = placeOrderCall(body, null, null);
Type returnType = new TypeToken<Order>(){}.getType(); Type returnType = new TypeToken<Order>(){}.getType();
return apiClient.execute(call, returnType); return apiClient.execute(call, returnType);
@ -188,6 +215,7 @@ public class StoreApi {
* @param body order placed for purchasing the pet * @param body order placed for purchasing the pet
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call placeOrderAsync(Order body, final ApiCallback<Order> callback) throws ApiException {
@ -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 * 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 * @param orderId ID of pet that needs to be fetched
* @return Order * @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 { 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); Call call = getOrderByIdCall(orderId, null, null);
Type returnType = new TypeToken<Order>(){}.getType(); Type returnType = new TypeToken<Order>(){}.getType();
return apiClient.execute(call, returnType); return apiClient.execute(call, returnType);
@ -282,6 +323,7 @@ public class StoreApi {
* @param orderId ID of pet that needs to be fetched * @param orderId ID of pet that needs to be fetched
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call getOrderByIdAsync(String orderId, final ApiCallback<Order> callback) throws ApiException {
@ -362,10 +404,22 @@ public class StoreApi {
* Delete purchase order by ID * Delete purchase order by ID
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors * 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 * @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 { 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); Call call = deleteOrderCall(orderId, null, null);
apiClient.execute(call); return apiClient.execute(call);
} }
/** /**
@ -374,6 +428,7 @@ public class StoreApi {
* @param orderId ID of the order that needs to be deleted * @param orderId ID of the order that needs to be deleted
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call deleteOrderAsync(String orderId, final ApiCallback<Void> callback) throws ApiException {

View File

@ -3,6 +3,7 @@ package io.swagger.client.api;
import io.swagger.client.ApiCallback; import io.swagger.client.ApiCallback;
import io.swagger.client.ApiClient; import io.swagger.client.ApiClient;
import io.swagger.client.ApiException; import io.swagger.client.ApiException;
import io.swagger.client.ApiResponse;
import io.swagger.client.Configuration; import io.swagger.client.Configuration;
import io.swagger.client.Pair; import io.swagger.client.Pair;
import io.swagger.client.ProgressRequestBody; import io.swagger.client.ProgressRequestBody;
@ -88,10 +89,22 @@ public class UserApi {
* Create user * Create user
* This can only be done by the logged in user. * This can only be done by the logged in user.
* @param body Created user object * @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 { 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); Call call = createUserCall(body, null, null);
apiClient.execute(call); return apiClient.execute(call);
} }
/** /**
@ -100,6 +113,7 @@ public class UserApi {
* @param body Created user object * @param body Created user object
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call createUserAsync(User body, final ApiCallback<Void> callback) throws ApiException {
@ -173,10 +187,22 @@ public class UserApi {
* Creates list of users with given input array * Creates list of users with given input array
* *
* @param body List of user object * @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 { 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); Call call = createUsersWithArrayInputCall(body, null, null);
apiClient.execute(call); return apiClient.execute(call);
} }
/** /**
@ -185,6 +211,7 @@ public class UserApi {
* @param body List of user object * @param body List of user object
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call createUsersWithArrayInputAsync(List<User> body, final ApiCallback<Void> callback) throws ApiException {
@ -258,10 +285,22 @@ public class UserApi {
* Creates list of users with given input array * Creates list of users with given input array
* *
* @param body List of user object * @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 { 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); Call call = createUsersWithListInputCall(body, null, null);
apiClient.execute(call); return apiClient.execute(call);
} }
/** /**
@ -270,6 +309,7 @@ public class UserApi {
* @param body List of user object * @param body List of user object
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call createUsersWithListInputAsync(List<User> body, final ApiCallback<Void> callback) throws ApiException {
@ -349,8 +389,22 @@ public class UserApi {
* @param username The user name for login * @param username The user name for login
* @param password The password for login in clear text * @param password The password for login in clear text
* @return String * @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 { public String loginUser(String username, String password) throws ApiException {
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); Call call = loginUserCall(username, password, null, null);
Type returnType = new TypeToken<String>(){}.getType(); Type returnType = new TypeToken<String>(){}.getType();
return apiClient.execute(call, returnType); return apiClient.execute(call, returnType);
@ -363,6 +417,7 @@ public class UserApi {
* @param password The password for login in clear text * @param password The password for login in clear text
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call loginUserAsync(String username, String password, final ApiCallback<String> callback) throws ApiException {
@ -436,10 +491,21 @@ public class UserApi {
/** /**
* Logs out current logged in user session * 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 { public void logoutUser() throws ApiException {
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); Call call = logoutUserCall(null, null);
apiClient.execute(call); return apiClient.execute(call);
} }
/** /**
@ -447,6 +513,7 @@ public class UserApi {
* *
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call logoutUserAsync(final ApiCallback<Void> callback) throws ApiException {
@ -527,8 +594,21 @@ public class UserApi {
* *
* @param username The name that needs to be fetched. Use user1 for testing. * @param username The name that needs to be fetched. Use user1 for testing.
* @return User * @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 { 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); Call call = getUserByNameCall(username, null, null);
Type returnType = new TypeToken<User>(){}.getType(); Type returnType = new TypeToken<User>(){}.getType();
return apiClient.execute(call, returnType); return apiClient.execute(call, returnType);
@ -540,6 +620,7 @@ public class UserApi {
* @param username The name that needs to be fetched. Use user1 for testing. * @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 * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call getUserByNameAsync(String username, final ApiCallback<User> callback) throws ApiException {
@ -621,10 +702,23 @@ public class UserApi {
* This can only be done by the logged in user. * This can only be done by the logged in user.
* @param username name that need to be deleted * @param username name that need to be deleted
* @param body Updated user object * @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 { public void updateUser(String username, User body) throws ApiException {
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); Call call = updateUserCall(username, body, null, null);
apiClient.execute(call); return apiClient.execute(call);
} }
/** /**
@ -634,6 +728,7 @@ public class UserApi {
* @param body Updated user object * @param body Updated user object
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call updateUserAsync(String username, User body, final ApiCallback<Void> callback) throws ApiException {
@ -713,10 +808,22 @@ public class UserApi {
* Delete user * Delete user
* This can only be done by the logged in user. * This can only be done by the logged in user.
* @param username The name that needs to be deleted * @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 { 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); Call call = deleteUserCall(username, null, null);
apiClient.execute(call); return apiClient.execute(call);
} }
/** /**
@ -725,6 +832,7 @@ public class UserApi {
* @param username The name that needs to be deleted * @param username The name that needs to be deleted
* @param callback The callback to be executed when the API call finishes * @param callback The callback to be executed when the API call finishes
* @return The request call * @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 { public Call deleteUserAsync(String username, final ApiCallback<Void> callback) throws ApiException {

View File

@ -5,7 +5,7 @@ import io.swagger.client.Pair;
import java.util.Map; import java.util.Map;
import java.util.List; 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 { public class ApiKeyAuth implements Authentication {
private final String location; private final String location;
private final String paramName; private final String paramName;

View File

@ -5,7 +5,7 @@ import io.swagger.client.Pair;
import java.util.Map; import java.util.Map;
import java.util.List; 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 { public interface Authentication {
/** Apply authentication settings to header and query params. */ /** Apply authentication settings to header and query params. */
void applyToParams(List<Pair> queryParams, Map<String, String> headerParams); 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.Map;
import java.util.List; 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 { public class OAuth implements Authentication {
private String accessToken; private String accessToken;

View File

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

View File

@ -1,10 +1,6 @@
package io.swagger.petstore.test; package io.swagger.petstore.test;
import io.swagger.client.ApiClient; import io.swagger.client.*;
import io.swagger.client.ApiException;
import io.swagger.client.Configuration;
import io.swagger.client.ApiCallback;
import io.swagger.client.api.*; import io.swagger.client.api.*;
import io.swagger.client.auth.*; import io.swagger.client.auth.*;
import io.swagger.client.model.*; import io.swagger.client.model.*;
@ -71,6 +67,21 @@ public class PetApiTest {
assertEquals(fetched.getCategory().getName(), pet.getCategory().getName()); 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 @Test
public void testCreateAndGetPetAsync() throws Exception { public void testCreateAndGetPetAsync() throws Exception {
Pet pet = createRandomPet(); Pet pet = createRandomPet();

View File

@ -101,6 +101,22 @@ class PetApi
* @throws \Swagger\Client\ApiException on non-2xx response * @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)
{ {
@ -141,21 +157,21 @@ class PetApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
throw $e; throw $e;
} }
} }
/** /**
@ -168,6 +184,22 @@ class PetApi
* @throws \Swagger\Client\ApiException on non-2xx response * @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)
{ {
@ -208,21 +240,21 @@ class PetApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
throw $e; throw $e;
} }
} }
/** /**
@ -235,6 +267,22 @@ class PetApi
* @throws \Swagger\Client\ApiException on non-2xx response * @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)
{ {
@ -274,19 +322,18 @@ class PetApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Pet[]' $headerParams, '\Swagger\Client\Model\Pet[]'
); );
if (!$response) { 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) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
@ -298,9 +345,6 @@ class PetApi
throw $e; throw $e;
} }
return null;
} }
/** /**
@ -313,6 +357,22 @@ class PetApi
* @throws \Swagger\Client\ApiException on non-2xx response * @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)
{ {
@ -352,19 +412,18 @@ class PetApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Pet[]' $headerParams, '\Swagger\Client\Model\Pet[]'
); );
if (!$response) { 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) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
@ -376,9 +435,6 @@ class PetApi
throw $e; throw $e;
} }
return null;
} }
/** /**
@ -391,6 +447,22 @@ class PetApi
* @throws \Swagger\Client\ApiException on non-2xx response * @throws \Swagger\Client\ApiException on non-2xx response
*/ */
public function getPetById($pet_id) 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 // verify the required parameter 'pet_id' is set
@ -440,19 +512,18 @@ class PetApi
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Pet' $headerParams, '\Swagger\Client\Model\Pet'
); );
if (!$response) { 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) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
@ -464,9 +535,6 @@ class PetApi
throw $e; throw $e;
} }
return null;
} }
/** /**
@ -481,6 +549,24 @@ class PetApi
* @throws \Swagger\Client\ApiException on non-2xx response * @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 // verify the required parameter 'pet_id' is set
@ -540,21 +626,21 @@ class PetApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
throw $e; throw $e;
} }
} }
/** /**
@ -568,6 +654,23 @@ class PetApi
* @throws \Swagger\Client\ApiException on non-2xx response * @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 // verify the required parameter 'pet_id' is set
@ -618,21 +721,21 @@ class PetApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
throw $e; throw $e;
} }
} }
/** /**
@ -647,6 +750,24 @@ class PetApi
* @throws \Swagger\Client\ApiException on non-2xx response * @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 // verify the required parameter 'pet_id' is set
@ -712,21 +833,21 @@ class PetApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
throw $e; throw $e;
} }
} }
} }

View File

@ -100,6 +100,21 @@ class StoreApi
* @throws \Swagger\Client\ApiException on non-2xx response * @throws \Swagger\Client\ApiException on non-2xx response
*/ */
public function getInventory() 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()
{ {
@ -138,19 +153,18 @@ class StoreApi
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, 'map[string,int]' $headerParams, 'map[string,int]'
); );
if (!$response) { 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) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
@ -162,9 +176,6 @@ class StoreApi
throw $e; throw $e;
} }
return null;
} }
/** /**
@ -177,6 +188,22 @@ class StoreApi
* @throws \Swagger\Client\ApiException on non-2xx response * @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)
{ {
@ -212,19 +239,18 @@ class StoreApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Order' $headerParams, '\Swagger\Client\Model\Order'
); );
if (!$response) { 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) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
@ -236,9 +262,6 @@ class StoreApi
throw $e; throw $e;
} }
return null;
} }
/** /**
@ -251,6 +274,22 @@ class StoreApi
* @throws \Swagger\Client\ApiException on non-2xx response * @throws \Swagger\Client\ApiException on non-2xx response
*/ */
public function getOrderById($order_id) 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 // verify the required parameter 'order_id' is set
@ -293,19 +332,18 @@ class StoreApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Order' $headerParams, '\Swagger\Client\Model\Order'
); );
if (!$response) { 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) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
@ -317,9 +355,6 @@ class StoreApi
throw $e; throw $e;
} }
return null;
} }
/** /**
@ -332,6 +367,22 @@ class StoreApi
* @throws \Swagger\Client\ApiException on non-2xx response * @throws \Swagger\Client\ApiException on non-2xx response
*/ */
public function deleteOrder($order_id) 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 // verify the required parameter 'order_id' is set
@ -374,21 +425,21 @@ class StoreApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
throw $e; throw $e;
} }
} }
} }

View File

@ -101,6 +101,22 @@ class UserApi
* @throws \Swagger\Client\ApiException on non-2xx response * @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)
{ {
@ -136,21 +152,21 @@ class UserApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
throw $e; throw $e;
} }
} }
/** /**
@ -163,6 +179,22 @@ class UserApi
* @throws \Swagger\Client\ApiException on non-2xx response * @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)
{ {
@ -198,21 +230,21 @@ class UserApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
throw $e; throw $e;
} }
} }
/** /**
@ -225,6 +257,22 @@ class UserApi
* @throws \Swagger\Client\ApiException on non-2xx response * @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)
{ {
@ -260,21 +308,21 @@ class UserApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
throw $e; throw $e;
} }
} }
/** /**
@ -288,6 +336,23 @@ class UserApi
* @throws \Swagger\Client\ApiException on non-2xx response * @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)
{ {
@ -325,19 +390,18 @@ class UserApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, 'string' $headerParams, 'string'
); );
if (!$response) { 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) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
@ -349,9 +413,6 @@ class UserApi
throw $e; throw $e;
} }
return null;
} }
/** /**
@ -363,6 +424,21 @@ class UserApi
* @throws \Swagger\Client\ApiException on non-2xx response * @throws \Swagger\Client\ApiException on non-2xx response
*/ */
public function logoutUser() 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()
{ {
@ -394,21 +470,21 @@ class UserApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
throw $e; throw $e;
} }
} }
/** /**
@ -421,6 +497,22 @@ class UserApi
* @throws \Swagger\Client\ApiException on non-2xx response * @throws \Swagger\Client\ApiException on non-2xx response
*/ */
public function getUserByName($username) 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 // verify the required parameter 'username' is set
@ -463,19 +555,18 @@ class UserApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\User' $headerParams, '\Swagger\Client\Model\User'
); );
if (!$response) { 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) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
@ -487,9 +578,6 @@ class UserApi
throw $e; throw $e;
} }
return null;
} }
/** /**
@ -503,6 +591,23 @@ class UserApi
* @throws \Swagger\Client\ApiException on non-2xx response * @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 // verify the required parameter 'username' is set
@ -549,21 +654,21 @@ class UserApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
throw $e; throw $e;
} }
} }
/** /**
@ -576,6 +681,22 @@ class UserApi
* @throws \Swagger\Client\ApiException on non-2xx response * @throws \Swagger\Client\ApiException on non-2xx response
*/ */
public function deleteUser($username) 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 // verify the required parameter 'username' is set
@ -618,21 +739,21 @@ class UserApi
} }
// make the API Call // make the API Call
try try {
{ list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
list($response, $httpHeader) = $this->apiClient->callApi(
$resourcePath, $method, $resourcePath, $method,
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
return array(null, $statusCode, $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
throw $e; throw $e;
} }
} }
} }

View File

@ -160,7 +160,7 @@ class ApiClient
if ($this->config->getCurlTimeout() != 0) { if ($this->config->getCurlTimeout() != 0) {
curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout()); 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_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
@ -216,7 +216,7 @@ class ApiClient
// Make the request // Make the request
$response = curl_exec($curl); $response = curl_exec($curl);
$http_header_size = curl_getinfo($curl, CURLINFO_HEADER_SIZE); $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); $http_body = substr($response, $http_header_size);
$response_info = curl_getinfo($curl); $response_info = curl_getinfo($curl);
@ -231,7 +231,7 @@ class ApiClient
} elseif ($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 // return raw body if response is a file
if ($responseType == '\SplFileObject') { if ($responseType == '\SplFileObject') {
return array($http_body, $http_header); return array($http_body, $response_info['http_code'], $http_header);
} }
$data = json_decode($http_body); $data = json_decode($http_body);
@ -249,7 +249,7 @@ class ApiClient
$response_info['http_code'], $http_header, $data $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 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

@ -198,7 +198,7 @@ class ObjectSerializer
$deserialized = $data; $deserialized = $data;
} elseif ($class === '\SplFileObject') { } elseif ($class === '\SplFileObject') {
// determine file name // 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]; $filename = Configuration::getDefaultConfiguration()->getTempFolderPath().$match[1];
} else { } else {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), ''); $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'); $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 // test getPetByStatus and verify by the "id" of the response
public function testFindPetByStatus() public function testFindPetByStatus()
{ {
@ -149,7 +168,26 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
$this->assertSame($response->getName(), 'updatePet'); $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() public function testUpdatePetWithForm()
{ {
// initialize the API client // initialize the API client

View File

@ -35,34 +35,12 @@ void PetApiTests::runTests() {
delete tests; 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() { void PetApiTests::findPetsByStatusTest() {
SWGPetApi* api = getApi(); SWGPetApi* api = getApi();
static QEventLoop loop; static QEventLoop loop;
QTimer timer; QTimer timer;
timer.setInterval(1000); timer.setInterval(4000);
timer.setSingleShot(true); timer.setSingleShot(true);
auto validator = [](QList<SWGPet*>* pets) { auto validator = [](QList<SWGPet*>* pets) {

View File

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

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!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> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
<value type="QByteArray">{e1009bf2-3b8d-440a-a972-23a1fd0a9453}</value> <value type="QByteArray">{20946a4e-8558-4260-a72e-14a8108ad944}</value>
</data> </data>
<data> <data>
<variable>ProjectExplorer.Project.ActiveTarget</variable> <variable>ProjectExplorer.Project.ActiveTarget</variable>
@ -58,14 +58,14 @@
<data> <data>
<variable>ProjectExplorer.Project.Target.0</variable> <variable>ProjectExplorer.Project.Target.0</variable>
<valuemap type="QVariantMap"> <valuemap type="QVariantMap">
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop Qt 5.4.1 clang 64bit</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.4.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.54.clang_64_kit</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.ActiveBuildConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
<value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value> <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0"> <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.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -76,6 +76,7 @@
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value> <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</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> <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1">
@ -125,7 +126,7 @@
<value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value> <value type="bool" key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild">true</value>
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.1"> <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.BuildConfiguration.BuildStepList.0">
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0"> <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
<value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value> <value type="bool" key="ProjectExplorer.BuildStep.Enabled">true</value>
@ -136,6 +137,7 @@
<value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value> <value type="bool" key="QtProjectManager.QMakeBuildStep.LinkQmlDebuggingLibraryAuto">true</value>
<value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value> <value type="QString" key="QtProjectManager.QMakeBuildStep.QMakeArguments"></value>
<value type="bool" key="QtProjectManager.QMakeBuildStep.QMakeForced">false</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> <value type="bool" key="QtProjectManager.QMakeBuildStep.UseQtQuickCompiler">false</value>
</valuemap> </valuemap>
<valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.1"> <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.Settings.UseGlobalSettings">true</value>
<value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value> <value type="bool" key="Analyzer.Valgrind.ShowReachable">false</value>
<value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</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"> <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
<value type="int">11</value> <value type="int">0</value>
<value type="int">14</value> <value type="int">1</value>
<value type="int">12</value>
<value type="int">13</value>
<value type="int">2</value> <value type="int">2</value>
<value type="int">3</value> <value type="int">3</value>
<value type="int">4</value> <value type="int">4</value>
@ -231,14 +231,16 @@
<value type="int">8</value> <value type="int">8</value>
<value type="int">9</value> <value type="int">9</value>
<value type="int">10</value> <value type="int">10</value>
<value type="int">0</value> <value type="int">11</value>
<value type="int">1</value> <value type="int">12</value>
<value type="int">13</value>
<value type="int">14</value>
</valuelist> </valuelist>
<value type="int" key="PE.EnvironmentAspect.Base">2</value> <value type="int" key="PE.EnvironmentAspect.Base">2</value>
<valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/> <valuelist type="QVariantList" key="PE.EnvironmentAspect.Changes"/>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">PetStore</value> <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">PetStore</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></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.CommandLineArguments"></value>
<value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">PetStore.pro</value> <value type="QString" key="Qt4ProjectManager.Qt4RunConfiguration.ProFile">PetStore.pro</value>
<value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value> <value type="bool" key="Qt4ProjectManager.Qt4RunConfiguration.UseDyldImageSuffix">false</value>

View File

@ -1,9 +1,9 @@
#include "SWGHelpers.h" #include "SWGHelpers.h"
#include "SWGModelFactory.h" #include "SWGModelFactory.h"
#include "SWGObject.h" #include "SWGObject.h"
#import <QDebug> #include <QDebug>
#import <QJsonArray> #include <QJsonArray>
#import <QJsonValue> #include <QJsonValue>
namespace Swagger { namespace Swagger {
@ -25,6 +25,14 @@ setValue(void* value, QJsonValue obj, QString type, QString complexType) {
qint64 *val = static_cast<qint64*>(value); qint64 *val = static_cast<qint64*>(value);
*val = obj.toVariant().toLongLong(); *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) { else if (QStringLiteral("QString").compare(type) == 0) {
QString **val = static_cast<QString**>(value); 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("")); setValue(&val, jval, QStringLiteral("bool"), QStringLiteral(""));
output->append((void*)&val); 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); 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); bool* str = static_cast<bool*>(value);
output->insert(name, QJsonValue(*str)); 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 void

View File

@ -10,10 +10,10 @@
#include <QJsonObject> #include <QJsonObject>
#include "SWGTag.h"
#include <QList>
#include "SWGCategory.h"
#include <QString> #include <QString>
#include "SWGCategory.h"
#include <QList>
#include "SWGTag.h"
#include "SWGObject.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 # @option opts [Pet] :body Pet object that needs to be added to the store
# @return [nil] # @return [nil]
def update_pet(opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#update_pet ..." Configuration.logger.debug "Calling API: PetApi#update_pet ..."
end end
@ -43,16 +53,16 @@ module Petstore
auth_names = ['petstore_auth'] auth_names = ['petstore_auth']
@api_client.call_api(:PUT, path, data, status_code, headers = @api_client.call_api(:PUT, path,
:header_params => header_params, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
:body => post_body, :body => post_body,
:auth_names => auth_names) :auth_names => auth_names)
if Configuration.debugging 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 end
return nil return data, status_code, headers
end end
# Add a new pet to the store # 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 # @option opts [Pet] :body Pet object that needs to be added to the store
# @return [nil] # @return [nil]
def add_pet(opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#add_pet ..." Configuration.logger.debug "Calling API: PetApi#add_pet ..."
end end
@ -90,16 +110,16 @@ module Petstore
auth_names = ['petstore_auth'] auth_names = ['petstore_auth']
@api_client.call_api(:POST, path, data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
:body => post_body, :body => post_body,
:auth_names => auth_names) :auth_names => auth_names)
if Configuration.debugging 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 end
return nil return data, status_code, headers
end end
# Finds Pets by status # Finds Pets by status
@ -108,6 +128,16 @@ module Petstore
# @option opts [Array<String>] :status Status values that need to be considered for filter # @option opts [Array<String>] :status Status values that need to be considered for filter
# @return [Array<Pet>] # @return [Array<Pet>]
def find_pets_by_status(opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#find_pets_by_status ..." Configuration.logger.debug "Calling API: PetApi#find_pets_by_status ..."
end end
@ -138,7 +168,7 @@ module Petstore
auth_names = ['petstore_auth'] 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, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
@ -146,9 +176,9 @@ module Petstore
:auth_names => auth_names, :auth_names => auth_names,
:return_type => 'Array<Pet>') :return_type => 'Array<Pet>')
if Configuration.debugging 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 end
return result return data, status_code, headers
end end
# Finds Pets by tags # Finds Pets by tags
@ -157,6 +187,16 @@ module Petstore
# @option opts [Array<String>] :tags Tags to filter by # @option opts [Array<String>] :tags Tags to filter by
# @return [Array<Pet>] # @return [Array<Pet>]
def find_pets_by_tags(opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#find_pets_by_tags ..." Configuration.logger.debug "Calling API: PetApi#find_pets_by_tags ..."
end end
@ -187,7 +227,7 @@ module Petstore
auth_names = ['petstore_auth'] 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, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
@ -195,9 +235,9 @@ module Petstore
:auth_names => auth_names, :auth_names => auth_names,
:return_type => 'Array<Pet>') :return_type => 'Array<Pet>')
if Configuration.debugging 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 end
return result return data, status_code, headers
end end
# Find pet by ID # Find pet by ID
@ -206,6 +246,16 @@ module Petstore
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @return [Pet] # @return [Pet]
def get_pet_by_id(pet_id, opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#get_pet_by_id ..." Configuration.logger.debug "Calling API: PetApi#get_pet_by_id ..."
end end
@ -238,7 +288,7 @@ module Petstore
auth_names = ['api_key'] 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, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
@ -246,9 +296,9 @@ module Petstore
:auth_names => auth_names, :auth_names => auth_names,
:return_type => 'Pet') :return_type => 'Pet')
if Configuration.debugging 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 end
return result return data, status_code, headers
end end
# Updates a pet in the store with form data # Updates a pet in the store with form data
@ -259,6 +309,18 @@ module Petstore
# @option opts [String] :status Updated status of the pet # @option opts [String] :status Updated status of the pet
# @return [nil] # @return [nil]
def update_pet_with_form(pet_id, opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#update_pet_with_form ..." Configuration.logger.debug "Calling API: PetApi#update_pet_with_form ..."
end end
@ -293,16 +355,16 @@ module Petstore
auth_names = ['petstore_auth'] auth_names = ['petstore_auth']
@api_client.call_api(:POST, path, data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
:body => post_body, :body => post_body,
:auth_names => auth_names) :auth_names => auth_names)
if Configuration.debugging 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 end
return nil return data, status_code, headers
end end
# Deletes a pet # Deletes a pet
@ -312,6 +374,17 @@ module Petstore
# @option opts [String] :api_key # @option opts [String] :api_key
# @return [nil] # @return [nil]
def delete_pet(pet_id, opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#delete_pet ..." Configuration.logger.debug "Calling API: PetApi#delete_pet ..."
end end
@ -345,16 +418,16 @@ module Petstore
auth_names = ['petstore_auth'] auth_names = ['petstore_auth']
@api_client.call_api(:DELETE, path, data, status_code, headers = @api_client.call_api(:DELETE, path,
:header_params => header_params, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
:body => post_body, :body => post_body,
:auth_names => auth_names) :auth_names => auth_names)
if Configuration.debugging 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 end
return nil return data, status_code, headers
end end
# uploads an image # uploads an image
@ -365,6 +438,18 @@ module Petstore
# @option opts [File] :file file to upload # @option opts [File] :file file to upload
# @return [nil] # @return [nil]
def upload_file(pet_id, opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: PetApi#upload_file ..." Configuration.logger.debug "Calling API: PetApi#upload_file ..."
end end
@ -399,16 +484,16 @@ module Petstore
auth_names = ['petstore_auth'] auth_names = ['petstore_auth']
@api_client.call_api(:POST, path, data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
:body => post_body, :body => post_body,
:auth_names => auth_names) :auth_names => auth_names)
if Configuration.debugging 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 end
return nil return data, status_code, headers
end end
end end
end end

View File

@ -13,6 +13,15 @@ module Petstore
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @return [Hash<String, Integer>] # @return [Hash<String, Integer>]
def get_inventory(opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: StoreApi#get_inventory ..." Configuration.logger.debug "Calling API: StoreApi#get_inventory ..."
end end
@ -42,7 +51,7 @@ module Petstore
auth_names = ['api_key'] 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, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
@ -50,9 +59,9 @@ module Petstore
:auth_names => auth_names, :auth_names => auth_names,
:return_type => 'Hash<String, Integer>') :return_type => 'Hash<String, Integer>')
if Configuration.debugging 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 end
return result return data, status_code, headers
end end
# Place an order for a pet # Place an order for a pet
@ -61,6 +70,16 @@ module Petstore
# @option opts [Order] :body order placed for purchasing the pet # @option opts [Order] :body order placed for purchasing the pet
# @return [Order] # @return [Order]
def place_order(opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: StoreApi#place_order ..." Configuration.logger.debug "Calling API: StoreApi#place_order ..."
end end
@ -90,7 +109,7 @@ module Petstore
auth_names = [] auth_names = []
result = @api_client.call_api(:POST, path, data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
@ -98,9 +117,9 @@ module Petstore
:auth_names => auth_names, :auth_names => auth_names,
:return_type => 'Order') :return_type => 'Order')
if Configuration.debugging 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 end
return result return data, status_code, headers
end end
# Find purchase order by ID # Find purchase order by ID
@ -109,6 +128,16 @@ module Petstore
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @return [Order] # @return [Order]
def get_order_by_id(order_id, opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: StoreApi#get_order_by_id ..." Configuration.logger.debug "Calling API: StoreApi#get_order_by_id ..."
end end
@ -141,7 +170,7 @@ module Petstore
auth_names = [] auth_names = []
result = @api_client.call_api(:GET, path, data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
@ -149,9 +178,9 @@ module Petstore
:auth_names => auth_names, :auth_names => auth_names,
:return_type => 'Order') :return_type => 'Order')
if Configuration.debugging 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 end
return result return data, status_code, headers
end end
# Delete purchase order by ID # Delete purchase order by ID
@ -160,6 +189,16 @@ module Petstore
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @return [nil] # @return [nil]
def delete_order(order_id, opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: StoreApi#delete_order ..." Configuration.logger.debug "Calling API: StoreApi#delete_order ..."
end end
@ -192,16 +231,16 @@ module Petstore
auth_names = [] auth_names = []
@api_client.call_api(:DELETE, path, data, status_code, headers = @api_client.call_api(:DELETE, path,
:header_params => header_params, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
:body => post_body, :body => post_body,
:auth_names => auth_names) :auth_names => auth_names)
if Configuration.debugging 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 end
return nil return data, status_code, headers
end end
end end
end end

View File

@ -14,6 +14,16 @@ module Petstore
# @option opts [User] :body Created user object # @option opts [User] :body Created user object
# @return [nil] # @return [nil]
def create_user(opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#create_user ..." Configuration.logger.debug "Calling API: UserApi#create_user ..."
end end
@ -43,16 +53,16 @@ module Petstore
auth_names = [] auth_names = []
@api_client.call_api(:POST, path, data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
:body => post_body, :body => post_body,
:auth_names => auth_names) :auth_names => auth_names)
if Configuration.debugging 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 end
return nil return data, status_code, headers
end end
# Creates list of users with given input array # Creates list of users with given input array
@ -61,6 +71,16 @@ module Petstore
# @option opts [Array<User>] :body List of user object # @option opts [Array<User>] :body List of user object
# @return [nil] # @return [nil]
def create_users_with_array_input(opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#create_users_with_array_input ..." Configuration.logger.debug "Calling API: UserApi#create_users_with_array_input ..."
end end
@ -90,16 +110,16 @@ module Petstore
auth_names = [] auth_names = []
@api_client.call_api(:POST, path, data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
:body => post_body, :body => post_body,
:auth_names => auth_names) :auth_names => auth_names)
if Configuration.debugging 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 end
return nil return data, status_code, headers
end end
# Creates list of users with given input array # Creates list of users with given input array
@ -108,6 +128,16 @@ module Petstore
# @option opts [Array<User>] :body List of user object # @option opts [Array<User>] :body List of user object
# @return [nil] # @return [nil]
def create_users_with_list_input(opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#create_users_with_list_input ..." Configuration.logger.debug "Calling API: UserApi#create_users_with_list_input ..."
end end
@ -137,16 +167,16 @@ module Petstore
auth_names = [] auth_names = []
@api_client.call_api(:POST, path, data, status_code, headers = @api_client.call_api(:POST, path,
:header_params => header_params, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
:body => post_body, :body => post_body,
:auth_names => auth_names) :auth_names => auth_names)
if Configuration.debugging 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 end
return nil return data, status_code, headers
end end
# Logs user into the system # Logs user into the system
@ -156,6 +186,17 @@ module Petstore
# @option opts [String] :password The password for login in clear text # @option opts [String] :password The password for login in clear text
# @return [String] # @return [String]
def login_user(opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#login_user ..." Configuration.logger.debug "Calling API: UserApi#login_user ..."
end end
@ -187,7 +228,7 @@ module Petstore
auth_names = [] auth_names = []
result = @api_client.call_api(:GET, path, data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
@ -195,9 +236,9 @@ module Petstore
:auth_names => auth_names, :auth_names => auth_names,
:return_type => 'String') :return_type => 'String')
if Configuration.debugging 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 end
return result return data, status_code, headers
end end
# Logs out current logged in user session # Logs out current logged in user session
@ -205,6 +246,15 @@ module Petstore
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @return [nil] # @return [nil]
def logout_user(opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#logout_user ..." Configuration.logger.debug "Calling API: UserApi#logout_user ..."
end end
@ -234,16 +284,16 @@ module Petstore
auth_names = [] auth_names = []
@api_client.call_api(:GET, path, data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
:body => post_body, :body => post_body,
:auth_names => auth_names) :auth_names => auth_names)
if Configuration.debugging 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 end
return nil return data, status_code, headers
end end
# Get user by user name # Get user by user name
@ -252,6 +302,16 @@ module Petstore
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @return [User] # @return [User]
def get_user_by_name(username, opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#get_user_by_name ..." Configuration.logger.debug "Calling API: UserApi#get_user_by_name ..."
end end
@ -284,7 +344,7 @@ module Petstore
auth_names = [] auth_names = []
result = @api_client.call_api(:GET, path, data, status_code, headers = @api_client.call_api(:GET, path,
:header_params => header_params, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
@ -292,9 +352,9 @@ module Petstore
:auth_names => auth_names, :auth_names => auth_names,
:return_type => 'User') :return_type => 'User')
if Configuration.debugging 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 end
return result return data, status_code, headers
end end
# Updated user # Updated user
@ -304,6 +364,17 @@ module Petstore
# @option opts [User] :body Updated user object # @option opts [User] :body Updated user object
# @return [nil] # @return [nil]
def update_user(username, opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#update_user ..." Configuration.logger.debug "Calling API: UserApi#update_user ..."
end end
@ -336,16 +407,16 @@ module Petstore
auth_names = [] auth_names = []
@api_client.call_api(:PUT, path, data, status_code, headers = @api_client.call_api(:PUT, path,
:header_params => header_params, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
:body => post_body, :body => post_body,
:auth_names => auth_names) :auth_names => auth_names)
if Configuration.debugging 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 end
return nil return data, status_code, headers
end end
# Delete user # Delete user
@ -354,6 +425,16 @@ module Petstore
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @return [nil] # @return [nil]
def delete_user(username, opts = {}) 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 if Configuration.debugging
Configuration.logger.debug "Calling API: UserApi#delete_user ..." Configuration.logger.debug "Calling API: UserApi#delete_user ..."
end end
@ -386,16 +467,16 @@ module Petstore
auth_names = [] auth_names = []
@api_client.call_api(:DELETE, path, data, status_code, headers = @api_client.call_api(:DELETE, path,
:header_params => header_params, :header_params => header_params,
:query_params => query_params, :query_params => query_params,
:form_params => form_params, :form_params => form_params,
:body => post_body, :body => post_body,
:auth_names => auth_names) :auth_names => auth_names)
if Configuration.debugging 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 end
return nil return data, status_code, headers
end end
end end
end end

View File

@ -15,9 +15,6 @@ module Petstore
# @return [Hash] # @return [Hash]
attr_accessor :default_headers 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) def initialize(host = nil)
@host = host || Configuration.base_url @host = host || Configuration.base_url
@format = 'json' @format = 'json'
@ -28,13 +25,14 @@ module Petstore
} }
end 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 = {}) def call_api(http_method, path, opts = {})
request = build_request(http_method, path, opts) request = build_request(http_method, path, opts)
response = request.run response = request.run
# record as last response
@last_response = response
if Configuration.debugging if Configuration.debugging
Configuration.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n" Configuration.logger.debug "HTTP response body ~BEGIN~\n#{response.body}\n~END~\n"
end end
@ -47,10 +45,11 @@ module Petstore
end end
if opts[:return_type] if opts[:return_type]
deserialize(response, opts[:return_type]) data = deserialize(response, opts[:return_type])
else else
nil data = nil
end end
return data, response.code, response.headers
end end
def build_request(http_method, path, opts = {}) def build_request(http_method, path, opts = {})

View File

@ -50,6 +50,17 @@ describe "Pet" do
pet.category.name.should == "category test" pet.category.name.should == "category test"
end 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 it "should not find a pet that does not exist" do
begin begin
@pet_api.get_pet_by_id(-10002) @pet_api.get_pet_by_id(-10002)