Regenerate PHP petstore sample

This commit is contained in:
Arne Jørgensen 2016-03-16 13:08:09 +01:00
parent 3823612674
commit 55ef72d47e
9 changed files with 196 additions and 144 deletions

View File

@ -89,10 +89,25 @@ Class | Method | HTTP request | Description
## Documentation For Authorization ## Documentation For Authorization
## test_api_key_header ## petstore_auth
- **Type**: OAuth
- **Flow**: implicit
- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog
- **Scopes**:
- **write:pets**: modify pets in your account
- **read:pets**: read your pets
## test_api_client_id
- **Type**: API key - **Type**: API key
- **API key parameter name**: test_api_key_header - **API key parameter name**: x-test_api_client_id
- **Location**: HTTP header
## test_api_client_secret
- **Type**: API key
- **API key parameter name**: x-test_api_client_secret
- **Location**: HTTP header - **Location**: HTTP header
## api_key ## api_key
@ -105,32 +120,17 @@ Class | Method | HTTP request | Description
- **Type**: HTTP basic authentication - **Type**: HTTP basic authentication
## test_api_client_secret
- **Type**: API key
- **API key parameter name**: x-test_api_client_secret
- **Location**: HTTP header
## test_api_client_id
- **Type**: API key
- **API key parameter name**: x-test_api_client_id
- **Location**: HTTP header
## test_api_key_query ## test_api_key_query
- **Type**: API key - **Type**: API key
- **API key parameter name**: test_api_key_query - **API key parameter name**: test_api_key_query
- **Location**: URL query string - **Location**: URL query string
## petstore_auth ## test_api_key_header
- **Type**: OAuth - **Type**: API key
- **Flow**: implicit - **API key parameter name**: test_api_key_header
- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog - **Location**: HTTP header
- **Scopes**:
- **write:pets**: modify pets in your account
- **read:pets**: read your pets
## Author ## Author

View File

