Skip to content

Use PHP's DateTime::ATOM for true ISO-8601 support #2385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ObjectSerializer
if (is_scalar($data) || null === $data) {
$sanitized = $data;
} elseif ($data instanceof \DateTime) {
$sanitized = $data->format(\DateTime::ISO8601);
$sanitized = $data->format(\DateTime::ATOM);
} elseif (is_array($data)) {
foreach ($data as $property => $value) {
$data[$property] = self::sanitizeForSerialization($value);
Expand Down Expand Up @@ -172,7 +172,7 @@ class ObjectSerializer
public function toString($value)
{
if ($value instanceof \DateTime) { // datetime in ISO8601 format
return $value->format(\DateTime::ISO8601);
return $value->format(\DateTime::ATOM);
} else {
return $value;
}
Expand Down
38 changes: 19 additions & 19 deletions samples/client/petstore/php/SwaggerClient-php/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,48 +89,48 @@ Class | Method | HTTP request | Description
## Documentation For Authorization


## test_api_key_header
## petstore_auth

- **Type**: API key
- **API key parameter name**: test_api_key_header
- **Location**: HTTP header
- **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

## api_key
## test_api_client_id

- **Type**: API key
- **API key parameter name**: api_key
- **API key parameter name**: x-test_api_client_id
- **Location**: HTTP header

## test_http_basic

- **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
## api_key

- **Type**: API key
- **API key parameter name**: x-test_api_client_id
- **API key parameter name**: api_key
- **Location**: HTTP header

## test_http_basic

- **Type**: HTTP basic authentication

## test_api_key_query

- **Type**: API key
- **API key parameter name**: test_api_key_query
- **Location**: URL query string

## petstore_auth
## test_api_key_header

- **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
- **Type**: API key
- **API key parameter name**: test_api_key_header
- **Location**: HTTP header


## Author
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**tags** | [**\Swagger\Client\Model\Tag[]**](Tag.md) | | [optional]
**photo_urls** | **string[]** | | [optional]
**name** | **string** | | [optional]
**id** | **int** | |
**category** | **object** | | [optional]
**tags** | [**\Swagger\Client\Model\Tag[]**](Tag.md) | | [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)

Expand Down
18 changes: 9 additions & 9 deletions samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,12 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error cond
<?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
Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
// 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();
$pet_id = 789; // int | ID of pet that needs to be fetched
Expand All @@ -299,7 +299,7 @@ Name | Type | Description | Notes

### 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

Expand All @@ -320,12 +320,12 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error cond
<?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
Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
// 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();
$pet_id = 789; // int | ID of pet that needs to be fetched
Expand All @@ -351,7 +351,7 @@ Name | Type | Description | Notes

### 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

Expand All @@ -372,12 +372,12 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error cond
<?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
Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
// 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();
$pet_id = 789; // int | ID of pet that needs to be fetched
Expand All @@ -403,7 +403,7 @@ Name | Type | Description | Notes

### 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

Expand Down
10 changes: 5 additions & 5 deletions samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge
<?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
Swagger\Client::getDefaultConfiguration->setApiKey('test_api_key_query', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
// 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();
$order_id = "order_id_example"; // string | ID of pet that needs to be fetched
Expand All @@ -247,7 +247,7 @@ Name | Type | Description | Notes

### 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

Expand Down
52 changes: 52 additions & 0 deletions samples/client/petstore/php/SwaggerClient-php/git_push.sh
Original file line number Diff line number Diff line change
@@ -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'

30 changes: 15 additions & 15 deletions samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -618,18 +618,18 @@ public function getPetByIdWithHttpInfo($pet_id)
$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
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
if (strlen($apiKey) !== 0) {
$headerParams['api_key'] = $apiKey;
}


// this endpoint requires OAuth (access token)
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
}

// make the API Call
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
Expand Down Expand Up @@ -725,18 +725,18 @@ public function getPetByIdInObjectWithHttpInfo($pet_id)
$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
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
if (strlen($apiKey) !== 0) {
$headerParams['api_key'] = $apiKey;
}


// this endpoint requires OAuth (access token)
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
}

// make the API Call
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
Expand Down Expand Up @@ -832,18 +832,18 @@ public function petPetIdtestingByteArraytrueGetWithHttpInfo($pet_id)
$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
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
if (strlen($apiKey) !== 0) {
$headerParams['api_key'] = $apiKey;
}


// this endpoint requires OAuth (access token)
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
}

// make the API Call
try {
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,16 +525,16 @@ public function getOrderByIdWithHttpInfo($order_id)
}

// 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) {
$headerParams['test_api_key_header'] = $apiKey;
$queryParams['test_api_key_query'] = $apiKey;
}


// 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) {
$queryParams['test_api_key_query'] = $apiKey;
$headerParams['test_api_key_header'] = $apiKey;
}


Expand Down
Loading