Merge branch 'master' into ruby-object-tests

This commit is contained in:
xhh 2016-03-04 12:45:42 +08:00
commit 9b4b0111ad
57 changed files with 1367 additions and 47 deletions

View File

@ -72,7 +72,7 @@ Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
If you're looking for the latest stable version, you can grab it directly from maven central (you'll need java 7 runtime at a minimum):
```
wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.1.5/swagger-codegen-cli-2.1.5.jar -o swagger-codegen-cli.jar
wget http://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.1.5/swagger-codegen-cli-2.1.5.jar -O swagger-codegen-cli.jar
java -jar swagger-codegen-cli.jar help
```

View File

@ -7,6 +7,7 @@ import java.util.*;
public class CodegenModel {
public String parent, parentSchema;
public String name, classname, description, classVarName, modelJson, dataType;
public String classFilename; // store the class file name, mainly used for import
public String unescapedDescription;
public String discriminator;
public String defaultValue;

View File

@ -877,6 +877,7 @@ public class DefaultCodegen {
m.unescapedDescription = model.getDescription();
m.classname = toModelName(name);
m.classVarName = toVarName(name);
m.classFilename = toModelFilename(name);
m.modelJson = Json.pretty(model);
m.externalDocs = model.getExternalDocs();
m.vendorExtensions = model.getVendorExtensions();

View File

@ -754,7 +754,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
CodegenModel cm = config.fromModel(key, mm, allDefinitions);
Map<String, Object> mo = new HashMap<String, Object>();
mo.put("model", cm);
mo.put("importPath", config.toModelImport(key));
mo.put("importPath", config.toModelImport(cm.classname));
models.add(mo);
allImports.addAll(cm.imports);

View File

@ -157,6 +157,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
typeMapping.put("number", "Number");
typeMapping.put("DateTime", "Date");
typeMapping.put("Date", "Date");
typeMapping.put("file", "File");
// binary not supported in JavaScript client right now, using String as a workaround
typeMapping.put("binary", "String");
@ -293,6 +294,14 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
public String toModelName(String name) {
name = sanitizeName(name); // FIXME parameter should not be assigned. Also declare it as "final"
if (!StringUtils.isEmpty(modelNamePrefix)) {
name = modelNamePrefix + "_" + name;
}
if (!StringUtils.isEmpty(modelNameSuffix)) {
name = name + "_" + modelNameSuffix;
}
// camelize the model name
// phone_number => PhoneNumber
name = camelize(name);
@ -315,7 +324,7 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
@Override
public String toModelImport(String name) {
return toModelName(name);
return name;
}
@Override

View File

@ -101,7 +101,7 @@ public class PhpClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("array", "array");
typeMapping.put("list", "array");
typeMapping.put("object", "object");
typeMapping.put("binary", "ByteArray");
typeMapping.put("binary", "string");
cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC));
cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC));

View File