@ -3,12 +3,12 @@
## Properties ## Properties
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**tags** | [**\Swagger\Client\Model\Tag[]**](Tag.md) | | [optional] **photo_urls** | **string[]** | | [optional]
**name** | **string** | | [optional]
**id** | **int** | | **id** | **int** | |
**category** | **object** | | [optional] **category** | **object** | | [optional]
**tags** | [**\Swagger\Client\Model\Tag[]**](Tag.md) | | [optional]
**status** | **string** | pet status in the store | [optional] **status** | **string** | pet status in the store | [optional]
**name** | **string** | | [optional]
**photo_urls** | **string[]** | | [optional]
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@ -268,12 +268,12 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error cond
<?php <?php
require_once(__DIR__ . '/vendor/autoload.php'); require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN');
// Configure API key authorization: api_key // Configure API key authorization: api_key
Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY'); Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER'); // Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER');
// Configure OAuth2 access token for authorization: petstore_auth
Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN');
$api_instance = new Swagger\Client\PetApi(); $api_instance = new Swagger\Client\PetApi();
$pet_id = 789; // int | ID of pet that needs to be fetched $pet_id = 789; // int | ID of pet that needs to be fetched
@ -299,7 +299,7 @@ Name | Type | Description | Notes
### Authorization ### Authorization
[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) [petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
### HTTP reuqest headers ### HTTP reuqest headers
@ -320,12 +320,12 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error cond
<?php <?php
require_once(__DIR__ . '/vendor/autoload.php'); require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN');
// Configure API key authorization: api_key // Configure API key authorization: api_key
Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY'); Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER'); // Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER');
// Configure OAuth2 access token for authorization: petstore_auth
Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN');
$api_instance = new Swagger\Client\PetApi(); $api_instance = new Swagger\Client\PetApi();
$pet_id = 789; // int | ID of pet that needs to be fetched $pet_id = 789; // int | ID of pet that needs to be fetched
@ -351,7 +351,7 @@ Name | Type | Description | Notes
### Authorization ### Authorization
[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) [petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
### HTTP reuqest headers ### HTTP reuqest headers
@ -372,12 +372,12 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error cond
<?php <?php
require_once(__DIR__ . '/vendor/autoload.php'); require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN');
// Configure API key authorization: api_key // Configure API key authorization: api_key
Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY'); Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER'); // Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER');
// Configure OAuth2 access token for authorization: petstore_auth
Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN');
$api_instance = new Swagger\Client\PetApi(); $api_instance = new Swagger\Client\PetApi();
$pet_id = 789; // int | ID of pet that needs to be fetched $pet_id = 789; // int | ID of pet that needs to be fetched
@ -403,7 +403,7 @@ Name | Type | Description | Notes
### Authorization ### Authorization
[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth) [petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
### HTTP reuqest headers ### HTTP reuqest headers

View File

@ -214,14 +214,14 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge
<?php <?php
require_once(__DIR__ . '/vendor/autoload.php'); require_once(__DIR__ . '/vendor/autoload.php');
// Configure API key authorization: test_api_key_header
Swagger\Client::getDefaultConfiguration->setApiKey('test_api_key_header', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('test_api_key_header', 'BEARER');
// Configure API key authorization: test_api_key_query // Configure API key authorization: test_api_key_query
Swagger\Client::getDefaultConfiguration->setApiKey('test_api_key_query', 'YOUR_API_KEY'); Swagger\Client::getDefaultConfiguration->setApiKey('test_api_key_query', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed // Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('test_api_key_query', 'BEARER'); // Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('test_api_key_query', 'BEARER');
// Configure API key authorization: test_api_key_header
Swagger\Client::getDefaultConfiguration->setApiKey('test_api_key_header', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('test_api_key_header', 'BEARER');
$api_instance = new Swagger\Client\StoreApi(); $api_instance = new Swagger\Client\StoreApi();
$order_id = "order_id_example"; // string | ID of pet that needs to be fetched $order_id = "order_id_example"; // string | ID of pet that needs to be fetched
@ -247,7 +247,7 @@ Name | Type | Description | Notes
### Authorization ### Authorization
[test_api_key_header](../README.md#test_api_key_header), [test_api_key_query](../README.md#test_api_key_query) [test_api_key_query](../README.md#test_api_key_query), [test_api_key_header](../README.md#test_api_key_header)
### HTTP reuqest headers ### HTTP reuqest headers

View File

@ -0,0 +1,52 @@
#!/bin/sh
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
#
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
git_user_id=$1
git_repo_id=$2
release_note=$3
if [ "$git_user_id" = "" ]; then
git_user_id="YOUR_GIT_USR_ID"
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
fi
if [ "$git_repo_id" = "" ]; then
git_repo_id="YOUR_GIT_REPO_ID"
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
fi
if [ "$release_note" = "" ]; then
release_note="Minor update"
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
fi
# Initialize the local directory as a Git repository
git init
# Adds the files in the local repository and stages them for commit.
git add .
# Commits the tracked changes and prepares them to be pushed to a remote repository.
git commit -m "$release_note"
# Sets the new remote
git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
fi
fi
git pull origin master
# Pushes (Forces) the changes in the local repository up to the remote repository
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
git push origin master 2>&1 | grep -v 'To https'

View File

@ -618,6 +618,11 @@ class PetApi
$httpBody = $formParams; // for HTTP post (form) $httpBody = $formParams; // for HTTP post (form)
} }
// this endpoint requires OAuth (access token)
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
}
// this endpoint requires API key authentication // this endpoint requires API key authentication
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
if (strlen($apiKey) !== 0) { if (strlen($apiKey) !== 0) {
@ -625,11 +630,6 @@ class PetApi
} }
// this endpoint requires OAuth (access token)
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
}
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
@ -725,6 +725,11 @@ class PetApi
$httpBody = $formParams; // for HTTP post (form) $httpBody = $formParams; // for HTTP post (form)
} }
// this endpoint requires OAuth (access token)
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
}
// this endpoint requires API key authentication // this endpoint requires API key authentication
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
if (strlen($apiKey) !== 0) { if (strlen($apiKey) !== 0) {
@ -732,11 +737,6 @@ class PetApi
} }
// this endpoint requires OAuth (access token)
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
}
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
@ -832,6 +832,11 @@ class PetApi
$httpBody = $formParams; // for HTTP post (form) $httpBody = $formParams; // for HTTP post (form)
} }
// this endpoint requires OAuth (access token)
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
}
// this endpoint requires API key authentication // this endpoint requires API key authentication
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
if (strlen($apiKey) !== 0) { if (strlen($apiKey) !== 0) {
@ -839,11 +844,6 @@ class PetApi
} }
// this endpoint requires OAuth (access token)
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
}
// make the API Call // make the API Call
try { try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi( list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(

View File

@ -525,16 +525,16 @@ class StoreApi
} }
// this endpoint requires API key authentication // this endpoint requires API key authentication
$apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_header'); $apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_query');
if (strlen($apiKey) !== 0) { if (strlen($apiKey) !== 0) {
$headerParams['test_api_key_header'] = $apiKey; $queryParams['test_api_key_query'] = $apiKey;
} }
// this endpoint requires API key authentication // this endpoint requires API key authentication
$apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_query'); $apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_header');
if (strlen($apiKey) !== 0) { if (strlen($apiKey) !== 0) {
$queryParams['test_api_key_query'] = $apiKey; $headerParams['test_api_key_header'] = $apiKey;
} }

