forked from loafle/openapi-generator-original
Merge branch 'develop_2.0' into ruby-debug
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
SET CSCPATH=%SYSTEMROOT%\Microsoft.NET\Framework\v4.0.30319
|
||||
%CSCPATH%\csc /reference:bin/Newtonsoft.Json.dll;bin/RestSharp.dll /target:library /out:bin/IO.Swagger.Client.dll /recurse:src\*.cs /doc:bin/IO.Swagger.Client.xml
|
||||
%CSCPATH%\csc /reference:bin/Newtonsoft.Json.dll;bin/RestSharp.dll /target:library /out:bin/.dll /recurse:src\*.cs /doc:bin/.xml
|
||||
|
||||
@@ -4,7 +4,6 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using IO.Swagger.Client;
|
||||
|
||||
namespace IO.Swagger.Client {
|
||||
/// <summary>
|
||||
@@ -12,6 +11,11 @@ namespace IO.Swagger.Client {
|
||||
/// </summary>
|
||||
public class Configuration{
|
||||
|
||||
/// <summary>
|
||||
/// Version of the package
|
||||
/// </summary>
|
||||
public const string Version = "1.0.0";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the API client. This is the default API client for making HTTP calls.
|
||||
/// </summary>
|
||||
@@ -49,6 +49,4 @@ namespace IO.Swagger.Model {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -77,6 +77,4 @@ namespace IO.Swagger.Model {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -77,6 +77,4 @@ namespace IO.Swagger.Model {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -49,6 +49,4 @@ namespace IO.Swagger.Model {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -91,6 +91,4 @@ namespace IO.Swagger.Model {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{1011E844-3414-4D65-BF1F-7C8CE0167174}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>SwaggerClientTest</RootNamespace>
|
||||
<AssemblyName>SwaggerClientTest</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath>packages\NUnit.2.6.3\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>Lib\SwaggerClient\bin\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp">
|
||||
<HintPath>Lib\SwaggerClient\bin\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Api\PetApi.cs" />
|
||||
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Api\StoreApi.cs" />
|
||||
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Api\UserApi.cs" />
|
||||
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Client\ApiClient.cs" />
|
||||
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Client\ApiException.cs" />
|
||||
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Client\Configuration.cs" />
|
||||
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Model\Category.cs" />
|
||||
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Model\Order.cs" />
|
||||
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Model\Pet.cs" />
|
||||
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Model\Tag.cs" />
|
||||
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Model\User.cs" />
|
||||
<Compile Include="TestPet.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Lib\SwaggerClient\compile.bat" />
|
||||
<None Include="Lib\SwaggerClient\bin\Newtonsoft.Json.dll" />
|
||||
<None Include="Lib\SwaggerClient\bin\RestSharp.dll" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Lib\" />
|
||||
<Folder Include="Lib\SwaggerClient\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,17 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwaggerClientTest", "SwaggerClientTest.csproj", "{1011E844-3414-4D65-BF1F-7C8CE0167174}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1011E844-3414-4D65-BF1F-7C8CE0167174}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1011E844-3414-4D65-BF1F-7C8CE0167174}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1011E844-3414-4D65-BF1F-7C8CE0167174}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1011E844-3414-4D65-BF1F-7C8CE0167174}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,13 @@
|
||||
<Properties StartupItem="SwaggerClientTest.csproj">
|
||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||
<MonoDevelop.Ide.Workbench ActiveDocument="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs">
|
||||
<Files>
|
||||
<File FileName="TestPet.cs" Line="110" Column="1" />
|
||||
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs" Line="11" Column="7" />
|
||||
</Files>
|
||||
</MonoDevelop.Ide.Workbench>
|
||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
<BreakpointStore />
|
||||
</MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
|
||||
</Properties>
|
||||
109
samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs
Normal file
109
samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using IO.Swagger.Api;
|
||||
using IO.Swagger.Model;
|
||||
using IO.Swagger.Client;
|
||||
|
||||
|
||||
namespace SwaggerClient.TestPet
|
||||
{
|
||||
[TestFixture ()]
|
||||
public class TestPet
|
||||
{
|
||||
public long petId = 11088;
|
||||
|
||||
[SetUp] public void Init()
|
||||
{
|
||||
// create pet
|
||||
Pet p = new Pet();
|
||||
p.Id = petId;
|
||||
p.Name = "Csharp test";
|
||||
p.Status = "available";
|
||||
// create Category object
|
||||
Category category = new Category();
|
||||
category.Id = 56;
|
||||
category.Name = "sample category name2";
|
||||
List<String> photoUrls = new List<String>(new String[] {"sample photoUrls"});
|
||||
// create Tag object
|
||||
Tag tag = new Tag();
|
||||
tag.Id = petId;
|
||||
tag.Name = "sample tag name1";
|
||||
List<Tag> tags = new List<Tag>(new Tag[] {tag});
|
||||
p.Tags = tags;
|
||||
p.Category = category;
|
||||
p.PhotoUrls = photoUrls;
|
||||
|
||||
// add pet before testing
|
||||
PetApi petApi = new PetApi("http://petstore.swagger.io/v2/");
|
||||
petApi.AddPet (p);
|
||||
|
||||
}
|
||||
|
||||
[TearDown] public void Cleanup()
|
||||
{
|
||||
// remove the pet after testing
|
||||
PetApi petApi = new PetApi ();
|
||||
petApi.DeletePet("test key", petId);
|
||||
}
|
||||
|
||||
|
||||
[Test ()]
|
||||
public void TestGetPetById ()
|
||||
{
|
||||
PetApi petApi = new PetApi ();
|
||||
Pet response = petApi.GetPetById (petId);
|
||||
Assert.IsInstanceOf<Pet> (response, "Response is a Pet");
|
||||
|
||||
Assert.AreEqual ("Csharp test", response.Name);
|
||||
Assert.AreEqual ("available", response.Status);
|
||||
|
||||
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
|
||||
Assert.AreEqual (petId, response.Tags [0].Id);
|
||||
Assert.AreEqual ("sample tag name1", response.Tags [0].Name);
|
||||
|
||||
Assert.IsInstanceOf<List<String>> (response.PhotoUrls, "Response.PhotoUrls is a Array");
|
||||
Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
|
||||
|
||||
Assert.IsInstanceOf<Category> (response.Category, "Response.Category is a Category");
|
||||
Assert.AreEqual (56, response.Category.Id);
|
||||
Assert.AreEqual ("sample category name2", response.Category.Name);
|
||||
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestUpdatePetWithForm ()
|
||||
{
|
||||
PetApi petApi = new PetApi ();
|
||||
petApi.UpdatePetWithForm (petId.ToString(), "new form name", "pending");
|
||||
|
||||
Pet response = petApi.GetPetById (petId);
|
||||
Assert.IsInstanceOf<Pet> (response, "Response is a Pet");
|
||||
Assert.IsInstanceOf<Category> (response.Category, "Response.Category is a Category");
|
||||
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
|
||||
|
||||
Assert.AreEqual ("new form name", response.Name);
|
||||
Assert.AreEqual ("pending", response.Status);
|
||||
|
||||
Assert.AreEqual (petId, response.Tags [0].Id);
|
||||
Assert.AreEqual (56, response.Category.Id);
|
||||
}
|
||||
|
||||
[Test ()]
|
||||
public void TestFindPetByStatus ()
|
||||
{
|
||||
PetApi petApi = new PetApi ();
|
||||
List<String> statusList = new List<String>(new String[] {"available"});
|
||||
|
||||
List<Pet> listPet = petApi.FindPetsByStatus (statusList);
|
||||
foreach (Pet pet in listPet) // Loop through List with foreach.
|
||||
{
|
||||
Assert.IsInstanceOf<Pet> (pet, "Response is a Pet");
|
||||
Assert.AreEqual ("available", pet.Status);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
BIN
samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll
Executable file
BIN
samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll
Executable file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,2 @@
|
||||
// <autogenerated />
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.5", FrameworkDisplayName = "")]
|
||||
@@ -0,0 +1,8 @@
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll
|
||||
/Users/williamcheng/Code/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb
|
||||
BIN
samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll
Executable file
BIN
samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll
Executable file
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NUnit" version="2.6.3" targetFramework="net45" />
|
||||
</packages>
|
||||
BIN
samples/client/petstore/csharp/SwaggerClientTest/packages/NUnit.2.6.3/NUnit.2.6.3.nupkg
vendored
Normal file
BIN
samples/client/petstore/csharp/SwaggerClientTest/packages/NUnit.2.6.3/NUnit.2.6.3.nupkg
vendored
Normal file
Binary file not shown.
BIN
samples/client/petstore/csharp/SwaggerClientTest/packages/NUnit.2.6.3/lib/nunit.framework.dll
vendored
Normal file
BIN
samples/client/petstore/csharp/SwaggerClientTest/packages/NUnit.2.6.3/lib/nunit.framework.dll
vendored
Normal file
Binary file not shown.
10960
samples/client/petstore/csharp/SwaggerClientTest/packages/NUnit.2.6.3/lib/nunit.framework.xml
vendored
Normal file
10960
samples/client/petstore/csharp/SwaggerClientTest/packages/NUnit.2.6.3/lib/nunit.framework.xml
vendored
Normal file
File diff suppressed because it is too large
Load Diff
15
samples/client/petstore/csharp/SwaggerClientTest/packages/NUnit.2.6.3/license.txt
vendored
Normal file
15
samples/client/petstore/csharp/SwaggerClientTest/packages/NUnit.2.6.3/license.txt
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
Copyright <20> 2002-2013 Charlie Poole
|
||||
Copyright <20> 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov
|
||||
Copyright <20> 2000-2002 Philip A. Craig
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment (see the following) in the product documentation is required.
|
||||
|
||||
Portions Copyright <20> 2002-2013 Charlie Poole or Copyright <20> 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov or Copyright <20> 2000-2002 Philip A. Craig
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<repositories>
|
||||
<repository path="../packages.config" />
|
||||
</repositories>
|
||||
@@ -420,10 +420,10 @@ public class ApiClient {
|
||||
throw new ApiException(500, "unknown method type " + method);
|
||||
}
|
||||
|
||||
if(response.getClientResponseStatus() == ClientResponse.Status.NO_CONTENT) {
|
||||
if(response.getStatusInfo() == ClientResponse.Status.NO_CONTENT) {
|
||||
return null;
|
||||
}
|
||||
else if(response.getClientResponseStatus().getFamily() == Family.SUCCESSFUL) {
|
||||
else if(response.getStatusInfo().getFamily() == Family.SUCCESSFUL) {
|
||||
if(response.hasEntity()) {
|
||||
return (String) response.getEntity(String.class);
|
||||
}
|
||||
@@ -444,7 +444,7 @@ public class ApiClient {
|
||||
}
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getClientResponseStatus().getStatusCode(),
|
||||
response.getStatusInfo().getStatusCode(),
|
||||
message,
|
||||
response.getHeaders(),
|
||||
respBody);
|
||||
|
||||
@@ -322,7 +322,7 @@ public class PetApi {
|
||||
}
|
||||
|
||||
try {
|
||||
String[] authNames = new String[] { "petstore_auth", "api_key" };
|
||||
String[] authNames = new String[] { "api_key", "petstore_auth" };
|
||||
String response = apiClient.invokeAPI(path, "GET", queryParams, postBody, headerParams, formParams, accept, contentType, authNames);
|
||||
if(response != null){
|
||||
return (Pet) apiClient.deserialize(response, "", Pet.class);
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package io.swagger.client.model;
|
||||
|
||||
import io.swagger.client.model.Category;
|
||||
import java.util.*;
|
||||
import io.swagger.client.model.Tag;
|
||||
import java.util.*;
|
||||
|
||||
import io.swagger.annotations.*;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
@@ -22,30 +22,28 @@
|
||||
|
||||
namespace Swagger\Client\Api;
|
||||
|
||||
use \Swagger\Client\ApiClient;
|
||||
use \Swagger\Client\Configuration;
|
||||
use \Swagger\Client\ApiClient;
|
||||
use \Swagger\Client\ApiException;
|
||||
use \Swagger\Client\ObjectSerializer;
|
||||
|
||||
class PetApi {
|
||||
|
||||
/**
|
||||
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use. Defaults to getting it from Configuration
|
||||
*/
|
||||
function __construct($apiClient = null) {
|
||||
if (null === $apiClient) {
|
||||
if (Configuration::$apiClient === null) {
|
||||
Configuration::$apiClient = new ApiClient(); // create a new API client if not present
|
||||
$this->apiClient = Configuration::$apiClient;
|
||||
}
|
||||
else
|
||||
$this->apiClient = Configuration::$apiClient; // use the default one
|
||||
} else {
|
||||
$this->apiClient = $apiClient; // use the one provided by the user
|
||||
}
|
||||
}
|
||||
|
||||
/** @var \Swagger\Client\ApiClient instance of the ApiClient */
|
||||
private $apiClient;
|
||||
|
||||
/**
|
||||
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use
|
||||
*/
|
||||
function __construct($apiClient = null) {
|
||||
if ($apiClient == null) {
|
||||
$apiClient = new ApiClient();
|
||||
$apiClient->getConfig()->setHost('http://petstore.swagger.io/v2');
|
||||
}
|
||||
|
||||
$this->apiClient = $apiClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Swagger\Client\ApiClient get the API client
|
||||
*/
|
||||
@@ -54,10 +52,12 @@ class PetApi {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Swagger\Client $apiClient set the API client
|
||||
* @param \Swagger\Client\ApiClient $apiClient set the API client
|
||||
* @return PetApi
|
||||
*/
|
||||
public function setApiClient($apiClient) {
|
||||
public function setApiClient(ApiClient $apiClient) {
|
||||
$this->apiClient = $apiClient;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ class PetApi {
|
||||
*
|
||||
* @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required)
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function updatePet($body) {
|
||||
|
||||
@@ -80,11 +81,11 @@ class PetApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml'));
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json','application/xml'));
|
||||
|
||||
|
||||
|
||||
@@ -103,14 +104,21 @@ class PetApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array('petstore_auth');
|
||||
|
||||
|
||||
|
||||
//TODO support oauth
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -121,6 +129,7 @@ class PetApi {
|
||||
*
|
||||
* @param \Swagger\Client\Model\Pet $body Pet object that needs to be added to the store (required)
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function addPet($body) {
|
||||
|
||||
@@ -133,11 +142,11 @@ class PetApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/json','application/xml'));
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/json','application/xml'));
|
||||
|
||||
|
||||
|
||||
@@ -156,14 +165,21 @@ class PetApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array('petstore_auth');
|
||||
|
||||
|
||||
|
||||
//TODO support oauth
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -174,6 +190,7 @@ class PetApi {
|
||||
*
|
||||
* @param string[] $status Status values that need to be considered for filter (required)
|
||||
* @return \Swagger\Client\Model\Pet[]
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function findPetsByStatus($status) {
|
||||
|
||||
@@ -186,15 +203,15 @@ class PetApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
|
||||
|
||||
// query params
|
||||
if($status !== null) {
|
||||
$queryParams['status'] = $this->apiClient->toQueryValue($status);
|
||||
$queryParams['status'] = $this->apiClient->getSerializer()->toQueryValue($status);
|
||||
}
|
||||
|
||||
|
||||
@@ -208,20 +225,33 @@ class PetApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array('petstore_auth');
|
||||
|
||||
|
||||
|
||||
//TODO support oauth
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
if(! $response) {
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Pet[]');
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (!$response) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->deserialize($response,'\Swagger\Client\Model\Pet[]');
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Pet[]');
|
||||
return $responseObject;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,6 +261,7 @@ class PetApi {
|
||||
*
|
||||
* @param string[] $tags Tags to filter by (required)
|
||||
* @return \Swagger\Client\Model\Pet[]
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function findPetsByTags($tags) {
|
||||
|
||||
@@ -243,15 +274,15 @@ class PetApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
|
||||
|
||||
// query params
|
||||
if($tags !== null) {
|
||||
$queryParams['tags'] = $this->apiClient->toQueryValue($tags);
|
||||
$queryParams['tags'] = $this->apiClient->getSerializer()->toQueryValue($tags);
|
||||
}
|
||||
|
||||
|
||||
@@ -265,20 +296,33 @@ class PetApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array('petstore_auth');
|
||||
|
||||
|
||||
|
||||
//TODO support oauth
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
if(! $response) {
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Pet[]');
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (!$response) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->deserialize($response,'\Swagger\Client\Model\Pet[]');
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Pet[]');
|
||||
return $responseObject;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,6 +332,7 @@ class PetApi {
|
||||
*
|
||||
* @param int $pet_id ID of pet that needs to be fetched (required)
|
||||
* @return \Swagger\Client\Model\Pet
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function getPetById($pet_id) {
|
||||
|
||||
@@ -305,18 +350,19 @@ class PetApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
|
||||
|
||||
|
||||
|
||||
// path params
|
||||
if($pet_id !== null) {
|
||||
$resourcePath = str_replace("{" . "petId" . "}",
|
||||
$this->apiClient->toPathValue($pet_id), $resourcePath);
|
||||
$this->apiClient->getSerializer()->toPathValue($pet_id),
|
||||
$resourcePath);
|
||||
}
|
||||
|
||||
|
||||
@@ -328,20 +374,40 @@ class PetApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
//TODO support oauth
|
||||
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array('api_key', 'petstore_auth');
|
||||
|
||||
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
|
||||
if (isset($apiKey)) {
|
||||
$headerParams['api_key'] = $apiKey;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
if(! $response) {
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Pet');
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (!$response) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->deserialize($response,'\Swagger\Client\Model\Pet');
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Pet');
|
||||
return $responseObject;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -353,6 +419,7 @@ class PetApi {
|
||||
* @param string $name Updated name of the pet (required)
|
||||
* @param string $status Updated status of the pet (required)
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function updatePetWithForm($pet_id, $name, $status) {
|
||||
|
||||
@@ -370,25 +437,26 @@ class PetApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('application/x-www-form-urlencoded'));
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('application/x-www-form-urlencoded'));
|
||||
|
||||
|
||||
|
||||
// path params
|
||||
if($pet_id !== null) {
|
||||
$resourcePath = str_replace("{" . "petId" . "}",
|
||||
$this->apiClient->toPathValue($pet_id), $resourcePath);
|
||||
$this->apiClient->getSerializer()->toPathValue($pet_id),
|
||||
$resourcePath);
|
||||
}
|
||||
// form params
|
||||
if ($name !== null) {
|
||||
$formParams['name'] = $this->apiClient->toFormValue($name);
|
||||
$formParams['name'] = $this->apiClient->getSerializer()->toFormValue($name);
|
||||
}// form params
|
||||
if ($status !== null) {
|
||||
$formParams['status'] = $this->apiClient->toFormValue($status);
|
||||
$formParams['status'] = $this->apiClient->getSerializer()->toFormValue($status);
|
||||
}
|
||||
|
||||
|
||||
@@ -399,14 +467,21 @@ class PetApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array('petstore_auth');
|
||||
|
||||
|
||||
|
||||
//TODO support oauth
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -418,6 +493,7 @@ class PetApi {
|
||||
* @param string $api_key (required)
|
||||
* @param int $pet_id Pet id to delete (required)
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function deletePet($api_key, $pet_id) {
|
||||
|
||||
@@ -435,21 +511,22 @@ class PetApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
|
||||
|
||||
|
||||
// header params
|
||||
if($api_key !== null) {
|
||||
$headerParams['api_key'] = $this->apiClient->toHeaderValue($api_key);
|
||||
$headerParams['api_key'] = $this->apiClient->getSerializer()->toHeaderValue($api_key);
|
||||
}
|
||||
// path params
|
||||
if($pet_id !== null) {
|
||||
$resourcePath = str_replace("{" . "petId" . "}",
|
||||
$this->apiClient->toPathValue($pet_id), $resourcePath);
|
||||
$this->apiClient->getSerializer()->toPathValue($pet_id),
|
||||
$resourcePath);
|
||||
}
|
||||
|
||||
|
||||
@@ -461,14 +538,21 @@ class PetApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array('petstore_auth');
|
||||
|
||||
|
||||
|
||||
//TODO support oauth
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -481,6 +565,7 @@ class PetApi {
|
||||
* @param string $additional_metadata Additional data to pass to server (required)
|
||||
* @param string $file file to upload (required)
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function uploadFile($pet_id, $additional_metadata, $file) {
|
||||
|
||||
@@ -498,25 +583,26 @@ class PetApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array('multipart/form-data'));
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array('multipart/form-data'));
|
||||
|
||||
|
||||
|
||||
// path params
|
||||
if($pet_id !== null) {
|
||||
$resourcePath = str_replace("{" . "petId" . "}",
|
||||
$this->apiClient->toPathValue($pet_id), $resourcePath);
|
||||
$this->apiClient->getSerializer()->toPathValue($pet_id),
|
||||
$resourcePath);
|
||||
}
|
||||
// form params
|
||||
if ($additional_metadata !== null) {
|
||||
$formParams['additionalMetadata'] = $this->apiClient->toFormValue($additional_metadata);
|
||||
$formParams['additionalMetadata'] = $this->apiClient->getSerializer()->toFormValue($additional_metadata);
|
||||
}// form params
|
||||
if ($file !== null) {
|
||||
$formParams['file'] = '@' . $this->apiClient->toFormValue($file);
|
||||
$formParams['file'] = '@' . $this->apiClient->getSerializer()->toFormValue($file);
|
||||
}
|
||||
|
||||
|
||||
@@ -527,16 +613,22 @@ class PetApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array('petstore_auth');
|
||||
|
||||
|
||||
|
||||
//TODO support oauth
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,30 +22,28 @@
|
||||
|
||||
namespace Swagger\Client\Api;
|
||||
|
||||
use \Swagger\Client\ApiClient;
|
||||
use \Swagger\Client\Configuration;
|
||||
use \Swagger\Client\ApiClient;
|
||||
use \Swagger\Client\ApiException;
|
||||
use \Swagger\Client\ObjectSerializer;
|
||||
|
||||
class StoreApi {
|
||||
|
||||
/**
|
||||
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use. Defaults to getting it from Configuration
|
||||
*/
|
||||
function __construct($apiClient = null) {
|
||||
if (null === $apiClient) {
|
||||
if (Configuration::$apiClient === null) {
|
||||
Configuration::$apiClient = new ApiClient(); // create a new API client if not present
|
||||
$this->apiClient = Configuration::$apiClient;
|
||||
}
|
||||
else
|
||||
$this->apiClient = Configuration::$apiClient; // use the default one
|
||||
} else {
|
||||
$this->apiClient = $apiClient; // use the one provided by the user
|
||||
}
|
||||
}
|
||||
|
||||
/** @var \Swagger\Client\ApiClient instance of the ApiClient */
|
||||
private $apiClient;
|
||||
|
||||
/**
|
||||
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use
|
||||
*/
|
||||
function __construct($apiClient = null) {
|
||||
if ($apiClient == null) {
|
||||
$apiClient = new ApiClient();
|
||||
$apiClient->getConfig()->setHost('http://petstore.swagger.io/v2');
|
||||
}
|
||||
|
||||
$this->apiClient = $apiClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Swagger\Client\ApiClient get the API client
|
||||
*/
|
||||
@@ -54,10 +52,12 @@ class StoreApi {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Swagger\Client $apiClient set the API client
|
||||
* @param \Swagger\Client\ApiClient $apiClient set the API client
|
||||
* @return StoreApi
|
||||
*/
|
||||
public function setApiClient($apiClient) {
|
||||
public function setApiClient(ApiClient $apiClient) {
|
||||
$this->apiClient = $apiClient;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ class StoreApi {
|
||||
* Returns pet inventories by status
|
||||
*
|
||||
* @return map[string,int]
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function getInventory() {
|
||||
|
||||
@@ -79,11 +80,11 @@ class StoreApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
|
||||
|
||||
|
||||
|
||||
@@ -98,20 +99,37 @@ class StoreApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array('api_key');
|
||||
|
||||
|
||||
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
|
||||
if (isset($apiKey)) {
|
||||
$headerParams['api_key'] = $apiKey;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
if(! $response) {
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), 'map[string,int]');
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (!$response) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->deserialize($response,'map[string,int]');
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'map[string,int]');
|
||||
return $responseObject;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -121,6 +139,7 @@ class StoreApi {
|
||||
*
|
||||
* @param \Swagger\Client\Model\Order $body order placed for purchasing the pet (required)
|
||||
* @return \Swagger\Client\Model\Order
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function placeOrder($body) {
|
||||
|
||||
@@ -133,11 +152,11 @@ class StoreApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
|
||||
|
||||
|
||||
|
||||
@@ -156,20 +175,30 @@ class StoreApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array();
|
||||
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
if(! $response) {
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Order');
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (!$response) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->deserialize($response,'\Swagger\Client\Model\Order');
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Order');
|
||||
return $responseObject;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,6 +208,7 @@ class StoreApi {
|
||||
*
|
||||
* @param string $order_id ID of pet that needs to be fetched (required)
|
||||
* @return \Swagger\Client\Model\Order
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function getOrderById($order_id) {
|
||||
|
||||
@@ -196,18 +226,19 @@ class StoreApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
|
||||
|
||||
|
||||
|
||||
// path params
|
||||
if($order_id !== null) {
|
||||
$resourcePath = str_replace("{" . "orderId" . "}",
|
||||
$this->apiClient->toPathValue($order_id), $resourcePath);
|
||||
$this->apiClient->getSerializer()->toPathValue($order_id),
|
||||
$resourcePath);
|
||||
}
|
||||
|
||||
|
||||
@@ -219,20 +250,30 @@ class StoreApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array();
|
||||
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
if(! $response) {
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\Order');
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (!$response) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->deserialize($response,'\Swagger\Client\Model\Order');
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\Order');
|
||||
return $responseObject;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -242,6 +283,7 @@ class StoreApi {
|
||||
*
|
||||
* @param string $order_id ID of the order that needs to be deleted (required)
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function deleteOrder($order_id) {
|
||||
|
||||
@@ -259,18 +301,19 @@ class StoreApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
|
||||
|
||||
|
||||
|
||||
// path params
|
||||
if($order_id !== null) {
|
||||
$resourcePath = str_replace("{" . "orderId" . "}",
|
||||
$this->apiClient->toPathValue($order_id), $resourcePath);
|
||||
$this->apiClient->getSerializer()->toPathValue($order_id),
|
||||
$resourcePath);
|
||||
}
|
||||
|
||||
|
||||
@@ -282,16 +325,19 @@ class StoreApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array();
|
||||
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,30 +22,28 @@
|
||||
|
||||
namespace Swagger\Client\Api;
|
||||
|
||||
use \Swagger\Client\ApiClient;
|
||||
use \Swagger\Client\Configuration;
|
||||
use \Swagger\Client\ApiClient;
|
||||
use \Swagger\Client\ApiException;
|
||||
use \Swagger\Client\ObjectSerializer;
|
||||
|
||||
class UserApi {
|
||||
|
||||
/**
|
||||
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use. Defaults to getting it from Configuration
|
||||
*/
|
||||
function __construct($apiClient = null) {
|
||||
if (null === $apiClient) {
|
||||
if (Configuration::$apiClient === null) {
|
||||
Configuration::$apiClient = new ApiClient(); // create a new API client if not present
|
||||
$this->apiClient = Configuration::$apiClient;
|
||||
}
|
||||
else
|
||||
$this->apiClient = Configuration::$apiClient; // use the default one
|
||||
} else {
|
||||
$this->apiClient = $apiClient; // use the one provided by the user
|
||||
}
|
||||
}
|
||||
|
||||
/** @var \Swagger\Client\ApiClient instance of the ApiClient */
|
||||
private $apiClient;
|
||||
|
||||
/**
|
||||
* @param \Swagger\Client\ApiClient|null $apiClient The api client to use
|
||||
*/
|
||||
function __construct($apiClient = null) {
|
||||
if ($apiClient == null) {
|
||||
$apiClient = new ApiClient();
|
||||
$apiClient->getConfig()->setHost('http://petstore.swagger.io/v2');
|
||||
}
|
||||
|
||||
$this->apiClient = $apiClient;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Swagger\Client\ApiClient get the API client
|
||||
*/
|
||||
@@ -54,10 +52,12 @@ class UserApi {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Swagger\Client $apiClient set the API client
|
||||
* @param \Swagger\Client\ApiClient $apiClient set the API client
|
||||
* @return UserApi
|
||||
*/
|
||||
public function setApiClient($apiClient) {
|
||||
public function setApiClient(ApiClient $apiClient) {
|
||||
$this->apiClient = $apiClient;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,6 +68,7 @@ class UserApi {
|
||||
*
|
||||
* @param \Swagger\Client\Model\User $body Created user object (required)
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function createUser($body) {
|
||||
|
||||
@@ -80,11 +81,11 @@ class UserApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
|
||||
|
||||
|
||||
|
||||
@@ -103,14 +104,18 @@ class UserApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array();
|
||||
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -121,6 +126,7 @@ class UserApi {
|
||||
*
|
||||
* @param \Swagger\Client\Model\User[] $body List of user object (required)
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function createUsersWithArrayInput($body) {
|
||||
|
||||
@@ -133,11 +139,11 @@ class UserApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
|
||||
|
||||
|
||||
|
||||
@@ -156,14 +162,18 @@ class UserApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array();
|
||||
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -174,6 +184,7 @@ class UserApi {
|
||||
*
|
||||
* @param \Swagger\Client\Model\User[] $body List of user object (required)
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function createUsersWithListInput($body) {
|
||||
|
||||
@@ -186,11 +197,11 @@ class UserApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
|
||||
|
||||
|
||||
|
||||
@@ -209,14 +220,18 @@ class UserApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array();
|
||||
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -228,6 +243,7 @@ class UserApi {
|
||||
* @param string $username The user name for login (required)
|
||||
* @param string $password The password for login in clear text (required)
|
||||
* @return string
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function loginUser($username, $password) {
|
||||
|
||||
@@ -240,18 +256,18 @@ class UserApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
|
||||
|
||||
// query params
|
||||
if($username !== null) {
|
||||
$queryParams['username'] = $this->apiClient->toQueryValue($username);
|
||||
$queryParams['username'] = $this->apiClient->getSerializer()->toQueryValue($username);
|
||||
}// query params
|
||||
if($password !== null) {
|
||||
$queryParams['password'] = $this->apiClient->toQueryValue($password);
|
||||
$queryParams['password'] = $this->apiClient->getSerializer()->toQueryValue($password);
|
||||
}
|
||||
|
||||
|
||||
@@ -265,20 +281,30 @@ class UserApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array();
|
||||
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
if(! $response) {
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), 'string');
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (!$response) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->deserialize($response,'string');
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'string');
|
||||
return $responseObject;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,6 +313,7 @@ class UserApi {
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function logoutUser() {
|
||||
|
||||
@@ -299,11 +326,11 @@ class UserApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
|
||||
|
||||
|
||||
|
||||
@@ -318,14 +345,18 @@ class UserApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array();
|
||||
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -336,6 +367,7 @@ class UserApi {
|
||||
*
|
||||
* @param string $username The name that needs to be fetched. Use user1 for testing. (required)
|
||||
* @return \Swagger\Client\Model\User
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function getUserByName($username) {
|
||||
|
||||
@@ -353,18 +385,19 @@ class UserApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
|
||||
|
||||
|
||||
|
||||
// path params
|
||||
if($username !== null) {
|
||||
$resourcePath = str_replace("{" . "username" . "}",
|
||||
$this->apiClient->toPathValue($username), $resourcePath);
|
||||
$this->apiClient->getSerializer()->toPathValue($username),
|
||||
$resourcePath);
|
||||
}
|
||||
|
||||
|
||||
@@ -376,20 +409,30 @@ class UserApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array();
|
||||
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
if(! $response) {
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case 200:
|
||||
$data = $this->apiClient->getSerializer()->deserialize($e->getResponseBody(), '\Swagger\Client\Model\User');
|
||||
$e->setResponseObject($data);
|
||||
break;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
if (!$response) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$responseObject = $this->apiClient->deserialize($response,'\Swagger\Client\Model\User');
|
||||
$responseObject = $this->apiClient->getSerializer()->deserialize($response,'\Swagger\Client\Model\User');
|
||||
return $responseObject;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,6 +443,7 @@ class UserApi {
|
||||
* @param string $username name that need to be deleted (required)
|
||||
* @param \Swagger\Client\Model\User $body Updated user object (required)
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function updateUser($username, $body) {
|
||||
|
||||
@@ -417,18 +461,19 @@ class UserApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
|
||||
|
||||
|
||||
|
||||
// path params
|
||||
if($username !== null) {
|
||||
$resourcePath = str_replace("{" . "username" . "}",
|
||||
$this->apiClient->toPathValue($username), $resourcePath);
|
||||
$this->apiClient->getSerializer()->toPathValue($username),
|
||||
$resourcePath);
|
||||
}
|
||||
|
||||
// body params
|
||||
@@ -444,14 +489,18 @@ class UserApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array();
|
||||
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -462,6 +511,7 @@ class UserApi {
|
||||
*
|
||||
* @param string $username The name that needs to be deleted (required)
|
||||
* @return void
|
||||
* @throws \Swagger\Client\ApiException on non-2xx response
|
||||
*/
|
||||
public function deleteUser($username) {
|
||||
|
||||
@@ -479,18 +529,19 @@ class UserApi {
|
||||
$queryParams = array();
|
||||
$headerParams = array();
|
||||
$formParams = array();
|
||||
$_header_accept = $this->apiClient->selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
$_header_accept = ApiClient::selectHeaderAccept(array('application/json', 'application/xml'));
|
||||
if (!is_null($_header_accept)) {
|
||||
$headerParams['Accept'] = $_header_accept;
|
||||
}
|
||||
$headerParams['Content-Type'] = $this->apiClient->selectHeaderContentType(array());
|
||||
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
|
||||
|
||||
|
||||
|
||||
// path params
|
||||
if($username !== null) {
|
||||
$resourcePath = str_replace("{" . "username" . "}",
|
||||
$this->apiClient->toPathValue($username), $resourcePath);
|
||||
$this->apiClient->getSerializer()->toPathValue($username),
|
||||
$resourcePath);
|
||||
}
|
||||
|
||||
|
||||
@@ -502,16 +553,19 @@ class UserApi {
|
||||
// for HTTP post (form)
|
||||
$httpBody = $formParams;
|
||||
}
|
||||
|
||||
// authentication setting, if any
|
||||
$authSettings = array();
|
||||
|
||||
|
||||
// make the API Call
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams, $authSettings);
|
||||
try {
|
||||
$response = $this->apiClient->callAPI($resourcePath, $method,
|
||||
$queryParams, $httpBody,
|
||||
$headerParams);
|
||||
} catch (ApiException $e) {
|
||||
switch ($e->getCode()) {
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -25,146 +25,60 @@ class ApiClient {
|
||||
public static $PUT = "PUT";
|
||||
public static $DELETE = "DELETE";
|
||||
|
||||
/** @var string[] Array of default headers where the key is the header name and the value is the header value */
|
||||
private $default_header = array();
|
||||
/** @var Configuration */
|
||||
protected $config;
|
||||
|
||||
/** @var string timeout (second) of the HTTP request, by default set to 0, no timeout */
|
||||
protected $curl_timeout = 0;
|
||||
|
||||
/** @var string user agent of the HTTP request, set to "PHP-Swagger" by default */
|
||||
protected $user_agent = "PHP-Swagger";
|
||||
/** @var ObjectSerializer */
|
||||
protected $serializer;
|
||||
|
||||
/**
|
||||
* @param string $host Base url of the API server (optional)
|
||||
* @param Configuration $config config for this ApiClient
|
||||
*/
|
||||
function __construct($host = null) {
|
||||
if ($host === null) {
|
||||
$this->host = 'http://petstore.swagger.io/v2';
|
||||
} else {
|
||||
$this->host = $host;
|
||||
function __construct(Configuration $config = null) {
|
||||
if ($config == null) {
|
||||
$config = Configuration::getDefaultConfiguration();
|
||||
}
|
||||
|
||||
$this->config = $config;
|
||||
$this->serializer = new ObjectSerializer();
|
||||
}
|
||||
|
||||
/**
|
||||
* add default header
|
||||
*
|
||||
* @param string $header_name header name (e.g. Token)
|
||||
* @param string $header_value header value (e.g. 1z8wp3)
|
||||
* get the config
|
||||
* @return Configuration
|
||||
*/
|
||||
public function addDefaultHeader($header_name, $header_value) {
|
||||
if (!is_string($header_name))
|
||||
throw new \InvalidArgumentException('Header name must be a string.');
|
||||
|
||||
$this->default_header[$header_name] = $header_value;
|
||||
public function getConfig() {
|
||||
return $this->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the default header
|
||||
*
|
||||
* @return array default header
|
||||
* get the serializer
|
||||
* @return ObjectSerializer
|
||||
*/
|
||||
public function getDefaultHeader() {
|
||||
return $this->default_header;
|
||||
public function getSerializer() {
|
||||
return $this->serializer;
|
||||
}
|
||||
|
||||
/**
|
||||
* delete the default header based on header name
|
||||
*
|
||||
* @param string $header_name header name (e.g. Token)
|
||||
*/
|
||||
public function deleteDefaultHeader($header_name) {
|
||||
unset($this->default_header[$header_name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* set the user agent of the api client
|
||||
*
|
||||
* @param string $user_agent the user agent of the api client
|
||||
*/
|
||||
public function setUserAgent($user_agent) {
|
||||
if (!is_string($user_agent))
|
||||
throw new \InvalidArgumentException('User-agent must be a string.');
|
||||
|
||||
$this->user_agent= $user_agent;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the user agent of the api client
|
||||
*
|
||||
* @return string user agent
|
||||
*/
|
||||
public function getUserAgent($user_agent) {
|
||||
return $this->user_agent;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the HTTP timeout value
|
||||
*
|
||||
* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
|
||||
*/
|
||||
public function setTimeout($seconds) {
|
||||
if (!is_numeric($seconds) || $seconds < 0)
|
||||
throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.');
|
||||
|
||||
$this->curl_timeout = $seconds;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the HTTP timeout value
|
||||
*
|
||||
* @return string HTTP timeout value
|
||||
*/
|
||||
public function getTimeout() {
|
||||
return $this->curl_timeout;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get API key (with prefix if set)
|
||||
* @param string key name
|
||||
* @param string $apiKey name of apikey
|
||||
* @return string API key with the prefix
|
||||
*/
|
||||
public function getApiKeyWithPrefix($apiKey) {
|
||||
if (isset(Configuration::$apiKeyPrefix[$apiKey])) {
|
||||
return Configuration::$apiKeyPrefix[$apiKey]." ".Configuration::$apiKey[$apiKey];
|
||||
} else if (isset(Configuration::$apiKey[$apiKey])) {
|
||||
return Configuration::$apiKey[$apiKey];
|
||||
$prefix = $this->config->getApiKeyPrefix($apiKey);
|
||||
$apiKey = $this->config->getApiKey($apiKey);
|
||||
|
||||
if (!isset($apiKey)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isset($prefix)) {
|
||||
$keyWithPrefix = $prefix." ".$apiKey;
|
||||
} else {
|
||||
return;
|
||||
$keyWithPrefix = $apiKey;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* update hearder and query param based on authentication setting
|
||||
*
|
||||
* @param array $headerParams header parameters (by ref)
|
||||
* @param array $queryParams query parameters (by ref)
|
||||
* @param array $authSettings array of authentication scheme (e.g ['api_key'])
|
||||
*/
|
||||
public function updateParamsForAuth(&$headerParams, &$queryParams, $authSettings)
|
||||
{
|
||||
if (count($authSettings) == 0)
|
||||
return;
|
||||
|
||||
// one endpoint can have more than 1 auth settings
|
||||
foreach($authSettings as $auth) {
|
||||
// determine which one to use
|
||||
switch($auth) {
|
||||
|
||||
case 'api_key':
|
||||
$headerParams['api_key'] = $this->getApiKeyWithPrefix('api_key');
|
||||
|
||||
break;
|
||||
|
||||
case 'petstore_auth':
|
||||
|
||||
//TODO support oauth
|
||||
break;
|
||||
|
||||
default:
|
||||
//TODO show warning about security definition not found
|
||||
}
|
||||
}
|
||||
return $keyWithPrefix;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,18 +87,15 @@ class ApiClient {
|
||||
* @param array $queryParams parameters to be place in query URL
|
||||
* @param array $postData parameters to be placed in POST body
|
||||
* @param array $headerParams parameters to be place in request header
|
||||
* @throws \Swagger\Client\ApiException on a non 2xx response
|
||||
* @return mixed
|
||||
*/
|
||||
public function callApi($resourcePath, $method, $queryParams, $postData,
|
||||
$headerParams, $authSettings) {
|
||||
public function callApi($resourcePath, $method, $queryParams, $postData, $headerParams) {
|
||||
|
||||
$headers = array();
|
||||
|
||||
# determine authentication setting
|
||||
$this->updateParamsForAuth($headerParams, $queryParams, $authSettings);
|
||||
|
||||
# construct the http header
|
||||
$headerParams = array_merge((array)$this->default_header, (array)$headerParams);
|
||||
$headerParams = array_merge((array)$this->config->getDefaultHeaders(), (array)$headerParams);
|
||||
|
||||
foreach ($headerParams as $key => $val) {
|
||||
$headers[] = "$key: $val";
|
||||
@@ -195,15 +106,15 @@ class ApiClient {
|
||||
$postData = http_build_query($postData);
|
||||
}
|
||||
else if ((is_object($postData) or is_array($postData)) and !in_array('Content-Type: multipart/form-data', $headers)) { // json model
|
||||
$postData = json_encode($this->sanitizeForSerialization($postData));
|
||||
$postData = json_encode($this->serializer->sanitizeForSerialization($postData));
|
||||
}
|
||||
|
||||
$url = $this->host . $resourcePath;
|
||||
$url = $this->config->getHost() . $resourcePath;
|
||||
|
||||
$curl = curl_init();
|
||||
// set timeout, if needed
|
||||
if ($this->curl_timeout != 0) {
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, $this->curl_timeout);
|
||||
if ($this->config->getCurlTimeout() != 0) {
|
||||
curl_setopt($curl, CURLOPT_TIMEOUT, $this->config->getCurlTimeout());
|
||||
}
|
||||
// return the result on success, rather than just TRUE
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
|
||||
@@ -232,14 +143,14 @@ class ApiClient {
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
|
||||
// Set user agent
|
||||
curl_setopt($curl, CURLOPT_USERAGENT, $this->user_agent);
|
||||
curl_setopt($curl, CURLOPT_USERAGENT, $this->config->getUserAgent());
|
||||
|
||||
// debugging for curl
|
||||
if (Configuration::$debug) {
|
||||
error_log("[DEBUG] HTTP Request body ~BEGIN~\n".print_r($postData, true)."\n~END~\n", 3, Configuration::$debug_file);
|
||||
if ($this->config->getDebug()) {
|
||||
error_log("[DEBUG] HTTP Request body ~BEGIN~\n".print_r($postData, true)."\n~END~\n", 3, $this->config->getDebugFile());
|
||||
|
||||
curl_setopt($curl, CURLOPT_VERBOSE, 1);
|
||||
curl_setopt($curl, CURLOPT_STDERR, fopen(Configuration::$debug_file, 'a'));
|
||||
curl_setopt($curl, CURLOPT_STDERR, fopen($this->config->getDebugFile(), 'a'));
|
||||
} else {
|
||||
curl_setopt($curl, CURLOPT_VERBOSE, 0);
|
||||
}
|
||||
@@ -255,8 +166,8 @@ class ApiClient {
|
||||
$response_info = curl_getinfo($curl);
|
||||
|
||||
// debug HTTP response body
|
||||
if (Configuration::$debug) {
|
||||
error_log("[DEBUG] HTTP Response body ~BEGIN~\n".print_r($http_body, true)."\n~END~\n", 3, Configuration::$debug_file);
|
||||
if ($this->config->getDebug()) {
|
||||
error_log("[DEBUG] HTTP Response body ~BEGIN~\n".print_r($http_body, true)."\n~END~\n", 3, $this->config->getDebugFile());
|
||||
}
|
||||
|
||||
// Handle the response
|
||||
@@ -274,153 +185,13 @@ class ApiClient {
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a JSON POST object
|
||||
*/
|
||||
protected function sanitizeForSerialization($data)
|
||||
{
|
||||
if (is_scalar($data) || null === $data) {
|
||||
$sanitized = $data;
|
||||
} else if ($data instanceof \DateTime) {
|
||||
$sanitized = $data->format(\DateTime::ISO8601);
|
||||
} else if (is_array($data)) {
|
||||
foreach ($data as $property => $value) {
|
||||
$data[$property] = $this->sanitizeForSerialization($value);
|
||||
}
|
||||
$sanitized = $data;
|
||||
} else if (is_object($data)) {
|
||||
$values = array();
|
||||
foreach (array_keys($data::$swaggerTypes) as $property) {
|
||||
if ($data->$property !== null) {
|
||||
$values[$data::$attributeMap[$property]] = $this->sanitizeForSerialization($data->$property);
|
||||
}
|
||||
}
|
||||
$sanitized = $values;
|
||||
} else {
|
||||
$sanitized = (string)$data;
|
||||
}
|
||||
|
||||
return $sanitized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the path, by url-encoding.
|
||||
* @param string $value a string which will be part of the path
|
||||
* @return string the serialized object
|
||||
*/
|
||||
public function toPathValue($value) {
|
||||
return rawurlencode($this->toString($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the query, by imploding comma-separated if it's an object.
|
||||
* If it's a string, pass through unchanged. It will be url-encoded
|
||||
* later.
|
||||
* @param object $object an object to be serialized to a string
|
||||
* @return string the serialized object
|
||||
*/
|
||||
public function toQueryValue($object) {
|
||||
if (is_array($object)) {
|
||||
return implode(',', $object);
|
||||
} else {
|
||||
return $this->toString($object);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the header. If it's a string, pass through unchanged
|
||||
* If it's a datetime object, format it in ISO8601
|
||||
* @param string $value a string which will be part of the header
|
||||
* @return string the header string
|
||||
*/
|
||||
public function toHeaderValue($value) {
|
||||
return $this->toString($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the http body (form parameter). If it's a string, pass through unchanged
|
||||
* If it's a datetime object, format it in ISO8601
|
||||
* @param string $value the value of the form parameter
|
||||
* @return string the form string
|
||||
*/
|
||||
public function toFormValue($value) {
|
||||
return $this->toString($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the parameter. If it's a string, pass through unchanged
|
||||
* If it's a datetime object, format it in ISO8601
|
||||
* @param string $value the value of the parameter
|
||||
* @return string the header string
|
||||
*/
|
||||
public function toString($value) {
|
||||
if ($value instanceof \DateTime) { // datetime in ISO8601 format
|
||||
return $value->format(\DateTime::ISO8601);
|
||||
}
|
||||
else {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize a JSON string into an object
|
||||
*
|
||||
* @param object $object object or primitive to be deserialized
|
||||
* @param string $class class name is passed as a string
|
||||
* @return object an instance of $class
|
||||
*/
|
||||
public function deserialize($data, $class)
|
||||
{
|
||||
if (null === $data) {
|
||||
$deserialized = null;
|
||||
} elseif (substr($class, 0, 4) == 'map[') { # for associative array e.g. map[string,int]
|
||||
$inner = substr($class, 4, -1);
|
||||
$deserialized = array();
|
||||
if(strrpos($inner, ",") !== false) {
|
||||
$subClass_array = explode(',', $inner, 2);
|
||||
$subClass = $subClass_array[1];
|
||||
foreach ($data as $key => $value) {
|
||||
$deserialized[$key] = $this->deserialize($value, $subClass);
|
||||
}
|
||||
}
|
||||
} elseif (strcasecmp(substr($class, -2),'[]') == 0) {
|
||||
$subClass = substr($class, 0, -2);
|
||||
$values = array();
|
||||
foreach ($data as $key => $value) {
|
||||
$values[] = $this->deserialize($value, $subClass);
|
||||
}
|
||||
$deserialized = $values;
|
||||
} elseif ($class == 'DateTime') {
|
||||
$deserialized = new \DateTime($data);
|
||||
} elseif (in_array($class, array('string', 'int', 'float', 'double', 'bool', 'object'))) {
|
||||
settype($data, $class);
|
||||
$deserialized = $data;
|
||||
} else {
|
||||
$instance = new $class();
|
||||
foreach ($instance::$swaggerTypes as $property => $type) {
|
||||
$original_property_name = $instance::$attributeMap[$property];
|
||||
if (isset($original_property_name) && isset($data->$original_property_name)) {
|
||||
$instance->$property = $this->deserialize($data->$original_property_name, $type);
|
||||
}
|
||||
}
|
||||
$deserialized = $instance;
|
||||
}
|
||||
|
||||
return $deserialized;
|
||||
}
|
||||
|
||||
/*
|
||||
* return the header 'Accept' based on an array of Accept provided
|
||||
*
|
||||
* @param array[string] $accept Array of header
|
||||
* @param string[] $accept Array of header
|
||||
* @return string Accept (e.g. application/json)
|
||||
*/
|
||||
public function selectHeaderAccept($accept) {
|
||||
public static function selectHeaderAccept($accept) {
|
||||
if (count($accept) === 0 or (count($accept) === 1 and $accept[0] === '')) {
|
||||
return NULL;
|
||||
} elseif (preg_grep("/application\/json/i", $accept)) {
|
||||
@@ -433,10 +204,10 @@ class ApiClient {
|
||||
/*
|
||||
* return the content type based on an array of content-type provided
|
||||
*
|
||||
* @param array[string] content_type_array Array fo content-type
|
||||
* @param string[] content_type_array Array fo content-type
|
||||
* @return string Content-Type (e.g. application/json)
|
||||
*/
|
||||
public function selectHeaderContentType($content_type) {
|
||||
public static function selectHeaderContentType($content_type) {
|
||||
if (count($content_type) === 0 or (count($content_type) === 1 and $content_type[0] === '')) {
|
||||
return 'application/json';
|
||||
} elseif (preg_grep("/application\/json/i", $content_type)) {
|
||||
@@ -445,6 +216,4 @@ class ApiClient {
|
||||
return implode(',', $content_type);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -22,15 +22,20 @@ use \Exception;
|
||||
class ApiException extends Exception {
|
||||
|
||||
/** @var string The HTTP body of the server response. */
|
||||
protected $response_body;
|
||||
protected $responseBody;
|
||||
|
||||
/** @var string[] The HTTP header of the server response. */
|
||||
protected $response_headers;
|
||||
protected $responseHeaders;
|
||||
|
||||
/**
|
||||
* The deserialized response object
|
||||
*/
|
||||
protected $responseObject;
|
||||
|
||||
public function __construct($message="", $code=0, $responseHeaders=null, $responseBody=null) {
|
||||
parent::__construct($message, $code);
|
||||
$this->response_headers = $responseHeaders;
|
||||
$this->response_body = $responseBody;
|
||||
$this->responseHeaders = $responseHeaders;
|
||||
$this->responseBody = $responseBody;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,7 +44,7 @@ class ApiException extends Exception {
|
||||
* @return string HTTP response header
|
||||
*/
|
||||
public function getResponseHeaders() {
|
||||
return $this->response_headers;
|
||||
return $this->responseHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,7 +53,18 @@ class ApiException extends Exception {
|
||||
* @return string HTTP response body
|
||||
*/
|
||||
public function getResponseBody() {
|
||||
return $this->response_body;
|
||||
return $this->responseBody;
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the deseralized response object (during deserialization)
|
||||
* @param mixed $obj
|
||||
*/
|
||||
public function setResponseObject($obj) {
|
||||
$this->responseObject = $obj;
|
||||
}
|
||||
|
||||
public function getResponseObject() {
|
||||
return $this->responseObject;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,37 +17,250 @@
|
||||
|
||||
namespace Swagger\Client;
|
||||
|
||||
use \Swagger\Client\ApiClient;
|
||||
|
||||
class Configuration {
|
||||
|
||||
private static $defaultConfiguration = null;
|
||||
|
||||
/** @var string[] Associate array to store API key(s) */
|
||||
public static $apiKey = array();
|
||||
protected $apiKeys = array();
|
||||
|
||||
/** string[] Associate array to store API prefix (e.g. Bearer) */
|
||||
public static $apiKeyPrefix = array();
|
||||
protected $apiKeyPrefixes = array();
|
||||
|
||||
/** @var string Username for HTTP basic authentication */
|
||||
public static $username = '';
|
||||
protected $username = '';
|
||||
|
||||
/** @var string Password for HTTP basic authentication */
|
||||
public static $password = '';
|
||||
protected $password = '';
|
||||
|
||||
/** @var \Swagger\Client\ApiClient The default instance of ApiClient */
|
||||
public static $apiClient;
|
||||
protected $defaultHeaders = array();
|
||||
|
||||
/** @var string The host */
|
||||
protected $host = 'http://localhost';
|
||||
|
||||
/** @var string timeout (second) of the HTTP request, by default set to 0, no timeout */
|
||||
protected $curlTimeout = 0;
|
||||
|
||||
/** @var string user agent of the HTTP request, set to "PHP-Swagger" by default */
|
||||
protected $userAgent = "PHP-Swagger";
|
||||
|
||||
/** @var bool Debug switch (default set to false) */
|
||||
public static $debug = false;
|
||||
protected $debug = false;
|
||||
|
||||
/** @var string Debug file location (log to STDOUT by default) */
|
||||
public static $debug_file = 'php://output';
|
||||
protected $debugFile = 'php://output';
|
||||
|
||||
/*
|
||||
* manually initalize ApiClient
|
||||
/**
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @return Configuration
|
||||
*/
|
||||
public static function init() {
|
||||
if (self::$apiClient === null)
|
||||
self::$apiClient = new ApiClient();
|
||||
public function setApiKey($key, $value) {
|
||||
$this->apiKeys[$key] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @return string
|
||||
*/
|
||||
public function getApiKey($key) {
|
||||
return isset($this->apiKeys[$key]) ? $this->apiKeys[$key] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $key
|
||||
* @param string $value
|
||||
* @return Configuration
|
||||
*/
|
||||
public function setApiKeyPrefix($key, $value) {
|
||||
$this->apiKeyPrefixes[$key] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $key
|
||||
* @return string
|
||||
*/
|
||||
public function getApiKeyPrefix($key) {
|
||||
return isset($this->apiKeyPrefixes[$key]) ? $this->apiKeyPrefixes[$key] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $username
|
||||
* @return Configuration
|
||||
*/
|
||||
public function setUsername($username) {
|
||||
$this->username = $username;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getUsername() {
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $password
|
||||
* @return Configuration
|
||||
*/
|
||||
public function setPassword($password) {
|
||||
$this->password = $password;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword() {
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* add default header
|
||||
*
|
||||
* @param string $headerName header name (e.g. Token)
|
||||
* @param string $headerValue header value (e.g. 1z8wp3)
|
||||
* @return ApiClient
|
||||
*/
|
||||
public function addDefaultHeader($headerName, $headerValue) {
|
||||
if (!is_string($headerName)) {
|
||||
throw new \InvalidArgumentException('Header name must be a string.');
|
||||
}
|
||||
|
||||
$this->defaultHeaders[$headerName] = $headerValue;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the default header
|
||||
*
|
||||
* @return array default header
|
||||
*/
|
||||
public function getDefaultHeaders() {
|
||||
return $this->defaultHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* delete a default header
|
||||
* @param string $headerName the header to delete
|
||||
* @return Configuration
|
||||
*/
|
||||
public function deleteDefaultHeader($headerName) {
|
||||
unset($this->defaultHeaders[$headerName]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $host
|
||||
* @return Configuration
|
||||
*/
|
||||
public function setHost($host) {
|
||||
$this->host = $host;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getHost() {
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the user agent of the api client
|
||||
*
|
||||
* @param string $userAgent the user agent of the api client
|
||||
* @return ApiClient
|
||||
*/
|
||||
public function setUserAgent($userAgent) {
|
||||
if (!is_string($userAgent)) {
|
||||
throw new \InvalidArgumentException('User-agent must be a string.');
|
||||
}
|
||||
|
||||
$this->userAgent = $userAgent;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the user agent of the api client
|
||||
*
|
||||
* @return string user agent
|
||||
*/
|
||||
public function getUserAgent() {
|
||||
return $this->userAgent;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the HTTP timeout value
|
||||
*
|
||||
* @param integer $seconds Number of seconds before timing out [set to 0 for no timeout]
|
||||
* @return ApiClient
|
||||
*/
|
||||
public function setCurlTimeout($seconds) {
|
||||
if (!is_numeric($seconds) || $seconds < 0) {
|
||||
throw new \InvalidArgumentException('Timeout value must be numeric and a non-negative number.');
|
||||
}
|
||||
|
||||
$this->curlTimeout = $seconds;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the HTTP timeout value
|
||||
*
|
||||
* @return string HTTP timeout value
|
||||
*/
|
||||
public function getCurlTimeout() {
|
||||
return $this->curlTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bool $debug
|
||||
* @return Configuration
|
||||
*/
|
||||
public function setDebug($debug) {
|
||||
$this->debug = $debug;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function getDebug() {
|
||||
return $this->debug;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $debugFile
|
||||
* @return Configuration
|
||||
*/
|
||||
public function setDebugFile($debugFile) {
|
||||
$this->debugFile = $debugFile;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDebugFile() {
|
||||
return $this->debugFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Configuration
|
||||
*/
|
||||
public static function getDefaultConfiguration() {
|
||||
if (self::$defaultConfiguration == null) {
|
||||
return new Configuration();
|
||||
}
|
||||
|
||||
return self::$defaultConfiguration;
|
||||
}
|
||||
|
||||
public static function setDefaultConfiguration(Configuration $config) {
|
||||
self::$defaultConfiguration = $config;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,21 +38,69 @@ class Category implements ArrayAccess {
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
);
|
||||
|
||||
/** @var string[] Array of attributes to setter functions (for deserialization of responses) */
|
||||
static $setters = array(
|
||||
'id' => 'setId',
|
||||
'name' => 'setName'
|
||||
);
|
||||
|
||||
/** @var string[] Array of attributes to getter functions (for serialization of requests) */
|
||||
static $getters = array(
|
||||
'id' => 'getId',
|
||||
'name' => 'getName'
|
||||
);
|
||||
|
||||
|
||||
/** @var int $id */
|
||||
public $id;
|
||||
protected $id;
|
||||
|
||||
/** @var string $name */
|
||||
public $name;
|
||||
protected $name;
|
||||
|
||||
public function __construct(array $data = null) {
|
||||
if ($data != null) {
|
||||
$this->id = $data["id"];
|
||||
$this->name = $data["name"];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] Array of parameters to initialize the object with
|
||||
* get id
|
||||
* @return int
|
||||
*/
|
||||
public function __construct(array $data = null) {
|
||||
$this->id = @$data["id"];
|
||||
$this->name = @$data["name"];
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* set id
|
||||
* @param int $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id) {
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get name
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* set name
|
||||
* @param string $name
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name) {
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
@@ -46,37 +46,165 @@ class Order implements ArrayAccess {
|
||||
'status' => 'status',
|
||||
'complete' => 'complete'
|
||||
);
|
||||
|
||||
/** @var string[] Array of attributes to setter functions (for deserialization of responses) */
|
||||
static $setters = array(
|
||||
'id' => 'setId',
|
||||
'pet_id' => 'setPetId',
|
||||
'quantity' => 'setQuantity',
|
||||
'ship_date' => 'setShipDate',
|
||||
'status' => 'setStatus',
|
||||
'complete' => 'setComplete'
|
||||
);
|
||||
|
||||
/** @var string[] Array of attributes to getter functions (for serialization of requests) */
|
||||
static $getters = array(
|
||||
'id' => 'getId',
|
||||
'pet_id' => 'getPetId',
|
||||
'quantity' => 'getQuantity',
|
||||
'ship_date' => 'getShipDate',
|
||||
'status' => 'getStatus',
|
||||
'complete' => 'getComplete'
|
||||
);
|
||||
|
||||
|
||||
/** @var int $id */
|
||||
public $id;
|
||||
protected $id;
|
||||
|
||||
/** @var int $pet_id */
|
||||
public $pet_id;
|
||||
protected $pet_id;
|
||||
|
||||
/** @var int $quantity */
|
||||
public $quantity;
|
||||
protected $quantity;
|
||||
|
||||
/** @var \DateTime $ship_date */
|
||||
public $ship_date;
|
||||
protected $ship_date;
|
||||
|
||||
/** @var string $status Order Status */
|
||||
public $status;
|
||||
protected $status;
|
||||
|
||||
/** @var bool $complete */
|
||||
public $complete;
|
||||
protected $complete;
|
||||
|
||||
public function __construct(array $data = null) {
|
||||
if ($data != null) {
|
||||
$this->id = $data["id"];
|
||||
$this->pet_id = $data["pet_id"];
|
||||
$this->quantity = $data["quantity"];
|
||||
$this->ship_date = $data["ship_date"];
|
||||
$this->status = $data["status"];
|
||||
$this->complete = $data["complete"];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] Array of parameters to initialize the object with
|
||||
* get id
|
||||
* @return int
|
||||
*/
|
||||
public function __construct(array $data = null) {
|
||||
$this->id = @$data["id"];
|
||||
$this->pet_id = @$data["pet_id"];
|
||||
$this->quantity = @$data["quantity"];
|
||||
$this->ship_date = @$data["ship_date"];
|
||||
$this->status = @$data["status"];
|
||||
$this->complete = @$data["complete"];
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* set id
|
||||
* @param int $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id) {
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get pet_id
|
||||
* @return int
|
||||
*/
|
||||
public function getPetId() {
|
||||
return $this->pet_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* set pet_id
|
||||
* @param int $pet_id
|
||||
* @return $this
|
||||
*/
|
||||
public function setPetId($pet_id) {
|
||||
$this->pet_id = $pet_id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get quantity
|
||||
* @return int
|
||||
*/
|
||||
public function getQuantity() {
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
/**
|
||||
* set quantity
|
||||
* @param int $quantity
|
||||
* @return $this
|
||||
*/
|
||||
public function setQuantity($quantity) {
|
||||
$this->quantity = $quantity;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get ship_date
|
||||
* @return \DateTime
|
||||
*/
|
||||
public function getShipDate() {
|
||||
return $this->ship_date;
|
||||
}
|
||||
|
||||
/**
|
||||
* set ship_date
|
||||
* @param \DateTime $ship_date
|
||||
* @return $this
|
||||
*/
|
||||
public function setShipDate($ship_date) {
|
||||
$this->ship_date = $ship_date;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get status
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus() {
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* set status
|
||||
* @param string $status
|
||||
* @return $this
|
||||
*/
|
||||
public function setStatus($status) {
|
||||
$this->status = $status;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get complete
|
||||
* @return bool
|
||||
*/
|
||||
public function getComplete() {
|
||||
return $this->complete;
|
||||
}
|
||||
|
||||
/**
|
||||
* set complete
|
||||
* @param bool $complete
|
||||
* @return $this
|
||||
*/
|
||||
public function setComplete($complete) {
|
||||
$this->complete = $complete;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
@@ -46,37 +46,165 @@ class Pet implements ArrayAccess {
|
||||
'tags' => 'tags',
|
||||
'status' => 'status'
|
||||
);
|
||||
|
||||
/** @var string[] Array of attributes to setter functions (for deserialization of responses) */
|
||||
static $setters = array(
|
||||
'id' => 'setId',
|
||||
'category' => 'setCategory',
|
||||
'name' => 'setName',
|
||||
'photo_urls' => 'setPhotoUrls',
|
||||
'tags' => 'setTags',
|
||||
'status' => 'setStatus'
|
||||
);
|
||||
|
||||
/** @var string[] Array of attributes to getter functions (for serialization of requests) */
|
||||
static $getters = array(
|
||||
'id' => 'getId',
|
||||
'category' => 'getCategory',
|
||||
'name' => 'getName',
|
||||
'photo_urls' => 'getPhotoUrls',
|
||||
'tags' => 'getTags',
|
||||
'status' => 'getStatus'
|
||||
);
|
||||
|
||||
|
||||
/** @var int $id */
|
||||
public $id;
|
||||
protected $id;
|
||||
|
||||
/** @var \Swagger\Client\Model\Category $category */
|
||||
public $category;
|
||||
protected $category;
|
||||
|
||||
/** @var string $name */
|
||||
public $name;
|
||||
protected $name;
|
||||
|
||||
/** @var string[] $photo_urls */
|
||||
public $photo_urls;
|
||||
protected $photo_urls;
|
||||
|
||||
/** @var \Swagger\Client\Model\Tag[] $tags */
|
||||
public $tags;
|
||||
protected $tags;
|
||||
|
||||
/** @var string $status pet status in the store */
|
||||
public $status;
|
||||
protected $status;
|
||||
|
||||
public function __construct(array $data = null) {
|
||||
if ($data != null) {
|
||||
$this->id = $data["id"];
|
||||
$this->category = $data["category"];
|
||||
$this->name = $data["name"];
|
||||
$this->photo_urls = $data["photo_urls"];
|
||||
$this->tags = $data["tags"];
|
||||
$this->status = $data["status"];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] Array of parameters to initialize the object with
|
||||
* get id
|
||||
* @return int
|
||||
*/
|
||||
public function __construct(array $data = null) {
|
||||
$this->id = @$data["id"];
|
||||
$this->category = @$data["category"];
|
||||
$this->name = @$data["name"];
|
||||
$this->photo_urls = @$data["photo_urls"];
|
||||
$this->tags = @$data["tags"];
|
||||
$this->status = @$data["status"];
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* set id
|
||||
* @param int $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id) {
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get category
|
||||
* @return \Swagger\Client\Model\Category
|
||||
*/
|
||||
public function getCategory() {
|
||||
return $this->category;
|
||||
}
|
||||
|
||||
/**
|
||||
* set category
|
||||
* @param \Swagger\Client\Model\Category $category
|
||||
* @return $this
|
||||
*/
|
||||
public function setCategory($category) {
|
||||
$this->category = $category;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get name
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* set name
|
||||
* @param string $name
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name) {
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get photo_urls
|
||||
* @return string[]
|
||||
*/
|
||||
public function getPhotoUrls() {
|
||||
return $this->photo_urls;
|
||||
}
|
||||
|
||||
/**
|
||||
* set photo_urls
|
||||
* @param string[] $photo_urls
|
||||
* @return $this
|
||||
*/
|
||||
public function setPhotoUrls($photo_urls) {
|
||||
$this->photo_urls = $photo_urls;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get tags
|
||||
* @return \Swagger\Client\Model\Tag[]
|
||||
*/
|
||||
public function getTags() {
|
||||
return $this->tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* set tags
|
||||
* @param \Swagger\Client\Model\Tag[] $tags
|
||||
* @return $this
|
||||
*/
|
||||
public function setTags($tags) {
|
||||
$this->tags = $tags;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get status
|
||||
* @return string
|
||||
*/
|
||||
public function getStatus() {
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
/**
|
||||
* set status
|
||||
* @param string $status
|
||||
* @return $this
|
||||
*/
|
||||
public function setStatus($status) {
|
||||
$this->status = $status;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
@@ -38,21 +38,69 @@ class Tag implements ArrayAccess {
|
||||
'id' => 'id',
|
||||
'name' => 'name'
|
||||
);
|
||||
|
||||
/** @var string[] Array of attributes to setter functions (for deserialization of responses) */
|
||||
static $setters = array(
|
||||
'id' => 'setId',
|
||||
'name' => 'setName'
|
||||
);
|
||||
|
||||
/** @var string[] Array of attributes to getter functions (for serialization of requests) */
|
||||
static $getters = array(
|
||||
'id' => 'getId',
|
||||
'name' => 'getName'
|
||||
);
|
||||
|
||||
|
||||
/** @var int $id */
|
||||
public $id;
|
||||
protected $id;
|
||||
|
||||
/** @var string $name */
|
||||
public $name;
|
||||
protected $name;
|
||||
|
||||
public function __construct(array $data = null) {
|
||||
if ($data != null) {
|
||||
$this->id = $data["id"];
|
||||
$this->name = $data["name"];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] Array of parameters to initialize the object with
|
||||
* get id
|
||||
* @return int
|
||||
*/
|
||||
public function __construct(array $data = null) {
|
||||
$this->id = @$data["id"];
|
||||
$this->name = @$data["name"];
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* set id
|
||||
* @param int $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id) {
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get name
|
||||
* @return string
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* set name
|
||||
* @param string $name
|
||||
* @return $this
|
||||
*/
|
||||
public function setName($name) {
|
||||
$this->name = $name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
@@ -50,45 +50,213 @@ class User implements ArrayAccess {
|
||||
'phone' => 'phone',
|
||||
'user_status' => 'userStatus'
|
||||
);
|
||||
|
||||
/** @var string[] Array of attributes to setter functions (for deserialization of responses) */
|
||||
static $setters = array(
|
||||
'id' => 'setId',
|
||||
'username' => 'setUsername',
|
||||
'first_name' => 'setFirstName',
|
||||
'last_name' => 'setLastName',
|
||||
'email' => 'setEmail',
|
||||
'password' => 'setPassword',
|
||||
'phone' => 'setPhone',
|
||||
'user_status' => 'setUserStatus'
|
||||
);
|
||||
|
||||
/** @var string[] Array of attributes to getter functions (for serialization of requests) */
|
||||
static $getters = array(
|
||||
'id' => 'getId',
|
||||
'username' => 'getUsername',
|
||||
'first_name' => 'getFirstName',
|
||||
'last_name' => 'getLastName',
|
||||
'email' => 'getEmail',
|
||||
'password' => 'getPassword',
|
||||
'phone' => 'getPhone',
|
||||
'user_status' => 'getUserStatus'
|
||||
);
|
||||
|
||||
|
||||
/** @var int $id */
|
||||
public $id;
|
||||
protected $id;
|
||||
|
||||
/** @var string $username */
|
||||
public $username;
|
||||
protected $username;
|
||||
|
||||
/** @var string $first_name */
|
||||
public $first_name;
|
||||
protected $first_name;
|
||||
|
||||
/** @var string $last_name */
|
||||
public $last_name;
|
||||
protected $last_name;
|
||||
|
||||
/** @var string $email */
|
||||
public $email;
|
||||
protected $email;
|
||||
|
||||
/** @var string $password */
|
||||
public $password;
|
||||
protected $password;
|
||||
|
||||
/** @var string $phone */
|
||||
public $phone;
|
||||
protected $phone;
|
||||
|
||||
/** @var int $user_status User Status */
|
||||
public $user_status;
|
||||
protected $user_status;
|
||||
|
||||
public function __construct(array $data = null) {
|
||||
if ($data != null) {
|
||||
$this->id = $data["id"];
|
||||
$this->username = $data["username"];
|
||||
$this->first_name = $data["first_name"];
|
||||
$this->last_name = $data["last_name"];
|
||||
$this->email = $data["email"];
|
||||
$this->password = $data["password"];
|
||||
$this->phone = $data["phone"];
|
||||
$this->user_status = $data["user_status"];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed[] Array of parameters to initialize the object with
|
||||
* get id
|
||||
* @return int
|
||||
*/
|
||||
public function __construct(array $data = null) {
|
||||
$this->id = @$data["id"];
|
||||
$this->username = @$data["username"];
|
||||
$this->first_name = @$data["first_name"];
|
||||
$this->last_name = @$data["last_name"];
|
||||
$this->email = @$data["email"];
|
||||
$this->password = @$data["password"];
|
||||
$this->phone = @$data["phone"];
|
||||
$this->user_status = @$data["user_status"];
|
||||
public function getId() {
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* set id
|
||||
* @param int $id
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id) {
|
||||
$this->id = $id;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get username
|
||||
* @return string
|
||||
*/
|
||||
public function getUsername() {
|
||||
return $this->username;
|
||||
}
|
||||
|
||||
/**
|
||||
* set username
|
||||
* @param string $username
|
||||
* @return $this
|
||||
*/
|
||||
public function setUsername($username) {
|
||||
$this->username = $username;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get first_name
|
||||
* @return string
|
||||
*/
|
||||
public function getFirstName() {
|
||||
return $this->first_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* set first_name
|
||||
* @param string $first_name
|
||||
* @return $this
|
||||
*/
|
||||
public function setFirstName($first_name) {
|
||||
$this->first_name = $first_name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get last_name
|
||||
* @return string
|
||||
*/
|
||||
public function getLastName() {
|
||||
return $this->last_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* set last_name
|
||||
* @param string $last_name
|
||||
* @return $this
|
||||
*/
|
||||
public function setLastName($last_name) {
|
||||
$this->last_name = $last_name;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get email
|
||||
* @return string
|
||||
*/
|
||||
public function getEmail() {
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
/**
|
||||
* set email
|
||||
* @param string $email
|
||||
* @return $this
|
||||
*/
|
||||
public function setEmail($email) {
|
||||
$this->email = $email;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get password
|
||||
* @return string
|
||||
*/
|
||||
public function getPassword() {
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
/**
|
||||
* set password
|
||||
* @param string $password
|
||||
* @return $this
|
||||
*/
|
||||
public function setPassword($password) {
|
||||
$this->password = $password;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get phone
|
||||
* @return string
|
||||
*/
|
||||
public function getPhone() {
|
||||
return $this->phone;
|
||||
}
|
||||
|
||||
/**
|
||||
* set phone
|
||||
* @param string $phone
|
||||
* @return $this
|
||||
*/
|
||||
public function setPhone($phone) {
|
||||
$this->phone = $phone;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* get user_status
|
||||
* @return int
|
||||
*/
|
||||
public function getUserStatus() {
|
||||
return $this->user_status;
|
||||
}
|
||||
|
||||
/**
|
||||
* set user_status
|
||||
* @param int $user_status
|
||||
* @return $this
|
||||
*/
|
||||
public function setUserStatus($user_status) {
|
||||
$this->user_status = $user_status;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function offsetExists($offset) {
|
||||
return isset($this->$offset);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
namespace Swagger\Client;
|
||||
|
||||
class ObjectSerializer {
|
||||
|
||||
/**
|
||||
* Build a JSON POST object
|
||||
* @param mixed $data the data to serialize
|
||||
* @return string serialized form of $data
|
||||
*/
|
||||
public function sanitizeForSerialization($data) {
|
||||
if (is_scalar($data) || null === $data) {
|
||||
$sanitized = $data;
|
||||
} else if ($data instanceof \DateTime) {
|
||||
$sanitized = $data->format(\DateTime::ISO8601);
|
||||
} else if (is_array($data)) {
|
||||
foreach ($data as $property => $value) {
|
||||
$data[$property] = $this->sanitizeForSerialization($value);
|
||||
}
|
||||
$sanitized = $data;
|
||||
} else if (is_object($data)) {
|
||||
$values = array();
|
||||
foreach (array_keys($data::$swaggerTypes) as $property) {
|
||||
$getter = $data::$getters[$property];
|
||||
if ($data->$getter() !== null) {
|
||||
$values[$data::$attributeMap[$property]] = $this->sanitizeForSerialization($data->$getter());
|
||||
}
|
||||
}
|
||||
$sanitized = $values;
|
||||
} else {
|
||||
$sanitized = (string)$data;
|
||||
}
|
||||
|
||||
return $sanitized;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the path, by url-encoding.
|
||||
* @param string $value a string which will be part of the path
|
||||
* @return string the serialized object
|
||||
*/
|
||||
public function toPathValue($value) {
|
||||
return rawurlencode($this->toString($value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the query, by imploding comma-separated if it's an object.
|
||||
* If it's a string, pass through unchanged. It will be url-encoded
|
||||
* later.
|
||||
* @param object $object an object to be serialized to a string
|
||||
* @return string the serialized object
|
||||
*/
|
||||
public function toQueryValue($object) {
|
||||
if (is_array($object)) {
|
||||
return implode(',', $object);
|
||||
} else {
|
||||
return $this->toString($object);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the header. If it's a string, pass through unchanged
|
||||
* If it's a datetime object, format it in ISO8601
|
||||
* @param string $value a string which will be part of the header
|
||||
* @return string the header string
|
||||
*/
|
||||
public function toHeaderValue($value) {
|
||||
return $this->toString($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the http body (form parameter). If it's a string, pass through unchanged
|
||||
* If it's a datetime object, format it in ISO8601
|
||||
* @param string $value the value of the form parameter
|
||||
* @return string the form string
|
||||
*/
|
||||
public function toFormValue($value) {
|
||||
return $this->toString($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Take value and turn it into a string suitable for inclusion in
|
||||
* the parameter. If it's a string, pass through unchanged
|
||||
* If it's a datetime object, format it in ISO8601
|
||||
* @param string $value the value of the parameter
|
||||
* @return string the header string
|
||||
*/
|
||||
public function toString($value) {
|
||||
if ($value instanceof \DateTime) { // datetime in ISO8601 format
|
||||
return $value->format(\DateTime::ISO8601);
|
||||
} else {
|
||||
return $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize a JSON string into an object
|
||||
*
|
||||
* @param mixed $data object or primitive to be deserialized
|
||||
* @param string $class class name is passed as a string
|
||||
* @return object an instance of $class
|
||||
*/
|
||||
public function deserialize($data, $class) {
|
||||
if (null === $data) {
|
||||
$deserialized = null;
|
||||
} elseif (substr($class, 0, 4) == 'map[') { # for associative array e.g. map[string,int]
|
||||
$inner = substr($class, 4, -1);
|
||||
$deserialized = array();
|
||||
if(strrpos($inner, ",") !== false) {
|
||||
$subClass_array = explode(',', $inner, 2);
|
||||
$subClass = $subClass_array[1];
|
||||
foreach ($data as $key => $value) {
|
||||
$deserialized[$key] = $this->deserialize($value, $subClass);
|
||||
}
|
||||
}
|
||||
} elseif (strcasecmp(substr($class, -2),'[]') == 0) {
|
||||
$subClass = substr($class, 0, -2);
|
||||
$values = array();
|
||||
foreach ($data as $key => $value) {
|
||||
$values[] = $this->deserialize($value, $subClass);
|
||||
}
|
||||
$deserialized = $values;
|
||||
} elseif ($class == 'DateTime') {
|
||||
$deserialized = new \DateTime($data);
|
||||
} elseif (in_array($class, array('string', 'int', 'float', 'double', 'bool', 'object'))) {
|
||||
settype($data, $class);
|
||||
$deserialized = $data;
|
||||
} else {
|
||||
$instance = new $class();
|
||||
foreach ($instance::$swaggerTypes as $property => $type) {
|
||||
$propertySetter = $instance::$setters[$property];
|
||||
|
||||
if (!isset($propertySetter) || !isset($data->{$instance::$attributeMap[$property]})) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$propertyValue = $data->{$instance::$attributeMap[$property]};
|
||||
if (isset($propertyValue)) {
|
||||
$instance->$propertySetter($this->deserialize($propertyValue, $type));
|
||||
}
|
||||
}
|
||||
$deserialized = $instance;
|
||||
}
|
||||
|
||||
return $deserialized;
|
||||
}
|
||||
}
|
||||
@@ -22,19 +22,19 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
||||
// new pet
|
||||
$new_pet_id = 10005;
|
||||
$new_pet = new Swagger\Client\Model\Pet;
|
||||
$new_pet->id = $new_pet_id;
|
||||
$new_pet->name = "PHP Unit Test";
|
||||
$new_pet->setId($new_pet_id);
|
||||
$new_pet->setName("PHP Unit Test");
|
||||
// new tag
|
||||
$tag= new Swagger\Client\Model\Tag;
|
||||
$tag->id = $new_pet_id; // use the same id as pet
|
||||
$tag->name = "test php tag";
|
||||
$tag->setId($new_pet_id); // use the same id as pet
|
||||
$tag->setName("test php tag");
|
||||
// new category
|
||||
$category = new Swagger\Client\Model\Category;
|
||||
$category->id = $new_pet_id; // use the same id as pet
|
||||
$category->name = "test php category";
|
||||
$category->setId($new_pet_id); // use the same id as pet
|
||||
$category->setName("test php category");
|
||||
|
||||
$new_pet->tags = array($tag);
|
||||
$new_pet->category = $category;
|
||||
$new_pet->setTags(array($tag));
|
||||
$new_pet->setCategory($category);
|
||||
|
||||
$pet_api = new Swagger\Client\Api\PetAPI();
|
||||
// add a new pet (model)
|
||||
@@ -56,65 +56,53 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame('application/yaml,application/xml', $api_client->selectHeaderContentType(array('application/yaml','application/xml')));
|
||||
|
||||
// test addDefaultHeader and getDefaultHeader
|
||||
$api_client->addDefaultHeader('test1', 'value1');
|
||||
$api_client->addDefaultHeader('test2', 200);
|
||||
$defaultHeader = $api_client->getDefaultHeader();
|
||||
$api_client->getConfig()->addDefaultHeader('test1', 'value1');
|
||||
$api_client->getConfig()->addDefaultHeader('test2', 200);
|
||||
$defaultHeader = $api_client->getConfig()->getDefaultHeaders();
|
||||
$this->assertSame('value1', $defaultHeader['test1']);
|
||||
$this->assertSame(200, $defaultHeader['test2']);
|
||||
|
||||
// test deleteDefaultHeader
|
||||
$api_client->deleteDefaultHeader('test2');
|
||||
$defaultHeader = $api_client->getDefaultHeader();
|
||||
$api_client->getConfig()->deleteDefaultHeader('test2');
|
||||
$defaultHeader = $api_client->getConfig()->getDefaultHeaders();
|
||||
$this->assertFalse(isset($defaultHeader['test2']));
|
||||
|
||||
$pet_api = new Swagger\Client\Api\PetAPI();
|
||||
$pet_api2 = new Swagger\Client\Api\PetAPI();
|
||||
$apiClient3 = new Swagger\Client\ApiClient();
|
||||
$apiClient3->setUserAgent = 'api client 3';
|
||||
$apiClient3->getConfig()->setUserAgent('api client 3');
|
||||
$apiClient4 = new Swagger\Client\ApiClient();
|
||||
$apiClient4->setUserAgent = 'api client 4';
|
||||
$apiClient4->getConfig()->setUserAgent('api client 4');
|
||||
$pet_api3 = new Swagger\Client\Api\PetAPI($apiClient3);
|
||||
|
||||
// same default api client
|
||||
$this->assertSame($pet_api->getApiClient(), $pet_api2->getApiClient());
|
||||
// confirm using the default api client in the Configuration
|
||||
$this->assertSame($pet_api->getApiClient(), Swagger\Client\Configuration::$apiClient);
|
||||
// 2 different api clients are not the same
|
||||
$this->assertNotEquals($apiClient3, $apiClient4);
|
||||
// customized pet api not using the default (configuration) api client
|
||||
$this->assertNotEquals($pet_api3->getApiClient(), Swagger\Client\Configuration::$apiClient);
|
||||
// customied pet api not using the old pet api's api client
|
||||
$this->assertNotEquals($pet_api2->getApiClient(), $pet_api3->getApiClient());
|
||||
|
||||
// both pet api and pet api2 share the same api client and confirm using timeout value
|
||||
$pet_api->getApiClient()->setTimeout(999);
|
||||
$this->assertSame(999, $pet_api2->getApiClient()->getTimeout());
|
||||
|
||||
}
|
||||
|
||||
// test getPetById with a Pet object (id 10005)
|
||||
public function testGetPetById()
|
||||
{
|
||||
// initialize the API client without host
|
||||
$api_client = new Swagger\Client\ApiClient();
|
||||
Swagger\Client\Configuration::$apiKey['api_key'] = '111222333444555';
|
||||
$pet_id = 10005; // ID of pet that needs to be fetched
|
||||
$pet_api = new Swagger\Client\Api\PetAPI($api_client);
|
||||
$pet_api = new Swagger\Client\Api\PetAPI();
|
||||
$pet_api->getApiClient()->getConfig()->setApiKey('api_key', '111222333444555');
|
||||
// return Pet (model)
|
||||
$response = $pet_api->getPetById($pet_id);
|
||||
$this->assertSame($response->id, $pet_id);
|
||||
$this->assertSame($response->name, 'PHP Unit Test');
|
||||
$this->assertSame($response->category->id, $pet_id);
|
||||
$this->assertSame($response->category->name, 'test php category');
|
||||
$this->assertSame($response->tags[0]->id, $pet_id);
|
||||
$this->assertSame($response->tags[0]->name, 'test php tag');
|
||||
$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');
|
||||
}
|
||||
|
||||
// test getPetByStatus and verify by the "id" of the response
|
||||
public function testFindPetByStatus()
|
||||
{
|
||||
// initialize the API client
|
||||
$api_client = new Swagger\Client\ApiClient('http://petstore.swagger.io/v2');
|
||||
$config = (new Swagger\Client\Configuration())->setHost('http://petstore.swagger.io/v2');
|
||||
$api_client = new Swagger\Client\ApiClient($config);
|
||||
$pet_api = new Swagger\Client\Api\PetAPI($api_client);
|
||||
// return Pet (model)
|
||||
$response = $pet_api->findPetsByStatus("available");
|
||||
@@ -133,30 +121,32 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
||||
public function testUpdatePet()
|
||||
{
|
||||
// initialize the API client
|
||||
$api_client = new Swagger\Client\ApiClient('http://petstore.swagger.io/v2');
|
||||
$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);
|
||||
// create updated pet object
|
||||
$updated_pet = new Swagger\Client\Model\Pet;
|
||||
$updated_pet->id = $pet_id;
|
||||
$updated_pet->name = 'updatePet'; // new name
|
||||
$updated_pet->status = 'pending'; // new status
|
||||
$updated_pet->setId($pet_id);
|
||||
$updated_pet->setName('updatePet'); // new name
|
||||
$updated_pet->setStatus('pending'); // new status
|
||||
// update Pet (model/json)
|
||||
$update_response = $pet_api->updatePet($updated_pet);
|
||||
// return nothing (void)
|
||||
$this->assertSame($update_response, NULL);
|
||||
// verify updated Pet
|
||||
$response = $pet_api->getPetById($pet_id);
|
||||
$this->assertSame($response->id, $pet_id);
|
||||
$this->assertSame($response->status, 'pending');
|
||||
$this->assertSame($response->name, 'updatePet');
|
||||
$this->assertSame($response->getId(), $pet_id);
|
||||
$this->assertSame($response->getStatus(), 'pending');
|
||||
$this->assertSame($response->getName(), 'updatePet');
|
||||
}
|
||||
|
||||
// test updatePet and verify by the "id" of the response
|
||||
public function testUpdatePetWithForm()
|
||||
{
|
||||
// initialize the API client
|
||||
$api_client = new Swagger\Client\ApiClient('http://petstore.swagger.io/v2');
|
||||
$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)
|
||||
@@ -164,20 +154,21 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
||||
// return nothing (void)
|
||||
$this->assertSame($update_response, NULL);
|
||||
$response = $pet_api->getPetById($pet_id);
|
||||
$this->assertSame($response->id, $pet_id);
|
||||
$this->assertSame($response->name, 'update pet with form');
|
||||
$this->assertSame($response->status, 'sold');
|
||||
$this->assertSame($response->getId(), $pet_id);
|
||||
$this->assertSame($response->getName(), 'update pet with form');
|
||||
$this->assertSame($response->getStatus(), 'sold');
|
||||
}
|
||||
|
||||
// test addPet and verify by the "id" and "name" of the response
|
||||
public function testAddPet()
|
||||
{
|
||||
// initialize the API client
|
||||
$api_client = new Swagger\Client\ApiClient('http://petstore.swagger.io/v2');
|
||||
$config = (new Swagger\Client\Configuration())->setHost('http://petstore.swagger.io/v2');
|
||||
$api_client = new Swagger\Client\ApiClient($config);
|
||||
$new_pet_id = 10001;
|
||||
$new_pet = new Swagger\Client\Model\Pet;
|
||||
$new_pet->id = $new_pet_id;
|
||||
$new_pet->name = "PHP Unit Test";
|
||||
$new_pet->setId($new_pet_id);
|
||||
$new_pet->setName("PHP Unit Test");
|
||||
$pet_api = new Swagger\Client\Api\PetAPI($api_client);
|
||||
// add a new pet (model)
|
||||
$add_response = $pet_api->addPet($new_pet);
|
||||
@@ -185,15 +176,16 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($add_response, NULL);
|
||||
// verify added Pet
|
||||
$response = $pet_api->getPetById($new_pet_id);
|
||||
$this->assertSame($response->id, $new_pet_id);
|
||||
$this->assertSame($response->name, 'PHP Unit Test');
|
||||
$this->assertSame($response->getId(), $new_pet_id);
|
||||
$this->assertSame($response->getName(), 'PHP Unit Test');
|
||||
}
|
||||
|
||||
// test upload file
|
||||
public function testUploadFile()
|
||||
{
|
||||
// initialize the API client
|
||||
$api_client = new Swagger\Client\ApiClient('http://petstore.swagger.io/v2');
|
||||
$config = (new Swagger\Client\Configuration())->setHost('http://petstore.swagger.io/v2');
|
||||
$api_client = new Swagger\Client\ApiClient($config);
|
||||
$pet_api = new Swagger\Client\Api\PetAPI($api_client);
|
||||
// upload file
|
||||
$pet_id = 10001;
|
||||
@@ -206,7 +198,9 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetInventory()
|
||||
{
|
||||
// initialize the API client
|
||||
$api_client = new Swagger\Client\APIClient('http://petstore.swagger.io/v2');
|
||||
$config = new Swagger\Client\Configuration();
|
||||
$config->setHost('http://petstore.swagger.io/v2');
|
||||
$api_client = new Swagger\Client\APIClient($config);
|
||||
$store_api = new Swagger\Client\Api\StoreAPI($api_client);
|
||||
// get inventory
|
||||
$get_response = $store_api->getInventory();
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once('SwaggerClient.php');
|
||||
require_once('autoload.php');
|
||||
|
||||
class StoreApiTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@@ -16,8 +16,9 @@ class StoreApiTest extends \PHPUnit_Framework_TestCase
|
||||
public function testGetInventory()
|
||||
{
|
||||
// initialize the API client
|
||||
$api_client = new SwaggerClient\APIClient('http://petstore.swagger.io/v2');
|
||||
$store_api = new SwaggerClient\StoreAPI($api_client);
|
||||
$config = (new Swagger\Client\Configuration())->setHost('http://petstore.swagger.io/v2');
|
||||
$api_client = new Swagger\Client\ApiClient($config);
|
||||
$store_api = new Swagger\Client\Api\StoreAPI($api_client);
|
||||
// get inventory
|
||||
$get_response = $store_api->getInventory();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
require_once('SwaggerClient.php');
|
||||
require_once('autoload.php');
|
||||
|
||||
class UserApiTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
@@ -16,8 +16,9 @@ class UserApiTest extends \PHPUnit_Framework_TestCase
|
||||
public function testLoginUser()
|
||||
{
|
||||
// initialize the API client
|
||||
$api_client = new SwaggerClient\APIClient('http://petstore.swagger.io/v2');
|
||||
$user_api = new SwaggerClient\UserAPI($api_client);
|
||||
$config = (new Swagger\Client\Configuration())->setHost('http://petstore.swagger.io/v2');
|
||||
$api_client = new Swagger\Client\ApiClient($config);
|
||||
$user_api = new Swagger\Client\Api\UserApi($api_client);
|
||||
// login
|
||||
$response = $user_api->loginUser("xxxxx", "yyyyyyyy");
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import sys
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
NAME = "swagger_client"
|
||||
VERSION = "1.0.0"
|
||||
|
||||
|
||||
|
||||
# To install the library, open a Terminal shell, then run this
|
||||
@@ -15,8 +18,8 @@ from setuptools import setup, find_packages
|
||||
REQUIRES = ["urllib3 >= 1.10", "six >= 1.9", "certifi"]
|
||||
|
||||
setup(
|
||||
name="SwaggerPetstore",
|
||||
version="1.0.0",
|
||||
name=NAME,
|
||||
version=VERSION,
|
||||
description="Swagger Petstore",
|
||||
author_email="apiteam@swagger.io",
|
||||
url="",
|
||||
|
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 42 KiB |
@@ -11,8 +11,8 @@ import os
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import SwaggerPetstore
|
||||
import SwaggerPetstore.configuration
|
||||
import swagger_client
|
||||
import swagger_client.configuration
|
||||
|
||||
HOST = 'http://petstore.swagger.io/v2'
|
||||
|
||||
@@ -20,20 +20,20 @@ HOST = 'http://petstore.swagger.io/v2'
|
||||
class ApiClientTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.api_client = SwaggerPetstore.ApiClient(HOST)
|
||||
self.api_client = swagger_client.ApiClient(HOST)
|
||||
|
||||
def test_configuration(self):
|
||||
SwaggerPetstore.configuration.api_key['api_key'] = '123456'
|
||||
SwaggerPetstore.configuration.api_key_prefix['api_key'] = 'PREFIX'
|
||||
SwaggerPetstore.configuration.username = 'test_username'
|
||||
SwaggerPetstore.configuration.password = 'test_password'
|
||||
swagger_client.configuration.api_key['api_key'] = '123456'
|
||||
swagger_client.configuration.api_key_prefix['api_key'] = 'PREFIX'
|
||||
swagger_client.configuration.username = 'test_username'
|
||||
swagger_client.configuration.password = 'test_password'
|
||||
|
||||
header_params = {'test1': 'value1'}
|
||||
query_params = {'test2': 'value2'}
|
||||
auth_settings = ['api_key', 'unknown']
|
||||
|
||||
# test prefix
|
||||
self.assertEqual('PREFIX', SwaggerPetstore.configuration.api_key_prefix['api_key'])
|
||||
self.assertEqual('PREFIX', swagger_client.configuration.api_key_prefix['api_key'])
|
||||
|
||||
# update parameters based on auth setting
|
||||
self.api_client.update_params_for_auth(header_params, query_params, auth_settings)
|
||||
@@ -44,8 +44,8 @@ class ApiClientTests(unittest.TestCase):
|
||||
self.assertEqual(query_params['test2'], 'value2')
|
||||
|
||||
# test basic auth
|
||||
self.assertEqual('test_username', SwaggerPetstore.configuration.username)
|
||||
self.assertEqual('test_password', SwaggerPetstore.configuration.password)
|
||||
self.assertEqual('test_username', swagger_client.configuration.username)
|
||||
self.assertEqual('test_password', swagger_client.configuration.password)
|
||||
|
||||
def test_select_header_accept(self):
|
||||
accepts = ['APPLICATION/JSON', 'APPLICATION/XML']
|
||||
@@ -114,7 +114,7 @@ class ApiClientTests(unittest.TestCase):
|
||||
|
||||
data = self.api_client.deserialize(json, 'dict(str, Pet)')
|
||||
self.assertTrue(isinstance(data, dict))
|
||||
self.assertTrue(isinstance(data['pet'], SwaggerPetstore.Pet))
|
||||
self.assertTrue(isinstance(data['pet'], swagger_client.Pet))
|
||||
|
||||
# dict(str, int)
|
||||
json = {
|
||||
@@ -128,6 +128,3 @@ class ApiClientTests(unittest.TestCase):
|
||||
def test_deserialize_to_object(self):
|
||||
data = self.api_client.deserialize("", "object")
|
||||
self.assertTrue(type(data) == object)
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"""
|
||||
Run the tests.
|
||||
$ pip install nose (optional)
|
||||
$ cd SwaggerPetstore-python
|
||||
$ cd swagger_client-python
|
||||
$ nosetests -v
|
||||
"""
|
||||
|
||||
@@ -11,25 +11,25 @@ import os
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import SwaggerPetstore
|
||||
from SwaggerPetstore.rest import ApiException
|
||||
import swagger_client
|
||||
from swagger_client.rest import ApiException
|
||||
|
||||
|
||||
class ApiExceptionTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.api_client = SwaggerPetstore.ApiClient()
|
||||
self.pet_api = SwaggerPetstore.PetApi(self.api_client)
|
||||
self.api_client = swagger_client.ApiClient()
|
||||
self.pet_api = swagger_client.PetApi(self.api_client)
|
||||
self.setUpModels()
|
||||
|
||||
def setUpModels(self):
|
||||
self.category = SwaggerPetstore.Category()
|
||||
self.category = swagger_client.Category()
|
||||
self.category.id = int(time.time())
|
||||
self.category.name = "dog"
|
||||
self.tag = SwaggerPetstore.Tag()
|
||||
self.tag = swagger_client.Tag()
|
||||
self.tag.id = int(time.time())
|
||||
self.tag.name = "blank"
|
||||
self.pet = SwaggerPetstore.Pet()
|
||||
self.pet = swagger_client.Pet()
|
||||
self.pet.id = int(time.time())
|
||||
self.pet.name = "hello kity"
|
||||
self.pet.photo_urls = ["http://foo.bar.com/1", "http://foo.bar.com/2"]
|
||||
@@ -3,7 +3,7 @@
|
||||
"""
|
||||
Run the tests.
|
||||
$ pip install nose (optional)
|
||||
$ cd SwaggerPetstore-python
|
||||
$ cd swagger_client-python
|
||||
$ nosetests -v
|
||||
"""
|
||||
|
||||
@@ -11,8 +11,8 @@ import os
|
||||
import time
|
||||
import unittest
|
||||
|
||||
import SwaggerPetstore
|
||||
from SwaggerPetstore.rest import ApiException
|
||||
import swagger_client
|
||||
from swagger_client.rest import ApiException
|
||||
|
||||
HOST = 'http://petstore.swagger.io/v2'
|
||||
|
||||
@@ -20,8 +20,8 @@ HOST = 'http://petstore.swagger.io/v2'
|
||||
class PetApiTests(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.api_client = SwaggerPetstore.ApiClient(HOST)
|
||||
self.pet_api = SwaggerPetstore.PetApi(self.api_client)
|
||||
self.api_client = swagger_client.ApiClient(HOST)
|
||||
self.pet_api = swagger_client.PetApi(self.api_client)
|
||||
self.setUpModels()
|
||||
self.setUpFiles()
|
||||
|
||||
@@ -30,13 +30,13 @@ class PetApiTests(unittest.TestCase):
|
||||
time.sleep(1)
|
||||
|
||||
def setUpModels(self):
|
||||
self.category = SwaggerPetstore.Category()
|
||||
self.category = swagger_client.Category()
|
||||
self.category.id = int(time.time())
|
||||
self.category.name = "dog"
|
||||
self.tag = SwaggerPetstore.Tag()
|
||||
self.tag = swagger_client.Tag()
|
||||
self.tag.id = int(time.time())
|
||||
self.tag.name = "blank"
|
||||
self.pet = SwaggerPetstore.Pet()
|
||||
self.pet = swagger_client.Pet()
|
||||
self.pet.id = int(time.time())
|
||||
self.pet.name = "hello kity"
|
||||
self.pet.photo_urls = ["http://foo.bar.com/1", "http://foo.bar.com/2"]
|
||||
@@ -50,22 +50,22 @@ class PetApiTests(unittest.TestCase):
|
||||
self.foo = os.path.join(self.test_file_dir, "foo.png")
|
||||
|
||||
def test_create_api_instance(self):
|
||||
pet_api = SwaggerPetstore.PetApi()
|
||||
pet_api2 = SwaggerPetstore.PetApi()
|
||||
api_client3 = SwaggerPetstore.ApiClient()
|
||||
pet_api = swagger_client.PetApi()
|
||||
pet_api2 = swagger_client.PetApi()
|
||||
api_client3 = swagger_client.ApiClient()
|
||||
api_client3.user_agent = 'api client 3'
|
||||
api_client4 = SwaggerPetstore.ApiClient()
|
||||
api_client4 = swagger_client.ApiClient()
|
||||
api_client4.user_agent = 'api client 4'
|
||||
pet_api3 = SwaggerPetstore.PetApi(api_client3)
|
||||
pet_api3 = swagger_client.PetApi(api_client3)
|
||||
|
||||
# same default api client
|
||||
self.assertEqual(pet_api.api_client, pet_api2.api_client)
|
||||
# confirm using the default api client in the config module
|
||||
self.assertEqual(pet_api.api_client, SwaggerPetstore.configuration.api_client)
|
||||
self.assertEqual(pet_api.api_client, swagger_client.configuration.api_client)
|
||||
# 2 different api clients are not the same
|
||||
self.assertNotEqual(api_client3, api_client4)
|
||||
# customized pet api not using the default api client
|
||||
self.assertNotEqual(pet_api3.api_client, SwaggerPetstore.configuration.api_client)
|
||||
self.assertNotEqual(pet_api3.api_client, swagger_client.configuration.api_client)
|
||||
# customized pet api not using the old pet api's api client
|
||||
self.assertNotEqual(pet_api3.api_client, pet_api2.api_client)
|
||||
|
||||
@@ -72,6 +72,7 @@
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.9.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add_sources</id>
|
||||
@@ -208,7 +209,7 @@
|
||||
<scala-version>2.10.4</scala-version>
|
||||
<joda-version>1.2</joda-version>
|
||||
<joda-time-version>2.2</joda-time-version>
|
||||
<jersey-version>1.7</jersey-version>
|
||||
<jersey-version>1.19</jersey-version>
|
||||
<swagger-core-version>1.5.0</swagger-core-version>
|
||||
<jersey-async-version>1.0.5</jersey-async-version>
|
||||
<maven-plugin.version>1.0.0</maven-plugin.version>
|
||||
@@ -216,6 +217,8 @@
|
||||
|
||||
<junit-version>4.8.1</junit-version>
|
||||
<scala-maven-plugin-version>3.1.5</scala-maven-plugin-version>
|
||||
<scala-test-version>2.1.3</scala-test-version>
|
||||
<scala-test-version>2.2.4</scala-test-version>
|
||||
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
@@ -141,7 +141,7 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
||||
}
|
||||
case _ => null
|
||||
}
|
||||
response.getClientResponseStatus().getStatusCode() match {
|
||||
response.getStatusInfo().getStatusCode() match {
|
||||
case 204 => ""
|
||||
case code: Int if (Range(200, 299).contains(code)) => {
|
||||
response.hasEntity() match {
|
||||
@@ -155,7 +155,7 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
||||
case false => "no data"
|
||||
}
|
||||
throw new ApiException(
|
||||
response.getClientResponseStatus().getStatusCode(),
|
||||
response.getStatusInfo().getStatusCode(),
|
||||
entity)
|
||||
}
|
||||
}
|
||||
@@ -172,7 +172,7 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def newClient(host: String): Client = asyncHttpClient match {
|
||||
case true => {
|
||||
import org.sonatype.spice.jersey.client.ahc.config.DefaultAhcConfig
|
||||
@@ -200,4 +200,3 @@ object ApiInvoker extends ApiInvoker(mapper = ScalaJsonUtil.getJsonMapper,
|
||||
authPreemptive = false)
|
||||
|
||||
class ApiException(val code: Int, msg: String) extends RuntimeException(msg)
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package io.swagger.client.model
|
||||
|
||||
import io.swagger.client.model.Category
|
||||
import io.swagger.client.model.Tag
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
|
||||
</IfModule>
|
||||
@@ -1,10 +0,0 @@
|
||||
# Swagger generated server
|
||||
|
||||
## Overview
|
||||
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the
|
||||
[swagger-spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This
|
||||
is an example of building a PHP server.
|
||||
|
||||
This example uses the [Silex](http://silex.sensiolabs.org/) micro-framework. To see how to make this your own, please take a look at the template here:
|
||||
|
||||
[TEMPLATES](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources/silex/)
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"require": {
|
||||
"silex/silex": "~1.2"
|
||||
}
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Silex\Application;
|
||||
|
||||
$app = new Silex\Application();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$app->POST('/user', function(Application $app, Request $request) {
|
||||
|
||||
|
||||
return new Response('How about implementing createUser as a POST method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->POST('/user/createWithArray', function(Application $app, Request $request) {
|
||||
|
||||
|
||||
return new Response('How about implementing createUsersWithArrayInput as a POST method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->POST('/user/createWithList', function(Application $app, Request $request) {
|
||||
|
||||
|
||||
return new Response('How about implementing createUsersWithListInput as a POST method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->GET('/user/login', function(Application $app, Request $request) {
|
||||
$username = $request->get('username'); $password = $request->get('password');
|
||||
|
||||
return new Response('How about implementing loginUser as a GET method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->GET('/user/logout', function(Application $app, Request $request) {
|
||||
|
||||
|
||||
return new Response('How about implementing logoutUser as a GET method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->GET('/user/{username}', function(Application $app, Request $request, $username) {
|
||||
|
||||
|
||||
return new Response('How about implementing getUserByName as a GET method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->PUT('/user/{username}', function(Application $app, Request $request, $username) {
|
||||
|
||||
|
||||
return new Response('How about implementing updateUser as a PUT method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->DELETE('/user/{username}', function(Application $app, Request $request, $username) {
|
||||
|
||||
|
||||
return new Response('How about implementing deleteUser as a DELETE method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$app->PUT('/pet', function(Application $app, Request $request) {
|
||||
|
||||
|
||||
return new Response('How about implementing updatePet as a PUT method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->POST('/pet', function(Application $app, Request $request) {
|
||||
|
||||
|
||||
return new Response('How about implementing addPet as a POST method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->GET('/pet/findByStatus', function(Application $app, Request $request) {
|
||||
$status = $request->get('status');
|
||||
|
||||
return new Response('How about implementing findPetsByStatus as a GET method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->GET('/pet/findByTags', function(Application $app, Request $request) {
|
||||
$tags = $request->get('tags');
|
||||
|
||||
return new Response('How about implementing findPetsByTags as a GET method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->GET('/pet/{petId}', function(Application $app, Request $request, $pet_id) {
|
||||
|
||||
|
||||
return new Response('How about implementing getPetById as a GET method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->POST('/pet/{petId}', function(Application $app, Request $request, $pet_id) {
|
||||
|
||||
$name = $request->get('name'); $status = $request->get('status');
|
||||
return new Response('How about implementing updatePetWithForm as a POST method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->DELETE('/pet/{petId}', function(Application $app, Request $request, $pet_id) {
|
||||
|
||||
|
||||
return new Response('How about implementing deletePet as a DELETE method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->POST('/pet/{petId}/uploadImage', function(Application $app, Request $request, $pet_id) {
|
||||
|
||||
$additional_metadata = $request->get('additional_metadata'); $file = $request->get('file');
|
||||
return new Response('How about implementing uploadFile as a POST method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$app->GET('/store/inventory', function(Application $app, Request $request) {
|
||||
|
||||
|
||||
return new Response('How about implementing getInventory as a GET method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->POST('/store/order', function(Application $app, Request $request) {
|
||||
|
||||
|
||||
return new Response('How about implementing placeOrder as a POST method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->GET('/store/order/{orderId}', function(Application $app, Request $request, $order_id) {
|
||||
|
||||
|
||||
return new Response('How about implementing getOrderById as a GET method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->DELETE('/store/order/{orderId}', function(Application $app, Request $request, $order_id) {
|
||||
|
||||
|
||||
return new Response('How about implementing deleteOrder as a DELETE method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$app->run();
|
||||
@@ -1,5 +0,0 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteRule ^(.*)$ index.php?_url=/$1 [QSA,L]
|
||||
</IfModule>
|
||||
@@ -1,10 +0,0 @@
|
||||
# Swagger generated server
|
||||
|
||||
## Overview
|
||||
This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the
|
||||
[swagger-spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This
|
||||
is an example of building a PHP server.
|
||||
|
||||
This example uses the [Silex](http://silex.sensiolabs.org/) micro-framework. To see how to make this your own, please take a look at the template here:
|
||||
|
||||
[TEMPLATES](https://github.com/swagger-api/swagger-codegen/tree/master/modules/swagger-codegen/src/main/resources/silex/)
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"require": {
|
||||
"silex/silex": "~1.2"
|
||||
}
|
||||
}
|
||||
@@ -1,184 +0,0 @@
|
||||
<?php
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Silex\Application;
|
||||
|
||||
$app = new Silex\Application();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$app->POST('/user', function(Application $app, Request $request) {
|
||||
|
||||
|
||||
return new Response('How about implementing createUser as a POST method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->POST('/user/createWithArray', function(Application $app, Request $request) {
|
||||
|
||||
|
||||
return new Response('How about implementing createUsersWithArrayInput as a POST method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->POST('/user/createWithList', function(Application $app, Request $request) {
|
||||
|
||||
|
||||
return new Response('How about implementing createUsersWithListInput as a POST method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->GET('/user/login', function(Application $app, Request $request) {
|
||||
$username = $request->get('username'); $password = $request->get('password');
|
||||
|
||||
return new Response('How about implementing loginUser as a GET method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->GET('/user/logout', function(Application $app, Request $request) {
|
||||
|
||||
|
||||
return new Response('How about implementing logoutUser as a GET method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->GET('/user/{username}', function(Application $app, Request $request, $username) {
|
||||
|
||||
|
||||
return new Response('How about implementing getUserByName as a GET method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->PUT('/user/{username}', function(Application $app, Request $request, $username) {
|
||||
|
||||
|
||||
return new Response('How about implementing updateUser as a PUT method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->DELETE('/user/{username}', function(Application $app, Request $request, $username) {
|
||||
|
||||
|
||||
return new Response('How about implementing deleteUser as a DELETE method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$app->PUT('/pet', function(Application $app, Request $request) {
|
||||
|
||||
|
||||
return new Response('How about implementing updatePet as a PUT method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->POST('/pet', function(Application $app, Request $request) {
|
||||
|
||||
|
||||
return new Response('How about implementing addPet as a POST method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->GET('/pet/findByStatus', function(Application $app, Request $request) {
|
||||
$status = $request->get('status');
|
||||
|
||||
return new Response('How about implementing findPetsByStatus as a GET method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->GET('/pet/findByTags', function(Application $app, Request $request) {
|
||||
$tags = $request->get('tags');
|
||||
|
||||
return new Response('How about implementing findPetsByTags as a GET method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->GET('/pet/{petId}', function(Application $app, Request $request, $pet_id) {
|
||||
|
||||
|
||||
return new Response('How about implementing getPetById as a GET method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->POST('/pet/{petId}', function(Application $app, Request $request, $pet_id) {
|
||||
|
||||
$name = $request->get('name'); $status = $request->get('status');
|
||||
return new Response('How about implementing updatePetWithForm as a POST method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->DELETE('/pet/{petId}', function(Application $app, Request $request, $pet_id) {
|
||||
|
||||
|
||||
return new Response('How about implementing deletePet as a DELETE method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->POST('/pet/{petId}/uploadImage', function(Application $app, Request $request, $pet_id) {
|
||||
|
||||
$additional_metadata = $request->get('additional_metadata'); $file = $request->get('file');
|
||||
return new Response('How about implementing uploadFile as a POST method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$app->GET('/store/inventory', function(Application $app, Request $request) {
|
||||
|
||||
|
||||
return new Response('How about implementing getInventory as a GET method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->POST('/store/order', function(Application $app, Request $request) {
|
||||
|
||||
|
||||
return new Response('How about implementing placeOrder as a POST method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->GET('/store/order/{orderId}', function(Application $app, Request $request, $order_id) {
|
||||
|
||||
|
||||
return new Response('How about implementing getOrderById as a GET method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
$app->DELETE('/store/order/{orderId}', function(Application $app, Request $request, $order_id) {
|
||||
|
||||
|
||||
return new Response('How about implementing deleteOrder as a DELETE method ?');
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$app->run();
|
||||
13
samples/client/petstore/typescript-angular/api/Category.ts
Normal file
13
samples/client/petstore/typescript-angular/api/Category.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
/// <reference path="api.d.ts" />
|
||||
|
||||
module api {
|
||||
'use strict';
|
||||
|
||||
export class Category {
|
||||
|
||||
id: number;
|
||||
|
||||
name: string;
|
||||
}
|
||||
|
||||
}
|
||||
32
samples/client/petstore/typescript-angular/api/Order.ts
Normal file
32
samples/client/petstore/typescript-angular/api/Order.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/// <reference path="api.d.ts" />
|
||||
|
||||
module api {
|
||||
'use strict';
|
||||
|
||||
export class Order {
|
||||
|
||||
id: number;
|
||||
|
||||
petId: number;
|
||||
|
||||
quantity: number;
|
||||
|
||||
shipDate: DateTime;
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*/
|
||||
status: Order.StatusEnum;
|
||||
|
||||
complete: boolean;
|
||||
}
|
||||
|
||||
export module Order {
|
||||
|
||||
export enum StatusEnum {
|
||||
placed = <any> 'placed',
|
||||
approved = <any> 'approved',
|
||||
delivered = <any> 'delivered',
|
||||
}
|
||||
}
|
||||
}
|
||||
32
samples/client/petstore/typescript-angular/api/Pet.ts
Normal file
32
samples/client/petstore/typescript-angular/api/Pet.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
/// <reference path="api.d.ts" />
|
||||
|
||||
module api {
|
||||
'use strict';
|
||||
|
||||
export class Pet {
|
||||
|
||||
id: number;
|
||||
|
||||
category: Category;
|
||||
|
||||
name: string;
|
||||
|
||||
photoUrls: Array<string>;
|
||||
|
||||
tags: Array<Tag>;
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
*/
|
||||
status: Pet.StatusEnum;
|
||||
}
|
||||
|
||||
export module Pet {
|
||||
|
||||
export enum StatusEnum {
|
||||
available = <any> 'available',
|
||||
pending = <any> 'pending',
|
||||
sold = <any> 'sold',
|
||||
}
|
||||
}
|
||||
}
|
||||
282
samples/client/petstore/typescript-angular/api/PetApi.ts
Normal file
282
samples/client/petstore/typescript-angular/api/PetApi.ts
Normal file
@@ -0,0 +1,282 @@
|
||||
/// <reference path="api.d.ts" />
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
module api {
|
||||
'use strict';
|
||||
|
||||
|
||||
export class PetApi {
|
||||
private basePath = 'http://petstore.swagger.io/v2';
|
||||
|
||||
static $inject: string[] = ['$http'];
|
||||
|
||||
constructor(private $http: ng.IHttpService, basePath?: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
}
|
||||
|
||||
public updatePet (body: Pet, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/pet';
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'PUT',
|
||||
url: path,
|
||||
json: true,
|
||||
data: body,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public addPet (body: Pet, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/pet';
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: true,
|
||||
data: body,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public findPetsByStatus (status: Array<string>, extraHttpRequestParams?: any ) : ng.IHttpPromise<Array<Pet>> {
|
||||
var path = this.basePath + '/pet/findByStatus';
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
if (status !== undefined) {
|
||||
queryParameters['status'] = status;
|
||||
}
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public findPetsByTags (tags: Array<string>, extraHttpRequestParams?: any ) : ng.IHttpPromise<Array<Pet>> {
|
||||
var path = this.basePath + '/pet/findByTags';
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
if (tags !== undefined) {
|
||||
queryParameters['tags'] = tags;
|
||||
}
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public getPetById (petId: number, extraHttpRequestParams?: any ) : ng.IHttpPromise<Pet> {
|
||||
var path = this.basePath + '/pet/{petId}';
|
||||
|
||||
path = path.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling getPetById');
|
||||
}
|
||||
|
||||
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public updatePetWithForm (petId: string, name: string, status: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/pet/{petId}';
|
||||
|
||||
path = path.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling updatePetWithForm');
|
||||
}
|
||||
|
||||
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public deletePet (apiKey: string, petId: number, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/pet/{petId}';
|
||||
|
||||
path = path.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling deletePet');
|
||||
}
|
||||
|
||||
|
||||
headerParams['apiKey'] = apiKey;
|
||||
var httpRequestParams: any = {
|
||||
method: 'DELETE',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public uploadFile (petId: number, additionalMetadata: string, file: file, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/pet/{petId}/uploadImage';
|
||||
|
||||
path = path.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling uploadFile');
|
||||
}
|
||||
|
||||
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
angular.module('api_PetApi', ['$http'])
|
||||
.service('PetApi', PetApi);
|
||||
}
|
||||
151
samples/client/petstore/typescript-angular/api/StoreApi.ts
Normal file
151
samples/client/petstore/typescript-angular/api/StoreApi.ts
Normal file
@@ -0,0 +1,151 @@
|
||||
/// <reference path="api.d.ts" />
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
module api {
|
||||
'use strict';
|
||||
|
||||
|
||||
export class StoreApi {
|
||||
private basePath = 'http://petstore.swagger.io/v2';
|
||||
|
||||
static $inject: string[] = ['$http'];
|
||||
|
||||
constructor(private $http: ng.IHttpService, basePath?: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
}
|
||||
|
||||
public getInventory ( extraHttpRequestParams?: any ) : ng.IHttpPromise<map<String, number>> {
|
||||
var path = this.basePath + '/store/inventory';
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public placeOrder (body: Order, extraHttpRequestParams?: any ) : ng.IHttpPromise<Order> {
|
||||
var path = this.basePath + '/store/order';
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: true,
|
||||
data: body,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public getOrderById (orderId: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<Order> {
|
||||
var path = this.basePath + '/store/order/{orderId}';
|
||||
|
||||
path = path.replace('{' + 'orderId' + '}', String(orderId));
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
// verify required parameter 'orderId' is set
|
||||
if (!orderId) {
|
||||
throw new Error('Missing required parameter orderId when calling getOrderById');
|
||||
}
|
||||
|
||||
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public deleteOrder (orderId: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/store/order/{orderId}';
|
||||
|
||||
path = path.replace('{' + 'orderId' + '}', String(orderId));
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
// verify required parameter 'orderId' is set
|
||||
if (!orderId) {
|
||||
throw new Error('Missing required parameter orderId when calling deleteOrder');
|
||||
}
|
||||
|
||||
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'DELETE',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
angular.module('api_StoreApi', ['$http'])
|
||||
.service('StoreApi', StoreApi);
|
||||
}
|
||||
13
samples/client/petstore/typescript-angular/api/Tag.ts
Normal file
13
samples/client/petstore/typescript-angular/api/Tag.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
/// <reference path="api.d.ts" />
|
||||
|
||||
module api {
|
||||
'use strict';
|
||||
|
||||
export class Tag {
|
||||
|
||||
id: number;
|
||||
|
||||
name: string;
|
||||
}
|
||||
|
||||
}
|
||||
28
samples/client/petstore/typescript-angular/api/User.ts
Normal file
28
samples/client/petstore/typescript-angular/api/User.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
/// <reference path="api.d.ts" />
|
||||
|
||||
module api {
|
||||
'use strict';
|
||||
|
||||
export class User {
|
||||
|
||||
id: number;
|
||||
|
||||
username: string;
|
||||
|
||||
firstName: string;
|
||||
|
||||
lastName: string;
|
||||
|
||||
email: string;
|
||||
|
||||
password: string;
|
||||
|
||||
phone: string;
|
||||
|
||||
/**
|
||||
* User Status
|
||||
*/
|
||||
userStatus: number;
|
||||
}
|
||||
|
||||
}
|
||||
277
samples/client/petstore/typescript-angular/api/UserApi.ts
Normal file
277
samples/client/petstore/typescript-angular/api/UserApi.ts
Normal file
@@ -0,0 +1,277 @@
|
||||
/// <reference path="api.d.ts" />
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
module api {
|
||||
'use strict';
|
||||
|
||||
|
||||
export class UserApi {
|
||||
private basePath = 'http://petstore.swagger.io/v2';
|
||||
|
||||
static $inject: string[] = ['$http'];
|
||||
|
||||
constructor(private $http: ng.IHttpService, basePath?: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
}
|
||||
|
||||
public createUser (body: User, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/user';
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: true,
|
||||
data: body,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public createUsersWithArrayInput (body: Array<User>, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/user/createWithArray';
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: true,
|
||||
data: body,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public createUsersWithListInput (body: Array<User>, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/user/createWithList';
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: true,
|
||||
data: body,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public loginUser (username: string, password: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<string> {
|
||||
var path = this.basePath + '/user/login';
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
if (username !== undefined) {
|
||||
queryParameters['username'] = username;
|
||||
}if (password !== undefined) {
|
||||
queryParameters['password'] = password;
|
||||
}
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public logoutUser ( extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/user/logout';
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public getUserByName (username: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<User> {
|
||||
var path = this.basePath + '/user/{username}';
|
||||
|
||||
path = path.replace('{' + 'username' + '}', String(username));
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
// verify required parameter 'username' is set
|
||||
if (!username) {
|
||||
throw new Error('Missing required parameter username when calling getUserByName');
|
||||
}
|
||||
|
||||
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public updateUser (username: string, body: User, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/user/{username}';
|
||||
|
||||
path = path.replace('{' + 'username' + '}', String(username));
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
// verify required parameter 'username' is set
|
||||
if (!username) {
|
||||
throw new Error('Missing required parameter username when calling updateUser');
|
||||
}
|
||||
|
||||
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'PUT',
|
||||
url: path,
|
||||
json: true,
|
||||
data: body,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public deleteUser (username: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/user/{username}';
|
||||
|
||||
path = path.replace('{' + 'username' + '}', String(username));
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
// verify required parameter 'username' is set
|
||||
if (!username) {
|
||||
throw new Error('Missing required parameter username when calling deleteUser');
|
||||
}
|
||||
|
||||
|
||||
|
||||
var httpRequestParams: any = {
|
||||
method: 'DELETE',
|
||||
url: path,
|
||||
json: true,
|
||||
|
||||
params: queryParameters,
|
||||
headers: headers
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams){
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
angular.module('api_UserApi', ['$http'])
|
||||
.service('UserApi', UserApi);
|
||||
}
|
||||
9
samples/client/petstore/typescript-angular/api/api.d.ts
vendored
Normal file
9
samples/client/petstore/typescript-angular/api/api.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/// <reference path="User.ts" />
|
||||
/// <reference path="Category.ts" />
|
||||
/// <reference path="Pet.ts" />
|
||||
/// <reference path="Tag.ts" />
|
||||
/// <reference path="Order.ts" />
|
||||
|
||||
/// <reference path="UserApi.ts" />
|
||||
/// <reference path="PetApi.ts" />
|
||||
/// <reference path="StoreApi.ts" />
|
||||
378
samples/client/petstore/typescript-node/api/PetApi.ts
Normal file
378
samples/client/petstore/typescript-node/api/PetApi.ts
Normal file
@@ -0,0 +1,378 @@
|
||||
/* tslint:disable:no-unused-variable */
|
||||
|
||||
export class PetApi {
|
||||
private basePath = 'http://petstore.swagger.io/v2';
|
||||
|
||||
constructor(private url: string, private username: string, private password: string, basePath?: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public updatePet (body: Pet ) : Promise<{ response: http.ClientResponse; }> {
|
||||
var path = this.url + this.basePath + '/pet';
|
||||
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; }>();
|
||||
|
||||
request({
|
||||
method: 'PUT',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
body: body,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public addPet (body: Pet ) : Promise<{ response: http.ClientResponse; }> {
|
||||
var path = this.url + this.basePath + '/pet';
|
||||
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; }>();
|
||||
|
||||
request({
|
||||
method: 'POST',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
body: body,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public findPetsByStatus (status: Array<string> ) : Promise<{ response: http.ClientResponse; body: Array<Pet>; }> {
|
||||
var path = this.url + this.basePath + '/pet/findByStatus';
|
||||
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
if (status !== undefined) {
|
||||
queryParameters['status'] = status;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; body: Array<Pet>; }>();
|
||||
|
||||
request({
|
||||
method: 'GET',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public findPetsByTags (tags: Array<string> ) : Promise<{ response: http.ClientResponse; body: Array<Pet>; }> {
|
||||
var path = this.url + this.basePath + '/pet/findByTags';
|
||||
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
if (tags !== undefined) {
|
||||
queryParameters['tags'] = tags;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; body: Array<Pet>; }>();
|
||||
|
||||
request({
|
||||
method: 'GET',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public getPetById (petId: number ) : Promise<{ response: http.ClientResponse; body: Pet; }> {
|
||||
var path = this.url + this.basePath + '/pet/{petId}';
|
||||
|
||||
|
||||
path = path.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling getPetById');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; body: Pet; }>();
|
||||
|
||||
request({
|
||||
method: 'GET',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public updatePetWithForm (petId: string, name: string, status: string ) : Promise<{ response: http.ClientResponse; }> {
|
||||
var path = this.url + this.basePath + '/pet/{petId}';
|
||||
|
||||
|
||||
path = path.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling updatePetWithForm');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; }>();
|
||||
|
||||
request({
|
||||
method: 'POST',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public deletePet (apiKey: string, petId: number ) : Promise<{ response: http.ClientResponse; }> {
|
||||
var path = this.url + this.basePath + '/pet/{petId}';
|
||||
|
||||
|
||||
path = path.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling deletePet');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
headerParams['apiKey'] = apiKey;
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; }>();
|
||||
|
||||
request({
|
||||
method: 'DELETE',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public uploadFile (petId: number, additionalMetadata: string, file: file ) : Promise<{ response: http.ClientResponse; }> {
|
||||
var path = this.url + this.basePath + '/pet/{petId}/uploadImage';
|
||||
|
||||
|
||||
path = path.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling uploadFile');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; }>();
|
||||
|
||||
request({
|
||||
method: 'POST',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
192
samples/client/petstore/typescript-node/api/StoreApi.ts
Normal file
192
samples/client/petstore/typescript-node/api/StoreApi.ts
Normal file
@@ -0,0 +1,192 @@
|
||||
/* tslint:disable:no-unused-variable */
|
||||
|
||||
export class StoreApi {
|
||||
private basePath = 'http://petstore.swagger.io/v2';
|
||||
|
||||
constructor(private url: string, private username: string, private password: string, basePath?: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public getInventory ( ) : Promise<{ response: http.ClientResponse; body: map<String, number>; }> {
|
||||
var path = this.url + this.basePath + '/store/inventory';
|
||||
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; body: map<String, number>; }>();
|
||||
|
||||
request({
|
||||
method: 'GET',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public placeOrder (body: Order ) : Promise<{ response: http.ClientResponse; body: Order; }> {
|
||||
var path = this.url + this.basePath + '/store/order';
|
||||
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; body: Order; }>();
|
||||
|
||||
request({
|
||||
method: 'POST',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
body: body,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public getOrderById (orderId: string ) : Promise<{ response: http.ClientResponse; body: Order; }> {
|
||||
var path = this.url + this.basePath + '/store/order/{orderId}';
|
||||
|
||||
|
||||
path = path.replace('{' + 'orderId' + '}', String(orderId));
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
// verify required parameter 'orderId' is set
|
||||
if (!orderId) {
|
||||
throw new Error('Missing required parameter orderId when calling getOrderById');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; body: Order; }>();
|
||||
|
||||
request({
|
||||
method: 'GET',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public deleteOrder (orderId: string ) : Promise<{ response: http.ClientResponse; }> {
|
||||
var path = this.url + this.basePath + '/store/order/{orderId}';
|
||||
|
||||
|
||||
path = path.replace('{' + 'orderId' + '}', String(orderId));
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
// verify required parameter 'orderId' is set
|
||||
if (!orderId) {
|
||||
throw new Error('Missing required parameter orderId when calling deleteOrder');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; }>();
|
||||
|
||||
request({
|
||||
method: 'DELETE',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
372
samples/client/petstore/typescript-node/api/UserApi.ts
Normal file
372
samples/client/petstore/typescript-node/api/UserApi.ts
Normal file
@@ -0,0 +1,372 @@
|
||||
/* tslint:disable:no-unused-variable */
|
||||
|
||||
export class UserApi {
|
||||
private basePath = 'http://petstore.swagger.io/v2';
|
||||
|
||||
constructor(private url: string, private username: string, private password: string, basePath?: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public createUser (body: User ) : Promise<{ response: http.ClientResponse; }> {
|
||||
var path = this.url + this.basePath + '/user';
|
||||
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; }>();
|
||||
|
||||
request({
|
||||
method: 'POST',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
body: body,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public createUsersWithArrayInput (body: Array<User> ) : Promise<{ response: http.ClientResponse; }> {
|
||||
var path = this.url + this.basePath + '/user/createWithArray';
|
||||
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; }>();
|
||||
|
||||
request({
|
||||
method: 'POST',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
body: body,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public createUsersWithListInput (body: Array<User> ) : Promise<{ response: http.ClientResponse; }> {
|
||||
var path = this.url + this.basePath + '/user/createWithList';
|
||||
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; }>();
|
||||
|
||||
request({
|
||||
method: 'POST',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
body: body,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public loginUser (username: string, password: string ) : Promise<{ response: http.ClientResponse; body: string; }> {
|
||||
var path = this.url + this.basePath + '/user/login';
|
||||
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
if (username !== undefined) {
|
||||
queryParameters['username'] = username;
|
||||
}
|
||||
if (password !== undefined) {
|
||||
queryParameters['password'] = password;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; body: string; }>();
|
||||
|
||||
request({
|
||||
method: 'GET',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public logoutUser ( ) : Promise<{ response: http.ClientResponse; }> {
|
||||
var path = this.url + this.basePath + '/user/logout';
|
||||
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; }>();
|
||||
|
||||
request({
|
||||
method: 'GET',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public getUserByName (username: string ) : Promise<{ response: http.ClientResponse; body: User; }> {
|
||||
var path = this.url + this.basePath + '/user/{username}';
|
||||
|
||||
|
||||
path = path.replace('{' + 'username' + '}', String(username));
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
// verify required parameter 'username' is set
|
||||
if (!username) {
|
||||
throw new Error('Missing required parameter username when calling getUserByName');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; body: User; }>();
|
||||
|
||||
request({
|
||||
method: 'GET',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public updateUser (username: string, body: User ) : Promise<{ response: http.ClientResponse; }> {
|
||||
var path = this.url + this.basePath + '/user/{username}';
|
||||
|
||||
|
||||
path = path.replace('{' + 'username' + '}', String(username));
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
// verify required parameter 'username' is set
|
||||
if (!username) {
|
||||
throw new Error('Missing required parameter username when calling updateUser');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; }>();
|
||||
|
||||
request({
|
||||
method: 'PUT',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
body: body,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
public deleteUser (username: string ) : Promise<{ response: http.ClientResponse; }> {
|
||||
var path = this.url + this.basePath + '/user/{username}';
|
||||
|
||||
|
||||
path = path.replace('{' + 'username' + '}', String(username));
|
||||
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headers: any = {};
|
||||
|
||||
|
||||
// verify required parameter 'username' is set
|
||||
if (!username) {
|
||||
throw new Error('Missing required parameter username when calling deleteUser');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
var deferred = promise.defer<{ response: http.ClientResponse; }>();
|
||||
|
||||
request({
|
||||
method: 'DELETE',
|
||||
qs: queryParameters,
|
||||
uri: path,
|
||||
json: true,
|
||||
|
||||
auth: {
|
||||
username: this.username, password: this.password
|
||||
}
|
||||
}, (error, response, body) => {
|
||||
if (error) {
|
||||
deferred.reject(error);
|
||||
} else {
|
||||
if (response.statusCode >= 200 && response.statusCode <= 299) {
|
||||
deferred.resolve({ response: response, body: body });
|
||||
} else {
|
||||
deferred.reject({ response: response, body: body });
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user