Skip to content

Commit 4d19da4

Browse files
committed
Merge pull request #2385 from arnested/php_date_time_iso8601_vs_atom
Use PHP's DateTime::ATOM for true ISO-8601 support
2 parents a019e13 + 55ef72d commit 4d19da4

File tree

10 files changed

+194
-142
lines changed

10 files changed

+194
-142
lines changed

modules/swagger-codegen/src/main/resources/php/ObjectSerializer.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class ObjectSerializer
5757
if (is_scalar($data) || null === $data) {
5858
$sanitized = $data;
5959
} elseif ($data instanceof \DateTime) {
60-
$sanitized = $data->format(\DateTime::ISO8601);
60+
$sanitized = $data->format(\DateTime::ATOM);
6161
} elseif (is_array($data)) {
6262
foreach ($data as $property => $value) {
6363
$data[$property] = self::sanitizeForSerialization($value);
@@ -172,7 +172,7 @@ class ObjectSerializer
172172
public function toString($value)
173173
{
174174
if ($value instanceof \DateTime) { // datetime in ISO8601 format
175-
return $value->format(\DateTime::ISO8601);
175+
return $value->format(\DateTime::ATOM);
176176
} else {
177177
return $value;
178178
}

samples/client/petstore/php/SwaggerClient-php/README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -89,48 +89,48 @@ Class | Method | HTTP request | Description
8989
## Documentation For Authorization
9090

9191

92-
## test_api_key_header
92+
## petstore_auth
9393

94-
- **Type**: API key
95-
- **API key parameter name**: test_api_key_header
96-
- **Location**: HTTP header
94+
- **Type**: OAuth
95+
- **Flow**: implicit
96+
- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog
97+
- **Scopes**:
98+
- **write:pets**: modify pets in your account
99+
- **read:pets**: read your pets
97100

98-
## api_key
101+
## test_api_client_id
99102

100103
- **Type**: API key
101-
- **API key parameter name**: api_key
104+
- **API key parameter name**: x-test_api_client_id
102105
- **Location**: HTTP header
103106

104-
## test_http_basic
105-
106-
- **Type**: HTTP basic authentication
107-
108107
## test_api_client_secret
109108

110109
- **Type**: API key
111110
- **API key parameter name**: x-test_api_client_secret
112111
- **Location**: HTTP header
113112

114-
## test_api_client_id
113+
## api_key
115114

116115
- **Type**: API key
117-
- **API key parameter name**: x-test_api_client_id
116+
- **API key parameter name**: api_key
118117
- **Location**: HTTP header
119118

119+
## test_http_basic
120+
121+
- **Type**: HTTP basic authentication
122+
120123
## test_api_key_query
121124

122125
- **Type**: API key
123126
- **API key parameter name**: test_api_key_query
124127
- **Location**: URL query string
125128

126-
## petstore_auth
129+
## test_api_key_header
127130

128-
- **Type**: OAuth
129-
- **Flow**: implicit
130-
- **Authorizatoin URL**: http://petstore.swagger.io/api/oauth/dialog
131-
- **Scopes**:
132-
- **write:pets**: modify pets in your account
133-
- **read:pets**: read your pets
131+
- **Type**: API key
132+
- **API key parameter name**: test_api_key_header
133+
- **Location**: HTTP header
134134

135135

136136
## Author

samples/client/petstore/php/SwaggerClient-php/docs/InlineResponse200.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
## Properties
44
Name | Type | Description | Notes
55
------------ | ------------- | ------------- | -------------
6-
**tags** | [**\Swagger\Client\Model\Tag[]**](Tag.md) | | [optional]
6+
**photo_urls** | **string[]** | | [optional]
7+
**name** | **string** | | [optional]
78
**id** | **int** | |
89
**category** | **object** | | [optional]
10+
**tags** | [**\Swagger\Client\Model\Tag[]**](Tag.md) | | [optional]
911
**status** | **string** | pet status in the store | [optional]
10-
**name** | **string** | | [optional]
11-
**photo_urls** | **string[]** | | [optional]
1212

1313
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
1414

samples/client/petstore/php/SwaggerClient-php/docs/PetApi.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,12 +268,12 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error cond
268268
<?php
269269
require_once(__DIR__ . '/vendor/autoload.php');
270270

271+
// Configure OAuth2 access token for authorization: petstore_auth
272+
Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN');
271273
// Configure API key authorization: api_key
272274
Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY');
273275
// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
274276
// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER');
275-
// Configure OAuth2 access token for authorization: petstore_auth
276-
Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN');
277277

278278
$api_instance = new Swagger\Client\PetApi();
279279
$pet_id = 789; // int | ID of pet that needs to be fetched
@@ -299,7 +299,7 @@ Name | Type | Description | Notes
299299

300300
### Authorization
301301

302-
[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
302+
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
303303

304304
### HTTP reuqest headers
305305

@@ -320,12 +320,12 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error cond
320320
<?php
321321
require_once(__DIR__ . '/vendor/autoload.php');
322322

323+
// Configure OAuth2 access token for authorization: petstore_auth
324+
Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN');
323325
// Configure API key authorization: api_key
324326
Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY');
325327
// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
326328
// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER');
327-
// Configure OAuth2 access token for authorization: petstore_auth
328-
Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN');
329329

330330
$api_instance = new Swagger\Client\PetApi();
331331
$pet_id = 789; // int | ID of pet that needs to be fetched
@@ -351,7 +351,7 @@ Name | Type | Description | Notes
351351

352352
### Authorization
353353

354-
[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
354+
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
355355

356356
### HTTP reuqest headers
357357

@@ -372,12 +372,12 @@ Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error cond
372372
<?php
373373
require_once(__DIR__ . '/vendor/autoload.php');
374374

375+
// Configure OAuth2 access token for authorization: petstore_auth
376+
Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN');
375377
// Configure API key authorization: api_key
376378
Swagger\Client::getDefaultConfiguration->setApiKey('api_key', 'YOUR_API_KEY');
377379
// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
378380
// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('api_key', 'BEARER');
379-
// Configure OAuth2 access token for authorization: petstore_auth
380-
Swagger\Client::getDefaultConfiguration->setAccessToken('YOUR_ACCESS_TOKEN');
381381

382382
$api_instance = new Swagger\Client\PetApi();
383383
$pet_id = 789; // int | ID of pet that needs to be fetched
@@ -403,7 +403,7 @@ Name | Type | Description | Notes
403403

404404
### Authorization
405405

406-
[api_key](../README.md#api_key), [petstore_auth](../README.md#petstore_auth)
406+
[petstore_auth](../README.md#petstore_auth), [api_key](../README.md#api_key)
407407

408408
### HTTP reuqest headers
409409

samples/client/petstore/php/SwaggerClient-php/docs/StoreApi.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -214,14 +214,14 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge
214214
<?php
215215
require_once(__DIR__ . '/vendor/autoload.php');
216216

217-
// Configure API key authorization: test_api_key_header
218-
Swagger\Client::getDefaultConfiguration->setApiKey('test_api_key_header', 'YOUR_API_KEY');
219-
// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
220-
// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('test_api_key_header', 'BEARER');
221217
// Configure API key authorization: test_api_key_query
222218
Swagger\Client::getDefaultConfiguration->setApiKey('test_api_key_query', 'YOUR_API_KEY');
223219
// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
224220
// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('test_api_key_query', 'BEARER');
221+
// Configure API key authorization: test_api_key_header
222+
Swagger\Client::getDefaultConfiguration->setApiKey('test_api_key_header', 'YOUR_API_KEY');
223+
// Uncomment below to setup prefix (e.g. BEARER) for API key, if needed
224+
// Swagger\Client::getDefaultConfiguration->setApiKeyPrefix('test_api_key_header', 'BEARER');
225225

226226
$api_instance = new Swagger\Client\StoreApi();
227227
$order_id = "order_id_example"; // string | ID of pet that needs to be fetched
@@ -247,7 +247,7 @@ Name | Type | Description | Notes
247247

248248
### Authorization
249249

250-
[test_api_key_header](../README.md#test_api_key_header), [test_api_key_query](../README.md#test_api_key_query)
250+
[test_api_key_query](../README.md#test_api_key_query), [test_api_key_header](../README.md#test_api_key_header)
251251

252252
### HTTP reuqest headers
253253

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/sh
2+
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
3+
#
4+
# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update"
5+
6+
git_user_id=$1
7+
git_repo_id=$2
8+
release_note=$3
9+
10+
if [ "$git_user_id" = "" ]; then
11+
git_user_id="YOUR_GIT_USR_ID"
12+
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
13+
fi
14+
15+
if [ "$git_repo_id" = "" ]; then
16+
git_repo_id="YOUR_GIT_REPO_ID"
17+
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
18+
fi
19+
20+
if [ "$release_note" = "" ]; then
21+
release_note="Minor update"
22+
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
23+
fi
24+
25+
# Initialize the local directory as a Git repository
26+
git init
27+
28+
# Adds the files in the local repository and stages them for commit.
29+
git add .
30+
31+
# Commits the tracked changes and prepares them to be pushed to a remote repository.
32+
git commit -m "$release_note"
33+
34+
# Sets the new remote
35+
git_remote=`git remote`
36+
if [ "$git_remote" = "" ]; then # git remote not defined
37+
38+
if [ "$GIT_TOKEN" = "" ]; then
39+
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
40+
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
41+
else
42+
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git
43+
fi
44+
45+
fi
46+
47+
git pull origin master
48+
49+
# Pushes (Forces) the changes in the local repository up to the remote repository
50+
echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git"
51+
git push origin master 2>&1 | grep -v 'To https'
52+

samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -618,18 +618,18 @@ public function getPetByIdWithHttpInfo($pet_id)
618618
$httpBody = $formParams; // for HTTP post (form)
619619
}
620620

621+
// this endpoint requires OAuth (access token)
622+
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
623+
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
624+
}
625+
621626
// this endpoint requires API key authentication
622627
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
623628
if (strlen($apiKey) !== 0) {
624629
$headerParams['api_key'] = $apiKey;
625630
}
626631

627632

628-
// this endpoint requires OAuth (access token)
629-
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
630-
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
631-
}
632-
633633
// make the API Call
634634
try {
635635
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
@@ -725,18 +725,18 @@ public function getPetByIdInObjectWithHttpInfo($pet_id)
725725
$httpBody = $formParams; // for HTTP post (form)
726726
}
727727

728+
// this endpoint requires OAuth (access token)
729+
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
730+
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
731+
}
732+
728733
// this endpoint requires API key authentication
729734
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
730735
if (strlen($apiKey) !== 0) {
731736
$headerParams['api_key'] = $apiKey;
732737
}
733738

734739

735-
// this endpoint requires OAuth (access token)
736-
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
737-
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
738-
}
739-
740740
// make the API Call
741741
try {
742742
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(
@@ -832,18 +832,18 @@ public function petPetIdtestingByteArraytrueGetWithHttpInfo($pet_id)
832832
$httpBody = $formParams; // for HTTP post (form)
833833
}
834834

835+
// this endpoint requires OAuth (access token)
836+
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
837+
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
838+
}
839+
835840
// this endpoint requires API key authentication
836841
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
837842
if (strlen($apiKey) !== 0) {
838843
$headerParams['api_key'] = $apiKey;
839844
}
840845

841846

842-
// this endpoint requires OAuth (access token)
843-
if (strlen($this->apiClient->getConfig()->getAccessToken()) !== 0) {
844-
$headerParams['Authorization'] = 'Bearer ' . $this->apiClient->getConfig()->getAccessToken();
845-
}
846-
847847
// make the API Call
848848
try {
849849
list($response, $statusCode, $httpHeader) = $this->apiClient->callApi(

samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -525,16 +525,16 @@ public function getOrderByIdWithHttpInfo($order_id)
525525
}
526526

527527
// this endpoint requires API key authentication
528-
$apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_header');
528+
$apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_query');
529529
if (strlen($apiKey) !== 0) {
530-
$headerParams['test_api_key_header'] = $apiKey;
530+
$queryParams['test_api_key_query'] = $apiKey;
531531
}
532532

533533

534534
// this endpoint requires API key authentication
535-
$apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_query');
535+
$apiKey = $this->apiClient->getApiKeyWithPrefix('test_api_key_header');
536536
if (strlen($apiKey) !== 0) {
537-
$queryParams['test_api_key_query'] = $apiKey;
537+
$headerParams['test_api_key_header'] = $apiKey;
538538
}
539539

540540

0 commit comments

Comments
 (0)