View File

@ -51,12 +51,12 @@ class InlineResponse200 implements ArrayAccess
* @var string[] * @var string[]
*/ */
static $swaggerTypes = array( static $swaggerTypes = array(
'tags' => '\Swagger\Client\Model\Tag[]', 'photo_urls' => 'string[]',
'name' => 'string',
'id' => 'int', 'id' => 'int',
'category' => 'object', 'category' => 'object',
'status' => 'string', 'tags' => '\Swagger\Client\Model\Tag[]',
'name' => 'string', 'status' => 'string'
'photo_urls' => 'string[]'
); );
/** /**
@ -64,12 +64,12 @@ class InlineResponse200 implements ArrayAccess
* @var string[] * @var string[]
*/ */
static $attributeMap = array( static $attributeMap = array(
'tags' => 'tags', 'photo_urls' => 'photoUrls',
'name' => 'name',
'id' => 'id', 'id' => 'id',
'category' => 'category', 'category' => 'category',
'status' => 'status', 'tags' => 'tags',
'name' => 'name', 'status' => 'status'
'photo_urls' => 'photoUrls'
); );
/** /**
@ -77,12 +77,12 @@ class InlineResponse200 implements ArrayAccess
* @var string[] * @var string[]
*/ */
static $setters = array( static $setters = array(
'tags' => 'setTags', 'photo_urls' => 'setPhotoUrls',
'name' => 'setName',
'id' => 'setId', 'id' => 'setId',
'category' => 'setCategory', 'category' => 'setCategory',
'status' => 'setStatus', 'tags' => 'setTags',
'name' => 'setName', 'status' => 'setStatus'
'photo_urls' => 'setPhotoUrls'
); );
/** /**
@ -90,20 +90,26 @@ class InlineResponse200 implements ArrayAccess
* @var string[] * @var string[]
*/ */
static $getters = array( static $getters = array(
'tags' => 'getTags', 'photo_urls' => 'getPhotoUrls',
'name' => 'getName',
'id' => 'getId', 'id' => 'getId',
'category' => 'getCategory', 'category' => 'getCategory',
'status' => 'getStatus', 'tags' => 'getTags',
'name' => 'getName', 'status' => 'getStatus'
'photo_urls' => 'getPhotoUrls'
); );
/** /**
* $tags * $photo_urls
* @var \Swagger\Client\Model\Tag[] * @var string[]
*/ */
protected $tags; protected $photo_urls;
/**
* $name
* @var string
*/
protected $name;
/** /**
* $id * $id
@ -117,24 +123,18 @@ class InlineResponse200 implements ArrayAccess
*/ */
protected $category; protected $category;
/**
* $tags
* @var \Swagger\Client\Model\Tag[]
*/
protected $tags;
/** /**
* $status pet status in the store * $status pet status in the store
* @var string * @var string
*/ */
protected $status; protected $status;
/**
* $name
* @var string
*/
protected $name;
/**
* $photo_urls
* @var string[]
*/
protected $photo_urls;
/** /**
* Constructor * Constructor
@ -143,33 +143,54 @@ class InlineResponse200 implements ArrayAccess
public function __construct(array $data = null) public function __construct(array $data = null)
{ {
if ($data != null) { if ($data != null) {
$this->tags = $data["tags"]; $this->photo_urls = $data["photo_urls"];
$this->name = $data["name"];
$this->id = $data["id"]; $this->id = $data["id"];
$this->category = $data["category"]; $this->category = $data["category"];
$this->tags = $data["tags"];
$this->status = $data["status"]; $this->status = $data["status"];
$this->name = $data["name"];
$this->photo_urls = $data["photo_urls"];
} }
} }
/** /**
* Gets tags * Gets photo_urls
* @return \Swagger\Client\Model\Tag[] * @return string[]
*/ */
public function getTags() public function getPhotoUrls()
{ {
return $this->tags; return $this->photo_urls;
} }
/** /**
* Sets tags * Sets photo_urls
* @param \Swagger\Client\Model\Tag[] $tags * @param string[] $photo_urls
* @return $this * @return $this
*/ */
public function setTags($tags) public function setPhotoUrls($photo_urls)
{ {
$this->tags = $tags; $this->photo_urls = $photo_urls;
return $this;
}
/**
* Gets name
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Sets name
* @param string $name
* @return $this
*/
public function setName($name)
{
$this->name = $name;
return $this; return $this;
} }
@ -215,6 +236,27 @@ class InlineResponse200 implements ArrayAccess
return $this; return $this;
} }
/**
* Gets tags
* @return \Swagger\Client\Model\Tag[]
*/
public function getTags()
{
return $this->tags;
}
/**
* Sets tags
* @param \Swagger\Client\Model\Tag[] $tags
* @return $this
*/
public function setTags($tags)
{
$this->tags = $tags;
return $this;
}
/** /**
* Gets status * Gets status
* @return string * @return string
@ -239,48 +281,6 @@ class InlineResponse200 implements ArrayAccess
return $this; return $this;
} }
/**
* Gets name
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Sets name
* @param string $name
* @return $this
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Gets photo_urls
* @return string[]
*/
public function getPhotoUrls()
{
return $this->photo_urls;
}
/**
* Sets photo_urls
* @param string[] $photo_urls
* @return $this
*/
public function setPhotoUrls($photo_urls)
{
$this->photo_urls = $photo_urls;
return $this;
}
/** /**
* Returns true if offset exists. False otherwise. * Returns true if offset exists. False otherwise.
* @param integer $offset Offset * @param integer $offset Offset

View File

@ -57,7 +57,7 @@ class ObjectSerializer
if (is_scalar($data) || null === $data) { if (is_scalar($data) || null === $data) {
$sanitized = $data; $sanitized = $data;
} elseif ($data instanceof \DateTime) { } elseif ($data instanceof \DateTime) {
$sanitized = $data->format(\DateTime::ISO8601); $sanitized = $data->format(\DateTime::ATOM);
} elseif (is_array($data)) { } elseif (is_array($data)) {
foreach ($data as $property => $value) { foreach ($data as $property => $value) {
$data[$property] = self::sanitizeForSerialization($value); $data[$property] = self::sanitizeForSerialization($value);
@ -172,7 +172,7 @@ class ObjectSerializer
public function toString($value) public function toString($value)
{ {
if ($value instanceof \DateTime) { // datetime in ISO8601 format if ($value instanceof \DateTime) { // datetime in ISO8601 format
return $value->format(\DateTime::ISO8601); return $value->format(\DateTime::ATOM);
} else { } else {
return $value; return $value;
} }
@ -256,7 +256,7 @@ class ObjectSerializer
} else { } else {
$deserialized = null; $deserialized = null;
} }
} elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) { } elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) {
settype($data, $class); settype($data, $class);
$deserialized = $data; $deserialized = $data;
} elseif ($class === '\SplFileObject') { } elseif ($class === '\SplFileObject') {