@ -212,8 +212,7 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
@Override
public String toModelName(String name) {
name = sanitizeName(modelNamePrefix + name + modelNameSuffix); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
// remove dollar sign
name = name.replaceAll("$", "");
@ -223,6 +222,14 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
name = "object_" + name; // e.g. return => ObjectReturn (after camelize)
}
if (!StringUtils.isEmpty(modelNamePrefix)) {
name = modelNamePrefix + "_" + name;
}
if (!StringUtils.isEmpty(modelNameSuffix)) {
name = name + "_" + modelNameSuffix;
}
// camelize the model name
// phone_number => PhoneNumber
return camelize(name);
@ -230,6 +237,10 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
@Override
public String toModelFilename(String name) {
name = sanitizeName(name); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
// remove dollar sign
name = name.replaceAll("$", "");
// model name cannot use reserved keyword, e.g. return
if (isReservedWord(name)) {
LOGGER.warn(name + " (reserved word) cannot be used as model filename. Renamed to " + underscore(dropDots("object_" + name)));

View File

@ -462,7 +462,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public String toModelImport(String name) {
return gemName + "/" + modelPackage() + "/" + toModelFilename(name);
return gemName + "/" + modelPackage() + "/" + underscore(name);
}
@Override

View File

@ -14,6 +14,13 @@ using {{packageName}}.Api;
namespace {{packageName}}.Test
{
/// <summary>
/// Class for testing {{classname}}
/// </summary>
/// <remarks>
/// This file is automatically generated by Swagger Codegen.
/// Please update the test case below to test the API endpoint.
/// </remarks>
[TestFixture]
public class {{classname}}Tests
{

View File

@ -13,6 +13,13 @@ using System.Reflection;
{{#model}}
namespace {{packageName}}.Test
{
/// <summary>
/// Class for testing {{classname}}
/// </summary>
/// <remarks>
/// This file is automatically generated by Swagger Codegen.
/// Please update the test case below to test the model.
/// </remarks>
[TestFixture]
public class {{classname}}Tests
{

View File

@ -14,8 +14,8 @@
# limitations under the License.
#
#
# NOTE: This class is auto generated by the swagger code generator program.
# Do not edit the class manually.
# NOTE: This class is auto generated by Swagger Codegen
# Please update the test case below to test the API endpoints.
#
use Test::More tests => 1; #TODO update number of test cases
use Test::Exception;

View File

@ -1,3 +1,6 @@
# NOTE: This class is auto generated by the Swagger Codegen
# Please update the test case below to test the model.
use Test::More tests => 2;
use Test::Exception;

View File

@ -230,7 +230,7 @@ class ApiClient
throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null);
} elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
// return raw body if response is a file
if ($responseType == '\SplFileObject' || $responseType == 'ByteArray') {
if ($responseType == '\SplFileObject' || $responseType == 'string') {
return array($http_body, $response_info['http_code'], $http_header);
}

View File

@ -241,8 +241,6 @@ class ObjectSerializer
$values[] = self::deserialize($value, $subClass);
}
$deserialized = $values;
} elseif ($class === 'ByteArray') { // byte array
$deserialized = unpack('C*', (string)$data);
} elseif ($class === '\DateTime') {
$deserialized = new \DateTime($data);
} elseif (in_array($class, array({{&primitives}}))) {

View File

@ -188,7 +188,7 @@ use \{{invokerPackage}}\ObjectSerializer;
{{#bodyParams}}// body params
$_tempBody = null;
if (isset(${{paramName}})) {
{{^isBinary}}$_tempBody = ${{paramName}};{{/isBinary}}{{#isBinary}}$_tempBody = call_user_func_array('pack', array_merge(array('C*'), ${{paramName}}));{{/isBinary}}
$_tempBody = ${{paramName}};
}{{/bodyParams}}
// for model (json/xml)

View File

@ -28,7 +28,7 @@
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
* Please update the test case below to test the endpoint.
*/
namespace {{apiPackage}};

View File

@ -30,7 +30,7 @@
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
* Please update the test case below to test the model.
*/
namespace {{modelPackage}};

View File

@ -1,5 +1,5 @@
from __future__ import absolute_import
# import models into model package
{{#models}}{{#model}}from .{{classVarName}} import {{classname}}{{/model}}
{{#models}}{{#model}}from .{{classFilename}} import {{classname}}{{/model}}
{{/models}}

View File

@ -1,7 +1,7 @@
from __future__ import absolute_import
# import models into sdk package
{{#models}}{{#model}}from .models.{{classVarName}} import {{classname}}
{{#models}}{{#model}}from .models.{{classFilename}} import {{classname}}
{{/model}}{{/models}}
# import apis into sdk package
{{#apiInfo}}{{#apis}}from .apis.{{classVarName}} import {{classname}}

View File

@ -1251,6 +1251,28 @@
"xml": {
"name": "Order"
}
},
"$special[model.name]": {
"properties": {
"$special[property.name]": {
"type": "integer",
"format": "int64"
}
},
"xml": {
"name": "$special[model.name]"
}
},
"Return": {
"properties": {
"return": {
"type": "integer",
"format": "int32"
}
},
"xml": {
"name": "Return"
}
}
}
}

View File

@ -11,6 +11,13 @@ using System.Reflection;
namespace IO.Swagger.Test
{
/// <summary>
/// Class for testing Category
/// </summary>
/// <remarks>
/// This file is automatically generated by Swagger Codegen.
/// Please update the test case below to test the model.
/// </remarks>
[TestFixture]
public class CategoryTests
{

View File

@ -11,6 +11,13 @@ using System.Reflection;
namespace IO.Swagger.Test
{
/// <summary>
/// Class for testing Order
/// </summary>
/// <remarks>
/// This file is automatically generated by Swagger Codegen.
/// Please update the test case below to test the model.
/// </remarks>
[TestFixture]
public class OrderTests
{

View File

@ -13,6 +13,13 @@ using IO.Swagger.Model;
namespace IO.Swagger.Test
{
/// <summary>
/// Class for testing PetApi
/// </summary>
/// <remarks>
/// This file is automatically generated by Swagger Codegen.
/// Please update the test case below to test the API endpoint.
/// </remarks>
[TestFixture]
public class PetApiTests
{
@ -155,6 +162,19 @@ namespace IO.Swagger.Test
}
/// <summary>
/// Test GetPetByIdInObject
/// </summary>
[Test]
public void GetPetByIdInObjectTest()
{
// TODO: add unit test for the method 'GetPetByIdInObject'
long? petId = null; // TODO: replace null with proper value
var response = instance.GetPetByIdInObject(petId);
Assert.IsInstanceOf<InlineResponse200> (response, "response is InlineResponse200");
}
/// <summary>
/// Test PetPetIdtestingByteArraytrueGet
/// </summary>

View File

@ -11,6 +11,13 @@ using System.Reflection;
namespace IO.Swagger.Test
{
/// <summary>
/// Class for testing Pet
/// </summary>
/// <remarks>
/// This file is automatically generated by Swagger Codegen.
/// Please update the test case below to test the model.
/// </remarks>
[TestFixture]
public class PetTests
{

View File

@ -13,6 +13,13 @@ using IO.Swagger.Model;
namespace IO.Swagger.Test
{
/// <summary>
/// Class for testing StoreApi
/// </summary>
/// <remarks>
/// This file is automatically generated by Swagger Codegen.
/// Please update the test case below to test the API endpoint.
/// </remarks>
[TestFixture]
public class StoreApiTests
{
@ -71,6 +78,18 @@ namespace IO.Swagger.Test
Assert.IsInstanceOf<Dictionary<string, int?>> (response, "response is Dictionary<string, int?>");
}
/// <summary>
/// Test GetInventoryInObject
/// </summary>
[Test]
public void GetInventoryInObjectTest()
{
// TODO: add unit test for the method 'GetInventoryInObject'
var response = instance.GetInventoryInObject();
Assert.IsInstanceOf<Object> (response, "response is Object");
}
/// <summary>
/// Test PlaceOrder
/// </summary>

View File

@ -11,6 +11,13 @@ using System.Reflection;
namespace IO.Swagger.Test
{
/// <summary>
/// Class for testing Tag
/// </summary>
/// <remarks>
/// This file is automatically generated by Swagger Codegen.
/// Please update the test case below to test the model.
/// </remarks>
[TestFixture]
public class TagTests
{

View File

@ -13,6 +13,13 @@ using IO.Swagger.Model;
namespace IO.Swagger.Test
{
/// <summary>
/// Class for testing UserApi
/// </summary>
/// <remarks>
/// This file is automatically generated by Swagger Codegen.
/// Please update the test case below to test the API endpoint.
/// </remarks>
[TestFixture]
public class UserApiTests
{

View File

@ -11,6 +11,13 @@ using System.Reflection;
namespace IO.Swagger.Test
{
/// <summary>
/// Class for testing User
/// </summary>
/// <remarks>
/// This file is automatically generated by Swagger Codegen.
/// Please update the test case below to test the model.
/// </remarks>
[TestFixture]
public class UserTests
{

View File

@ -203,6 +203,28 @@ namespace IO.Swagger.Api
/// <returns>ApiResponse of Object(void)</returns>
ApiResponse<Object> UploadFileWithHttpInfo (long? petId, string additionalMetadata = null, Stream file = null);
/// <summary>
/// Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
/// </summary>
/// <remarks>
/// Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="petId">ID of pet that needs to be fetched</param>
/// <returns>InlineResponse200</returns>
InlineResponse200 GetPetByIdInObject (long? petId);
/// <summary>
/// Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
/// </summary>
/// <remarks>
/// Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="petId">ID of pet that needs to be fetched</param>
/// <returns>ApiResponse of InlineResponse200</returns>
ApiResponse<InlineResponse200> GetPetByIdInObjectWithHttpInfo (long? petId);
/// <summary>
/// Fake endpoint to test byte array return by &#39;Find pet by ID&#39;
/// </summary>
@ -437,6 +459,28 @@ namespace IO.Swagger.Api
/// <returns>Task of ApiResponse</returns>
System.Threading.Tasks.Task<ApiResponse<Object>> UploadFileAsyncWithHttpInfo (long? petId, string additionalMetadata = null, Stream file = null);
/// <summary>
/// Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
/// </summary>
/// <remarks>
/// Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="petId">ID of pet that needs to be fetched</param>
/// <returns>Task of InlineResponse200</returns>
System.Threading.Tasks.Task<InlineResponse200> GetPetByIdInObjectAsync (long? petId);
/// <summary>
/// Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
/// </summary>
/// <remarks>
/// Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="petId">ID of pet that needs to be fetched</param>
/// <returns>Task of ApiResponse (InlineResponse200)</returns>
System.Threading.Tasks.Task<ApiResponse<InlineResponse200>> GetPetByIdInObjectAsyncWithHttpInfo (long? petId);
/// <summary>
/// Fake endpoint to test byte array return by &#39;Find pet by ID&#39;
/// </summary>
@ -1978,6 +2022,192 @@ namespace IO.Swagger.Api
null);
}
/// <summary>
/// Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39; Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="petId">ID of pet that needs to be fetched</param>
/// <returns>InlineResponse200</returns>
public InlineResponse200 GetPetByIdInObject (long? petId)
{
ApiResponse<InlineResponse200> localVarResponse = GetPetByIdInObjectWithHttpInfo(petId);
return localVarResponse.Data;
}
/// <summary>
/// Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39; Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="petId">ID of pet that needs to be fetched</param>
/// <returns>ApiResponse of InlineResponse200</returns>
public ApiResponse< InlineResponse200 > GetPetByIdInObjectWithHttpInfo (long? petId)
{
// verify the required parameter 'petId' is set
if (petId == null)
throw new ApiException(400, "Missing required parameter 'petId' when calling PetApi->GetPetByIdInObject");
var localVarPath = "/pet/{petId}?response=inline_arbitrary_object";
var localVarPathParams = new Dictionary<String, String>();
var localVarQueryParams = new Dictionary<String, String>();
var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var localVarFormParams = new Dictionary<String, String>();
var localVarFileParams = new Dictionary<String, FileParameter>();
Object localVarPostBody = null;
// to determine the Content-Type header
String[] localVarHttpContentTypes = new String[] {
};
String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
// to determine the Accept header
String[] localVarHttpHeaderAccepts = new String[] {
"application/json", "application/xml"
};
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
if (localVarHttpHeaderAccept != null)
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
localVarPathParams.Add("format", "json");
if (petId != null) localVarPathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter
// authentication (api_key) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key")))
{
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
}
// authentication (petstore_auth) required
// oauth required
if (!String.IsNullOrEmpty(Configuration.AccessToken))
{
localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken;
}
// make the HTTP request
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
localVarPathParams, localVarHttpContentType);
int localVarStatusCode = (int) localVarResponse.StatusCode;
if (localVarStatusCode >= 400)
throw new ApiException (localVarStatusCode, "Error calling GetPetByIdInObject: " + localVarResponse.Content, localVarResponse.Content);
else if (localVarStatusCode == 0)
throw new ApiException (localVarStatusCode, "Error calling GetPetByIdInObject: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
return new ApiResponse<InlineResponse200>(localVarStatusCode,
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
(InlineResponse200) Configuration.ApiClient.Deserialize(localVarResponse, typeof(InlineResponse200)));
}
/// <summary>
/// Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39; Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="petId">ID of pet that needs to be fetched</param>
/// <returns>Task of InlineResponse200</returns>
public async System.Threading.Tasks.Task<InlineResponse200> GetPetByIdInObjectAsync (long? petId)
{
ApiResponse<InlineResponse200> localVarResponse = await GetPetByIdInObjectAsyncWithHttpInfo(petId);
return localVarResponse.Data;
}
/// <summary>
/// Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39; Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="petId">ID of pet that needs to be fetched</param>
/// <returns>Task of ApiResponse (InlineResponse200)</returns>
public async System.Threading.Tasks.Task<ApiResponse<InlineResponse200>> GetPetByIdInObjectAsyncWithHttpInfo (long? petId)
{
// verify the required parameter 'petId' is set
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling GetPetByIdInObject");
var localVarPath = "/pet/{petId}?response=inline_arbitrary_object";
var localVarPathParams = new Dictionary<String, String>();
var localVarQueryParams = new Dictionary<String, String>();
var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var localVarFormParams = new Dictionary<String, String>();
var localVarFileParams = new Dictionary<String, FileParameter>();
Object localVarPostBody = null;
// to determine the Content-Type header
String[] localVarHttpContentTypes = new String[] {
};
String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
// to determine the Accept header
String[] localVarHttpHeaderAccepts = new String[] {
"application/json", "application/xml"
};
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
if (localVarHttpHeaderAccept != null)
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
localVarPathParams.Add("format", "json");
if (petId != null) localVarPathParams.Add("petId", Configuration.ApiClient.ParameterToString(petId)); // path parameter
// authentication (api_key) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key")))
{
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
}
// authentication (petstore_auth) required
// oauth required
if (!String.IsNullOrEmpty(Configuration.AccessToken))
{
localVarHeaderParams["Authorization"] = "Bearer " + Configuration.AccessToken;
}
// make the HTTP request
IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
localVarPathParams, localVarHttpContentType);
int localVarStatusCode = (int) localVarResponse.StatusCode;
if (localVarStatusCode >= 400)
throw new ApiException (localVarStatusCode, "Error calling GetPetByIdInObject: " + localVarResponse.Content, localVarResponse.Content);
else if (localVarStatusCode == 0)
throw new ApiException (localVarStatusCode, "Error calling GetPetByIdInObject: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
return new ApiResponse<InlineResponse200>(localVarStatusCode,
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
(InlineResponse200) Configuration.ApiClient.Deserialize(localVarResponse, typeof(InlineResponse200)));
}
/// <summary>
/// Fake endpoint to test byte array return by &#39;Find pet by ID&#39; Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
/// </summary>

View File

@ -59,6 +59,26 @@ namespace IO.Swagger.Api
/// <returns>ApiResponse of Dictionary&lt;string, int?&gt;</returns>
ApiResponse<Dictionary<string, int?>> GetInventoryWithHttpInfo ();
/// <summary>
/// Fake endpoint to test arbitrary object return by &#39;Get inventory&#39;
/// </summary>
/// <remarks>
/// Returns an arbitrary object which is actually a map of status codes to quantities
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <returns>Object</returns>
Object GetInventoryInObject ();
/// <summary>
/// Fake endpoint to test arbitrary object return by &#39;Get inventory&#39;
/// </summary>
/// <remarks>
/// Returns an arbitrary object which is actually a map of status codes to quantities
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <returns>ApiResponse of Object</returns>
ApiResponse<Object> GetInventoryInObjectWithHttpInfo ();
/// <summary>
/// Place an order for a pet
/// </summary>
@ -171,6 +191,26 @@ namespace IO.Swagger.Api
/// <returns>Task of ApiResponse (Dictionary&lt;string, int?&gt;)</returns>
System.Threading.Tasks.Task<ApiResponse<Dictionary<string, int?>>> GetInventoryAsyncWithHttpInfo ();
/// <summary>
/// Fake endpoint to test arbitrary object return by &#39;Get inventory&#39;
/// </summary>
/// <remarks>
/// Returns an arbitrary object which is actually a map of status codes to quantities
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <returns>Task of Object</returns>
System.Threading.Tasks.Task<Object> GetInventoryInObjectAsync ();
/// <summary>
/// Fake endpoint to test arbitrary object return by &#39;Get inventory&#39;
/// </summary>
/// <remarks>
/// Returns an arbitrary object which is actually a map of status codes to quantities
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <returns>Task of ApiResponse (Object)</returns>
System.Threading.Tasks.Task<ApiResponse<Object>> GetInventoryInObjectAsyncWithHttpInfo ();
/// <summary>
/// Place an order for a pet
/// </summary>
@ -654,6 +694,165 @@ namespace IO.Swagger.Api
}
/// <summary>
/// Fake endpoint to test arbitrary object return by &#39;Get inventory&#39; Returns an arbitrary object which is actually a map of status codes to quantities
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <returns>Object</returns>
public Object GetInventoryInObject ()
{
ApiResponse<Object> localVarResponse = GetInventoryInObjectWithHttpInfo();
return localVarResponse.Data;
}
/// <summary>
/// Fake endpoint to test arbitrary object return by &#39;Get inventory&#39; Returns an arbitrary object which is actually a map of status codes to quantities
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <returns>ApiResponse of Object</returns>
public ApiResponse< Object > GetInventoryInObjectWithHttpInfo ()
{
var localVarPath = "/store/inventory?response=arbitrary_object";
var localVarPathParams = new Dictionary<String, String>();
var localVarQueryParams = new Dictionary<String, String>();
var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var localVarFormParams = new Dictionary<String, String>();
var localVarFileParams = new Dictionary<String, FileParameter>();
Object localVarPostBody = null;
// to determine the Content-Type header
String[] localVarHttpContentTypes = new String[] {
};
String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
// to determine the Accept header
String[] localVarHttpHeaderAccepts = new String[] {
"application/json", "application/xml"
};
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
if (localVarHttpHeaderAccept != null)
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
localVarPathParams.Add("format", "json");
// authentication (api_key) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key")))
{
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
}
// make the HTTP request
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
localVarPathParams, localVarHttpContentType);
int localVarStatusCode = (int) localVarResponse.StatusCode;
if (localVarStatusCode >= 400)
throw new ApiException (localVarStatusCode, "Error calling GetInventoryInObject: " + localVarResponse.Content, localVarResponse.Content);
else if (localVarStatusCode == 0)
throw new ApiException (localVarStatusCode, "Error calling GetInventoryInObject: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
return new ApiResponse<Object>(localVarStatusCode,
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
(Object) Configuration.ApiClient.Deserialize(localVarResponse, typeof(Object)));
}
/// <summary>
/// Fake endpoint to test arbitrary object return by &#39;Get inventory&#39; Returns an arbitrary object which is actually a map of status codes to quantities
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <returns>Task of Object</returns>
public async System.Threading.Tasks.Task<Object> GetInventoryInObjectAsync ()
{
ApiResponse<Object> localVarResponse = await GetInventoryInObjectAsyncWithHttpInfo();
return localVarResponse.Data;
}
/// <summary>
/// Fake endpoint to test arbitrary object return by &#39;Get inventory&#39; Returns an arbitrary object which is actually a map of status codes to quantities
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <returns>Task of ApiResponse (Object)</returns>
public async System.Threading.Tasks.Task<ApiResponse<Object>> GetInventoryInObjectAsyncWithHttpInfo ()
{
var localVarPath = "/store/inventory?response=arbitrary_object";
var localVarPathParams = new Dictionary<String, String>();
var localVarQueryParams = new Dictionary<String, String>();
var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var localVarFormParams = new Dictionary<String, String>();
var localVarFileParams = new Dictionary<String, FileParameter>();
Object localVarPostBody = null;
// to determine the Content-Type header
String[] localVarHttpContentTypes = new String[] {
};
String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
// to determine the Accept header
String[] localVarHttpHeaderAccepts = new String[] {
"application/json", "application/xml"
};
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
if (localVarHttpHeaderAccept != null)
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
localVarPathParams.Add("format", "json");
// authentication (api_key) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key")))
{
localVarHeaderParams["api_key"] = Configuration.GetApiKeyWithPrefix("api_key");
}
// make the HTTP request
IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,
Method.GET, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
localVarPathParams, localVarHttpContentType);
int localVarStatusCode = (int) localVarResponse.StatusCode;
if (localVarStatusCode >= 400)
throw new ApiException (localVarStatusCode, "Error calling GetInventoryInObject: " + localVarResponse.Content, localVarResponse.Content);
else if (localVarStatusCode == 0)
throw new ApiException (localVarStatusCode, "Error calling GetInventoryInObject: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage);
return new ApiResponse<Object>(localVarStatusCode,
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
(Object) Configuration.ApiClient.Deserialize(localVarResponse, typeof(Object)));
}
/// <summary>
/// Place an order for a pet
/// </summary>

View File

@ -0,0 +1,157 @@
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;
namespace IO.Swagger.Model
{
/// <summary>
///
/// </summary>
[DataContract]
public partial class InlineResponse200 : IEquatable<InlineResponse200>
{
/// <summary>
/// Initializes a new instance of the <see cref="InlineResponse200" />class.
/// </summary>
/// <param name="Id">Id (required).</param>
/// <param name="Category">Category.</param>
/// <param name="Name">Name.</param>
public InlineResponse200(long? Id = null, Object Category = null, string Name = null)
{
// to ensure "Id" is required (not null)
if (Id == null)
{
throw new InvalidDataException("Id is a required property for InlineResponse200 and cannot be null");
}
else
{
this.Id = Id;
}
this.Category = Category;
this.Name = Name;
}
/// <summary>
/// Gets or Sets Id
/// </summary>
[DataMember(Name="id", EmitDefaultValue=false)]
public long? Id { get; set; }
/// <summary>
/// Gets or Sets Category
/// </summary>
[DataMember(Name="category", EmitDefaultValue=false)]
public Object Category { get; set; }
/// <summary>
/// Gets or Sets Name
/// </summary>
[DataMember(Name="name", EmitDefaultValue=false)]
public string Name { get; set; }
/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class InlineResponse200 {\n");
sb.Append(" Id: ").Append(Id).Append("\n");
sb.Append(" Category: ").Append(Category).Append("\n");
sb.Append(" Name: ").Append(Name).Append("\n");
sb.Append("}\n");
return sb.ToString();
}
/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}
/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
// credit: http://stackoverflow.com/a/10454552/677735
return this.Equals(obj as InlineResponse200);
}
/// <summary>
/// Returns true if InlineResponse200 instances are equal
/// </summary>
/// <param name="other">Instance of InlineResponse200 to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(InlineResponse200 other)
{
// credit: http://stackoverflow.com/a/10454552/677735
if (other == null)
return false;
return
(
this.Id == other.Id ||
this.Id != null &&
this.Id.Equals(other.Id)
) &&
(
this.Category == other.Category ||
this.Category != null &&
this.Category.Equals(other.Category)
) &&
(
this.Name == other.Name ||
this.Name != null &&
this.Name.Equals(other.Name)
);
}
/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
// credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap
{
int hash = 41;
// Suitable nullity checks etc, of course :)
if (this.Id != null)
hash = hash * 59 + this.Id.GetHashCode();
if (this.Category != null)
hash = hash * 59 + this.Category.GetHashCode();
if (this.Name != null)
hash = hash * 59 + this.Name.GetHashCode();
return hash;
}
}
}
}

View File

@ -59,6 +59,7 @@
<Compile Include="TestConfiguration.cs" />
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Client\ApiResponse.cs" />
<Compile Include="TestOrder.cs" />
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Model\InlineResponse200.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>

View File

@ -1,9 +1,10 @@
<Properties StartupItem="SwaggerClientTest.csproj">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs">
<MonoDevelop.Ide.Workbench ActiveDocument="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs">
<Files>
<File FileName="TestPet.cs" Line="162" Column="35" />
<File FileName="TestOrder.cs" Line="42" Column="12" />
<File FileName="TestOrder.cs" Line="1" Column="1" />
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs" Line="8" Column="24" />
</Files>
<Pads>
<Pad Id="MonoDevelop.NUnit.TestPad">

View File

@ -8,7 +8,7 @@ WWW::SwaggerClient::Role - a Moose role for the Swagger Petstore
Automatically generated by the Perl Swagger Codegen project:
- Build date: 2016-02-27T21:43:00.005+08:00
- Build date: 2016-03-03T20:09:18.907+08:00
- Build package: class io.swagger.codegen.languages.PerlClientCodegen
- Codegen version:

View File

@ -186,12 +186,12 @@ sub add_pet {
#
# Finds Pets by status
#
# @param ARRAY[string] $status Status values that need to be considered for filter (optional)
# @param ARRAY[string] $status Status values that need to be considered for query (optional)
{
my $params = {
'status' => {
data_type => 'ARRAY[string]',
description => 'Status values that need to be considered for filter',
description => 'Status values that need to be considered for query',
required => '0',
},
};
@ -662,6 +662,81 @@ sub upload_file {
}
#
# get_pet_by_id_in_object
#
# Fake endpoint to test inline arbitrary object return by 'Find pet by ID'
#
# @param int $pet_id ID of pet that needs to be fetched (required)
{
my $params = {
'pet_id' => {
data_type => 'int',
description => 'ID of pet that needs to be fetched',
required => '1',
},
};
__PACKAGE__->method_documentation->{ get_pet_by_id_in_object } = {
summary => 'Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;',
params => $params,
returns => 'InlineResponse200',
};
}
# @return InlineResponse200
#
sub get_pet_by_id_in_object {
my ($self, %args) = @_;
# verify the required parameter 'pet_id' is set
unless (exists $args{'pet_id'}) {
croak("Missing the required parameter 'pet_id' when calling get_pet_by_id_in_object");
}
# parse inputs
my $_resource_path = '/pet/{petId}?response=inline_arbitrary_object';
$_resource_path =~ s/{format}/json/; # default format to json
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# path params
if ( exists $args{'pet_id'}) {
my $_base_variable = "{" . "petId" . "}";
my $_base_value = $self->{api_client}->to_path_value($args{'pet_id'});
$_resource_path =~ s/$_base_variable/$_base_value/g;
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(api_key petstore_auth )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('InlineResponse200', $response);
return $_response_object;
}
#
# pet_pet_idtesting_byte_arraytrue_get
#

View File

@ -37,7 +37,7 @@ has version_info => ( is => 'ro',
default => sub { {
app_name => 'Swagger Petstore',
app_version => '1.0.0',
generated_date => '2016-02-27T21:43:00.005+08:00',
generated_date => '2016-03-03T20:09:18.907+08:00',
generator_class => 'class io.swagger.codegen.languages.PerlClientCodegen',
} },
documentation => 'Information about the application version and the codegen codebase version'
@ -103,7 +103,7 @@ Automatically generated by the Perl Swagger Codegen project:
=over 4
=item Build date: 2016-02-27T21:43:00.005+08:00
=item Build date: 2016-03-03T20:09:18.907+08:00
=item Build package: class io.swagger.codegen.languages.PerlClientCodegen

View File

@ -51,6 +51,74 @@ sub new {
}
#
# find_orders_by_status
#
# Finds orders by status
#
# @param string $status Status value that needs to be considered for query (optional)
{
my $params = {
'status' => {
data_type => 'string',
description => 'Status value that needs to be considered for query',
required => '0',
},
};
__PACKAGE__->method_documentation->{ find_orders_by_status } = {
summary => 'Finds orders by status',
params => $params,
returns => 'ARRAY[Order]',
};
}
# @return ARRAY[Order]
#
sub find_orders_by_status {
my ($self, %args) = @_;
# parse inputs
my $_resource_path = '/store/findByStatus';
$_resource_path =~ s/{format}/json/; # default format to json
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
# query params
if ( exists $args{'status'}) {
$query_params->{'status'} = $self->{api_client}->to_query_value($args{'status'});
}
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(test_api_client_id test_api_client_secret )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('ARRAY[Order]', $response);
return $_response_object;
}
#
# get_inventory
#
@ -110,6 +178,65 @@ sub get_inventory {
}
#
# get_inventory_in_object
#
# Fake endpoint to test arbitrary object return by 'Get inventory'
#
{
my $params = {
};
__PACKAGE__->method_documentation->{ get_inventory_in_object } = {
summary => 'Fake endpoint to test arbitrary object return by &#39;Get inventory&#39;',
params => $params,
returns => 'object',
};
}
# @return object
#
sub get_inventory_in_object {
my ($self, %args) = @_;
# parse inputs
my $_resource_path = '/store/inventory?response=arbitrary_object';
$_resource_path =~ s/{format}/json/; # default format to json
my $_method = 'GET';
my $query_params = {};
my $header_params = {};
my $form_params = {};
# 'Accept' and 'Content-Type' header
my $_header_accept = $self->{api_client}->select_header_accept('application/json', 'application/xml');
if ($_header_accept) {
$header_params->{'Accept'} = $_header_accept;
}
$header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();
my $_body_data;
# authentication setting, if any
my $auth_settings = [qw(api_key )];
# make the API Call
my $response = $self->{api_client}->call_api($_resource_path, $_method,
$query_params, $form_params,
$header_params, $_body_data, $auth_settings);
if (!$response) {
return;
}
my $_response_object = $self->{api_client}->deserialize('object', $response);
return $_response_object;
}
#
# place_order
#

View File

@ -98,6 +98,14 @@ isa_ok($api, 'WWW::SwaggerClient::PetApi');
my $result = $api->upload_file(pet_id => $pet_id, additional_metadata => $additional_metadata, file => $file);
}
#
# get_pet_by_id_in_object test
#
{
my $pet_id = undef; # replace NULL with a proper value
my $result = $api->get_pet_by_id_in_object(pet_id => $pet_id);
}
#
# pet_pet_idtesting_byte_arraytrue_get test
#

View File

@ -29,6 +29,14 @@ use_ok('WWW::SwaggerClient::StoreApi');
my $api = WWW::SwaggerClient::StoreApi->new();
isa_ok($api, 'WWW::SwaggerClient::StoreApi');
#
# find_orders_by_status test
#
{
my $status = undef; # replace NULL with a proper value
my $result = $api->find_orders_by_status(status => $status);
}
#
# get_inventory test
#
@ -36,6 +44,13 @@ isa_ok($api, 'WWW::SwaggerClient::StoreApi');
my $result = $api->get_inventory();
}
#
# get_inventory_in_object test
#
{
my $result = $api->get_inventory_in_object();
}
#
# place_order test
#

View File

@ -50,7 +50,7 @@ is $get_pet->tags->[0]->id, '11', 'stored and retrieved: got the proper tag id';
# API method docs
is_deeply( [sort keys %{$api->pet_api->method_documentation}],
[ 'add_pet', 'add_pet_using_byte_array', 'delete_pet', 'find_pets_by_status', 'find_pets_by_tags', 'get_pet_by_id', 'pet_pet_idtesting_byte_arraytrue_get', 'update_pet', 'update_pet_with_form', 'upload_file'],
[ 'add_pet', 'add_pet_using_byte_array', 'delete_pet', 'find_pets_by_status', 'find_pets_by_tags', 'get_pet_by_id', 'get_pet_by_id_in_object', 'pet_pet_idtesting_byte_arraytrue_get', 'update_pet', 'update_pet_with_form', 'upload_file'],
"Pet API method_documentation has the correct keys");
is $api->pet_api->method_documentation->{get_pet_by_id}->{params}->{pet_id}->{description},
'ID of pet that needs to be fetched', 'get_pet_by_id parameter pet_id description is correct';

View File

@ -878,13 +878,120 @@ class PetApi
}
}
/**
* getPetByIdInObject
*
* Fake endpoint to test inline arbitrary object return by 'Find pet by ID'
*
* @param int $pet_id ID of pet that needs to be fetched (required)
* @return \Swagger\Client\Model\InlineResponse200
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getPetByIdInObject($pet_id)
{
list($response, $statusCode, $httpHeader) = $this->getPetByIdInObjectWithHttpInfo ($pet_id);
return $response;
}
/**
* getPetByIdInObjectWithHttpInfo
*
* Fake endpoint to test inline arbitrary object return by 'Find pet by ID'
*
* @param int $pet_id ID of pet that needs to be fetched (required)
* @return Array of \Swagger\Client\Model\InlineResponse200, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getPetByIdInObjectWithHttpInfo($pet_id)
{
// verify the required parameter 'pet_id' is set
if ($pet_id === null) {
throw new \InvalidArgumentException('Missing the required parameter $pet_id when calling getPetByIdInObject');
}
// parse inputs
$resourcePath = "/pet/{petId}?response=inline_arbitrary_object";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// path params
if ($pet_id !== null) {
$resourcePath = str_replace(
"{" . "petId" . "}",
$this->apiClient->getSerializer()->toPathValue($pet_id),
$resourcePath
);
}
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
// this endpoint requires API key authentication
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
if (strlen($apiKey) !== 0) {
$headerParams['api_key'] = $apiKey;
}
// this endpoint requires OAuth (access token)
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
}
// make the API Call
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, 'GET',
$queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\InlineResponse200'
);
if (!$response) {
return array(null, $statusCode, $httpHeader);
}
return array(\Swagger\Client\ObjectSerializer::deserialize($response, '\Swagger\Client\Model\InlineResponse200', $httpHeader), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), '\Swagger\Client\Model\InlineResponse200', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* petPetIdtestingByteArraytrueGet
*
* Fake endpoint to test byte array return by 'Find pet by ID'
*
* @param int $pet_id ID of pet that needs to be fetched (required)
* @return ByteArray
* @return string
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function petPetIdtestingByteArraytrueGet($pet_id)
@ -900,7 +1007,7 @@ class PetApi
* Fake endpoint to test byte array return by 'Find pet by ID'
*
* @param int $pet_id ID of pet that needs to be fetched (required)
* @return Array of ByteArray, HTTP status code, HTTP response headers (array of strings)
* @return Array of string, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function petPetIdtestingByteArraytrueGetWithHttpInfo($pet_id)
@ -964,19 +1071,19 @@ class PetApi
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, 'GET',
$queryParams, $httpBody,
$headerParams, 'ByteArray'
$headerParams, 'string'
);
if (!$response) {
return array(null, $statusCode, $httpHeader);
}
return array(\Swagger\Client\ObjectSerializer::deserialize($response, 'ByteArray', $httpHeader), $statusCode, $httpHeader);
return array(\Swagger\Client\ObjectSerializer::deserialize($response, 'string', $httpHeader), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'ByteArray', $e->getResponseHeaders());
$data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'string', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
}
@ -990,7 +1097,7 @@ class PetApi
*
* Fake endpoint to test byte array in body parameter for adding a new pet to the store
*
* @param ByteArray $body Pet object in the form of byte array (optional)
* @param string $body Pet object in the form of byte array (optional)
* @return void
* @throws \Swagger\Client\ApiException on non-2xx response
*/
@ -1006,7 +1113,7 @@ class PetApi
*
* Fake endpoint to test byte array in body parameter for adding a new pet to the store
*
* @param ByteArray $body Pet object in the form of byte array (optional)
* @param string $body Pet object in the form of byte array (optional)
* @return Array of null, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
@ -1036,7 +1143,7 @@ class PetApi
// body params
$_tempBody = null;
if (isset($body)) {
$_tempBody = call_user_func_array('pack', array_merge(array('C*'), $body));
$_tempBody = $body;
}
// for model (json/xml)

View File

@ -280,6 +280,94 @@ class StoreApi
}
}
/**
* getInventoryInObject
*
* Fake endpoint to test arbitrary object return by 'Get inventory'
*
* @return object
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getInventoryInObject()
{
list($response, $statusCode, $httpHeader) = $this->getInventoryInObjectWithHttpInfo ();
return $response;
}
/**
* getInventoryInObjectWithHttpInfo
*
* Fake endpoint to test arbitrary object return by 'Get inventory'
*
* @return Array of object, HTTP status code, HTTP response headers (array of strings)
* @throws \Swagger\Client\ApiException on non-2xx response
*/
public function getInventoryInObjectWithHttpInfo()
{
// parse inputs
$resourcePath = "/store/inventory?response=arbitrary_object";
$httpBody = '';
$queryParams = array();
$headerParams = array();
$formParams = array();
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
if (!is_null($_header_accept)) {
$headerParams['Accept'] = $_header_accept;
}
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
// default format to json
$resourcePath = str_replace("{format}", "json", $resourcePath);
// for model (json/xml)
if (isset($_tempBody)) {
$httpBody = $_tempBody; // $_tempBody is the method argument, if present
} elseif (count($formParams) > 0) {
$httpBody = $formParams; // for HTTP post (form)
}
// this endpoint requires API key authentication
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
if (strlen($apiKey) !== 0) {
$headerParams['api_key'] = $apiKey;
}
// make the API Call
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
$resourcePath, 'GET',
$queryParams, $httpBody,
$headerParams, 'object'
);
if (!$response) {
return array(null, $statusCode, $httpHeader);
}
return array(\Swagger\Client\ObjectSerializer::deserialize($response, 'object', $httpHeader), $statusCode, $httpHeader);
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = \Swagger\Client\ObjectSerializer::deserialize($e->getResponseBody(), 'object', $e->getResponseHeaders());
$e->setResponseObject($data);
break;
}
throw $e;
}
}
/**
* placeOrder
*

View File

@ -230,7 +230,7 @@ class ApiClient
throw new ApiException("API call to $url timed out: ".serialize($response_info), 0, null, null);
} elseif ($response_info['http_code'] >= 200 && $response_info['http_code'] <= 299 ) {
// return raw body if response is a file
if ($responseType == '\SplFileObject' || $responseType == 'ByteArray') {
if ($responseType == '\SplFileObject' || $responseType == 'string') {
return array($http_body, $response_info['http_code'], $http_header);
}

View File

@ -241,8 +241,6 @@ class ObjectSerializer
$values[] = self::deserialize($value, $subClass);
}
$deserialized = $values;
} elseif ($class === 'ByteArray') { // byte array
$deserialized = unpack('C*', (string)$data);
} elseif ($class === '\DateTime') {
$deserialized = new \DateTime($data);
} elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) {

View File

@ -28,7 +28,7 @@
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
* Please update the test case below to test the model.
*/
namespace Swagger\Client\Model;

View File

@ -28,7 +28,7 @@
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
* Please update the test case below to test the model.
*/
namespace Swagger\Client\Model;

View File

@ -28,7 +28,7 @@
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
* Please update the test case below to test the endpoint.
*/
namespace Swagger\Client\Api;
@ -145,6 +145,16 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
}
/**
* Test case for getPetByIdInObject
*
* Fake endpoint to test inline arbitrary object return by 'Find pet by ID'
*
*/
public function test_getPetByIdInObject() {
}
/**
* Test case for petPetIdtestingByteArraytrueGet
*

View File

@ -28,7 +28,7 @@
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
* Please update the test case below to test the model.
*/
namespace Swagger\Client\Model;

View File

@ -28,7 +28,7 @@
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
* Please update the test case below to test the endpoint.
*/
namespace Swagger\Client\Api;
@ -85,6 +85,16 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase
}
/**
* Test case for getInventoryInObject
*
* Fake endpoint to test arbitrary object return by 'Get inventory'
*
*/
public function test_getInventoryInObject() {
}
/**
* Test case for placeOrder
*

View File

@ -28,7 +28,7 @@
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
* Please update the test case below to test the model.
*/
namespace Swagger\Client\Model;

View File

@ -28,7 +28,7 @@
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
* Please update the test case below to test the endpoint.
*/
namespace Swagger\Client\Api;

View File

@ -28,7 +28,7 @@
/**
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen
* Do not edit the class manually.
* Please update the test case below to test the model.
*/
namespace Swagger\Client\Model;

View File

@ -279,7 +279,7 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
// add a new pet (model)
$object_serializer = new Swagger\Client\ObjectSerializer();
$pet_json_string = json_encode($object_serializer->sanitizeForSerialization($new_pet));
$add_response = $pet_api->addPetUsingByteArray(unpack('C*', $pet_json_string));
$add_response = $pet_api->addPetUsingByteArray($pet_json_string);
// return nothing (void)
$this->assertSame($add_response, NULL);
// verify added Pet
@ -330,9 +330,9 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
// test getPetByIdWithByteArray
$pet_id = 10005;
$bytes = $pet_api->petPetIdtestingByteArraytrueGet($pet_id);
$json = json_decode(call_user_func_array('pack', array_merge(array('C*'), $bytes )), true);
$json = json_decode($bytes, true);
$this->assertInternalType("array", $bytes);
$this->assertInternalType("string", $bytes);
$this->assertSame($json['id'], $pet_id);
// not testing name as it's tested by addPetUsingByteArray

View File

@ -5,7 +5,10 @@ from .models.user import User
from .models.category import Category
from .models.pet import Pet
from .models.tag import Tag
from .models.object_return import ObjectReturn
from .models.order import Order
from .models.special_model_name import SpecialModelName
from .models.inline_response_200 import InlineResponse200
# import apis into sdk package
from .apis.user_api import UserApi

View File

@ -664,6 +664,83 @@ class PetApi(object):
callback=params.get('callback'))
return response
def get_pet_by_id_in_object(self, pet_id, **kwargs):
"""
Fake endpoint to test inline arbitrary object return by 'Find pet by ID'
Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.get_pet_by_id_in_object(pet_id, callback=callback_function)
:param callback function: The callback function
for asynchronous request. (optional)
:param int pet_id: ID of pet that needs to be fetched (required)
:return: InlineResponse200
If the method is called asynchronously,
returns the request thread.
"""
all_params = ['pet_id']
all_params.append('callback')
params = locals()
for key, val in iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method get_pet_by_id_in_object" % key
)
params[key] = val
del params['kwargs']
# verify the required parameter 'pet_id' is set
if ('pet_id' not in params) or (params['pet_id'] is None):
raise ValueError("Missing the required parameter `pet_id` when calling `get_pet_by_id_in_object`")
resource_path = '/pet/{petId}?response=inline_arbitrary_object'.replace('{format}', 'json')
path_params = {}
if 'pet_id' in params:
path_params['petId'] = params['pet_id']
query_params = {}
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.\
select_header_accept(['application/json', 'application/xml'])
if not header_params['Accept']:
del header_params['Accept']
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.\
select_header_content_type([])
# Authentication setting
auth_settings = ['api_key', 'petstore_auth']
response = self.api_client.call_api(resource_path, 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='InlineResponse200',
auth_settings=auth_settings,
callback=params.get('callback'))
return response
def pet_pet_idtesting_byte_arraytrue_get(self, pet_id, **kwargs):
"""
Fake endpoint to test byte array return by 'Find pet by ID'

View File

@ -190,6 +190,77 @@ class StoreApi(object):
callback=params.get('callback'))
return response
def get_inventory_in_object(self, **kwargs):
"""
Fake endpoint to test arbitrary object return by 'Get inventory'
Returns an arbitrary object which is actually a map of status codes to quantities
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please define a `callback` function
to be invoked when receiving the response.
>>> def callback_function(response):
>>> pprint(response)
>>>
>>> thread = api.get_inventory_in_object(callback=callback_function)
:param callback function: The callback function
for asynchronous request. (optional)
:return: object
If the method is called asynchronously,
returns the request thread.
"""
all_params = []
all_params.append('callback')
params = locals()
for key, val in iteritems(params['kwargs']):
if key not in all_params:
raise TypeError(
"Got an unexpected keyword argument '%s'"
" to method get_inventory_in_object" % key
)
params[key] = val
del params['kwargs']
resource_path = '/store/inventory?response=arbitrary_object'.replace('{format}', 'json')
path_params = {}
query_params = {}
header_params = {}
form_params = []
local_var_files = {}
body_params = None
# HTTP header `Accept`
header_params['Accept'] = self.api_client.\
select_header_accept(['application/json', 'application/xml'])
if not header_params['Accept']:
del header_params['Accept']
# HTTP header `Content-Type`
header_params['Content-Type'] = self.api_client.\
select_header_content_type([])
# Authentication setting
auth_settings = ['api_key']
response = self.api_client.call_api(resource_path, 'GET',
path_params,
query_params,
header_params,
body=body_params,
post_params=form_params,
files=local_var_files,
response_type='object',
auth_settings=auth_settings,
callback=params.get('callback'))
return response
def place_order(self, **kwargs):
"""
Place an order for a pet

View File

@ -5,4 +5,7 @@ from .user import User
from .category import Category
from .pet import Pet
from .tag import Tag
from .object_return import ObjectReturn
from .order import Order
from .special_model_name import SpecialModelName
from .inline_response_200 import InlineResponse200