Skip to content

Commit 41619ad

Browse files
Update samples
1 parent 9a6ef47 commit 41619ad

File tree

19 files changed

+249
-151
lines changed

19 files changed

+249
-151
lines changed

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

Lines changed: 13 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SwaggerClient-php
2-
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
2+
This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
33

44
This PHP package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
55

@@ -56,40 +56,32 @@ Please follow the [installation procedure](#installation--usage) and then run th
5656
<?php
5757
require_once(__DIR__ . '/vendor/autoload.php');
5858

59-
$apiInstance = new Swagger\Client\Api\AnotherFakeApi(
59+
// Configure OAuth2 access token for authorization: petstore_auth
60+
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
61+
62+
$apiInstance = new Swagger\Client\Api\PetApi(
6063
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
6164
// This is optional, `GuzzleHttp\Client` will be used as default.
62-
new GuzzleHttp\Client()
65+
new GuzzleHttp\Client(),
66+
$config
6367
);
64-
$body = new \Swagger\Client\Model\Client(); // \Swagger\Client\Model\Client | client model
68+
$body = new \Swagger\Client\Model\Pet(); // \Swagger\Client\Model\Pet | Pet object that needs to be added to the store
6569

6670
try {
67-
$result = $apiInstance->testSpecialTags($body);
68-
print_r($result);
71+
$apiInstance->addPet($body);
6972
} catch (Exception $e) {
70-
echo 'Exception when calling AnotherFakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL;
73+
echo 'Exception when calling PetApi->addPet: ', $e->getMessage(), PHP_EOL;
7174
}
7275

7376
?>
7477
```
7578

7679
## Documentation for API Endpoints
7780

78-
All URIs are relative to *http://petstore.swagger.io:80/v2*
81+
All URIs are relative to *http://petstore.swagger.io/v2*
7982

8083
Class | Method | HTTP request | Description
8184
------------ | ------------- | ------------- | -------------
82-
*AnotherFakeApi* | [**testSpecialTags**](docs/Api/AnotherFakeApi.md#testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
83-
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/Api/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
84-
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/Api/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite |
85-
*FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number |
86-
*FakeApi* | [**fakeOuterStringSerialize**](docs/Api/FakeApi.md#fakeouterstringserialize) | **POST** /fake/outer/string |
87-
*FakeApi* | [**testClientModel**](docs/Api/FakeApi.md#testclientmodel) | **PATCH** /fake | To test \&quot;client\&quot; model
88-
*FakeApi* | [**testEndpointParameters**](docs/Api/FakeApi.md#testendpointparameters) | **POST** /fake | Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
89-
*FakeApi* | [**testEnumParameters**](docs/Api/FakeApi.md#testenumparameters) | **GET** /fake | To test enum parameters
90-
*FakeApi* | [**testInlineAdditionalProperties**](docs/Api/FakeApi.md#testinlineadditionalproperties) | **POST** /fake/inline-additionalProperties | test inline additionalProperties
91-
*FakeApi* | [**testJsonFormData**](docs/Api/FakeApi.md#testjsonformdata) | **GET** /fake/jsonFormData | test json serialization of form data
92-
*FakeClassnameTags123Api* | [**testClassname**](docs/Api/FakeClassnameTags123Api.md#testclassname) | **PATCH** /fake_classname_test | To test class name in snake case
9385
*PetApi* | [**addPet**](docs/Api/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
9486
*PetApi* | [**deletePet**](docs/Api/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
9587
*PetApi* | [**findPetsByStatus**](docs/Api/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
@@ -98,9 +90,9 @@ Class | Method | HTTP request | Description
9890
*PetApi* | [**updatePet**](docs/Api/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet
9991
*PetApi* | [**updatePetWithForm**](docs/Api/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
10092
*PetApi* | [**uploadFile**](docs/Api/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
101-
*StoreApi* | [**deleteOrder**](docs/Api/StoreApi.md#deleteorder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
93+
*StoreApi* | [**deleteOrder**](docs/Api/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
10294
*StoreApi* | [**getInventory**](docs/Api/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
103-
*StoreApi* | [**getOrderById**](docs/Api/StoreApi.md#getorderbyid) | **GET** /store/order/{order_id} | Find purchase order by ID
95+
*StoreApi* | [**getOrderById**](docs/Api/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID
10496
*StoreApi* | [**placeOrder**](docs/Api/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet
10597
*UserApi* | [**createUser**](docs/Api/UserApi.md#createuser) | **POST** /user | Create user
10698
*UserApi* | [**createUsersWithArrayInput**](docs/Api/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array
@@ -114,42 +106,12 @@ Class | Method | HTTP request | Description
114106

115107
## Documentation For Models
116108

117-
- [AdditionalPropertiesClass](docs/Model/AdditionalPropertiesClass.md)
118-
- [Animal](docs/Model/Animal.md)
119-
- [AnimalFarm](docs/Model/AnimalFarm.md)
120109
- [ApiResponse](docs/Model/ApiResponse.md)
121-
- [ArrayOfArrayOfNumberOnly](docs/Model/ArrayOfArrayOfNumberOnly.md)
122-
- [ArrayOfNumberOnly](docs/Model/ArrayOfNumberOnly.md)
123-
- [ArrayTest](docs/Model/ArrayTest.md)
124-
- [Capitalization](docs/Model/Capitalization.md)
125110
- [Category](docs/Model/Category.md)
126-
- [ClassModel](docs/Model/ClassModel.md)
127-
- [Client](docs/Model/Client.md)
128-
- [EnumArrays](docs/Model/EnumArrays.md)
129-
- [EnumClass](docs/Model/EnumClass.md)
130-
- [EnumTest](docs/Model/EnumTest.md)
131-
- [FormatTest](docs/Model/FormatTest.md)
132-
- [HasOnlyReadOnly](docs/Model/HasOnlyReadOnly.md)
133-
- [MapTest](docs/Model/MapTest.md)
134-
- [MixedPropertiesAndAdditionalPropertiesClass](docs/Model/MixedPropertiesAndAdditionalPropertiesClass.md)
135-
- [Model200Response](docs/Model/Model200Response.md)
136-
- [ModelList](docs/Model/ModelList.md)
137-
- [ModelReturn](docs/Model/ModelReturn.md)
138-
- [Name](docs/Model/Name.md)
139-
- [NumberOnly](docs/Model/NumberOnly.md)
140111
- [Order](docs/Model/Order.md)
141-
- [OuterBoolean](docs/Model/OuterBoolean.md)
142-
- [OuterComposite](docs/Model/OuterComposite.md)
143-
- [OuterEnum](docs/Model/OuterEnum.md)
144-
- [OuterNumber](docs/Model/OuterNumber.md)
145-
- [OuterString](docs/Model/OuterString.md)
146112
- [Pet](docs/Model/Pet.md)
147-
- [ReadOnlyFirst](docs/Model/ReadOnlyFirst.md)
148-
- [SpecialModelName](docs/Model/SpecialModelName.md)
149113
- [Tag](docs/Model/Tag.md)
150114
- [User](docs/Model/User.md)
151-
- [Cat](docs/Model/Cat.md)
152-
- [Dog](docs/Model/Dog.md)
153115

154116

155117
## Documentation For Authorization
@@ -161,16 +123,6 @@ Class | Method | HTTP request | Description
161123
- **API key parameter name**: api_key
162124
- **Location**: HTTP header
163125

164-
## api_key_query
165-
166-
- **Type**: API key
167-
- **API key parameter name**: api_key_query
168-
- **Location**: URL query string
169-
170-
## http_basic_test
171-
172-
- **Type**: HTTP basic authentication
173-
174126
## petstore_auth
175127

176128
- **Type**: OAuth

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Swagger\Client\PetApi
22

3-
All URIs are relative to *http://petstore.swagger.io:80/v2*
3+
All URIs are relative to *http://petstore.swagger.io/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Swagger\Client\StoreApi
22

3-
All URIs are relative to *http://petstore.swagger.io:80/v2*
3+
All URIs are relative to *http://petstore.swagger.io/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7-
[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{order_id} | Delete purchase order by ID
7+
[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
88
[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status
9-
[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{order_id} | Find purchase order by ID
9+
[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID
1010
[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet
1111

1212

samples/client/petstore/php/SwaggerClient-php/docs/Api/UserApi.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Swagger\Client\UserApi
22

3-
All URIs are relative to *http://petstore.swagger.io:80/v2*
3+
All URIs are relative to *http://petstore.swagger.io/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------

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

Lines changed: 85 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
/**
1313
* Swagger Petstore
1414
*
15-
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
15+
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
1616
*
1717
* OpenAPI spec version: 1.0.0
1818
* Contact: [email protected]
@@ -261,9 +261,16 @@ protected function addPetRequest($body)
261261
if (isset($_tempBody)) {
262262
// $_tempBody is the method argument, if present
263263
$httpBody = $_tempBody;
264-
// \stdClass has no __toString(), so we should encode it manually
265-
if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
266-
$httpBody = \GuzzleHttp\json_encode($httpBody);
264+
265+
if($headers['Content-Type'] === 'application/json') {
266+
// \stdClass has no __toString(), so we should encode it manually
267+
if ($httpBody instanceof \stdClass) {
268+
$httpBody = \GuzzleHttp\json_encode($httpBody);
269+
}
270+
// array has no __toString(), so we should encode it manually
271+
if(is_array($httpBody)) {
272+
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
273+
}
267274
}
268275
} elseif (count($formParams) > 0) {
269276
if ($multipart) {
@@ -499,9 +506,16 @@ protected function deletePetRequest($pet_id, $api_key = null)
499506
if (isset($_tempBody)) {
500507
// $_tempBody is the method argument, if present
501508
$httpBody = $_tempBody;
502-
// \stdClass has no __toString(), so we should encode it manually
503-
if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
504-
$httpBody = \GuzzleHttp\json_encode($httpBody);
509+
510+
if($headers['Content-Type'] === 'application/json') {
511+
// \stdClass has no __toString(), so we should encode it manually
512+
if ($httpBody instanceof \stdClass) {
513+
$httpBody = \GuzzleHttp\json_encode($httpBody);
514+
}
515+
// array has no __toString(), so we should encode it manually
516+
if(is_array($httpBody)) {
517+
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
518+
}
505519
}
506520
} elseif (count($formParams) > 0) {
507521
if ($multipart) {
@@ -739,8 +753,8 @@ protected function findPetsByStatusRequest($status)
739753

740754
// query params
741755
if (is_array($status)) {
742-
$status = ObjectSerializer::serializeCollection($status, 'csv', true);
743-
}
756+
$queryParams['status'] = $status;
757+
} else
744758
if ($status !== null) {
745759
$queryParams['status'] = ObjectSerializer::toQueryValue($status);
746760
}
@@ -764,9 +778,16 @@ protected function findPetsByStatusRequest($status)
764778
if (isset($_tempBody)) {
765779
// $_tempBody is the method argument, if present
766780
$httpBody = $_tempBody;
767-
// \stdClass has no __toString(), so we should encode it manually
768-
if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
769-
$httpBody = \GuzzleHttp\json_encode($httpBody);
781+
782+
if($headers['Content-Type'] === 'application/json') {
783+
// \stdClass has no __toString(), so we should encode it manually
784+
if ($httpBody instanceof \stdClass) {
785+
$httpBody = \GuzzleHttp\json_encode($httpBody);
786+
}
787+
// array has no __toString(), so we should encode it manually
788+
if(is_array($httpBody)) {
789+
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
790+
}
770791
}
771792
} elseif (count($formParams) > 0) {
772793
if ($multipart) {
@@ -1004,8 +1025,8 @@ protected function findPetsByTagsRequest($tags)
10041025

10051026
// query params
10061027
if (is_array($tags)) {
1007-
$tags = ObjectSerializer::serializeCollection($tags, 'csv', true);
1008-
}
1028+
$queryParams['tags'] = $tags;
1029+
} else
10091030
if ($tags !== null) {
10101031
$queryParams['tags'] = ObjectSerializer::toQueryValue($tags);
10111032
}
@@ -1029,9 +1050,16 @@ protected function findPetsByTagsRequest($tags)
10291050
if (isset($_tempBody)) {
10301051
// $_tempBody is the method argument, if present
10311052
$httpBody = $_tempBody;
1032-
// \stdClass has no __toString(), so we should encode it manually
1033-
if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
1034-
$httpBody = \GuzzleHttp\json_encode($httpBody);
1053+
1054+
if($headers['Content-Type'] === 'application/json') {
1055+
// \stdClass has no __toString(), so we should encode it manually
1056+
if ($httpBody instanceof \stdClass) {
1057+
$httpBody = \GuzzleHttp\json_encode($httpBody);
1058+
}
1059+
// array has no __toString(), so we should encode it manually
1060+
if(is_array($httpBody)) {
1061+
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
1062+
}
10351063
}
10361064
} elseif (count($formParams) > 0) {
10371065
if ($multipart) {
@@ -1295,9 +1323,16 @@ protected function getPetByIdRequest($pet_id)
12951323
if (isset($_tempBody)) {
12961324
// $_tempBody is the method argument, if present
12971325
$httpBody = $_tempBody;
1298-
// \stdClass has no __toString(), so we should encode it manually
1299-
if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
1300-
$httpBody = \GuzzleHttp\json_encode($httpBody);
1326+
1327+
if($headers['Content-Type'] === 'application/json') {
1328+
// \stdClass has no __toString(), so we should encode it manually
1329+
if ($httpBody instanceof \stdClass) {
1330+
$httpBody = \GuzzleHttp\json_encode($httpBody);
1331+
}
1332+
// array has no __toString(), so we should encode it manually
1333+
if(is_array($httpBody)) {
1334+
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
1335+
}
13011336
}
13021337
} elseif (count($formParams) > 0) {
13031338
if ($multipart) {
@@ -1520,9 +1555,16 @@ protected function updatePetRequest($body)
15201555
if (isset($_tempBody)) {
15211556
// $_tempBody is the method argument, if present
15221557
$httpBody = $_tempBody;
1523-
// \stdClass has no __toString(), so we should encode it manually
1524-
if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
1525-
$httpBody = \GuzzleHttp\json_encode($httpBody);
1558+
1559+
if($headers['Content-Type'] === 'application/json') {
1560+
// \stdClass has no __toString(), so we should encode it manually
1561+
if ($httpBody instanceof \stdClass) {
1562+
$httpBody = \GuzzleHttp\json_encode($httpBody);
1563+
}
1564+
// array has no __toString(), so we should encode it manually
1565+
if(is_array($httpBody)) {
1566+
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
1567+
}
15261568
}
15271569
} elseif (count($formParams) > 0) {
15281570
if ($multipart) {
@@ -1767,9 +1809,16 @@ protected function updatePetWithFormRequest($pet_id, $name = null, $status = nul
17671809
if (isset($_tempBody)) {
17681810
// $_tempBody is the method argument, if present
17691811
$httpBody = $_tempBody;
1770-
// \stdClass has no __toString(), so we should encode it manually
1771-
if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
1772-
$httpBody = \GuzzleHttp\json_encode($httpBody);
1812+
1813+
if($headers['Content-Type'] === 'application/json') {
1814+
// \stdClass has no __toString(), so we should encode it manually
1815+
if ($httpBody instanceof \stdClass) {
1816+
$httpBody = \GuzzleHttp\json_encode($httpBody);
1817+
}
1818+
// array has no __toString(), so we should encode it manually
1819+
if(is_array($httpBody)) {
1820+
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
1821+
}
17731822
}
17741823
} elseif (count($formParams) > 0) {
17751824
if ($multipart) {
@@ -2052,9 +2101,16 @@ protected function uploadFileRequest($pet_id, $additional_metadata = null, $file
20522101
if (isset($_tempBody)) {
20532102
// $_tempBody is the method argument, if present
20542103
$httpBody = $_tempBody;
2055-
// \stdClass has no __toString(), so we should encode it manually
2056-
if ($httpBody instanceof \stdClass && $headers['Content-Type'] === 'application/json') {
2057-
$httpBody = \GuzzleHttp\json_encode($httpBody);
2104+
2105+
if($headers['Content-Type'] === 'application/json') {
2106+
// \stdClass has no __toString(), so we should encode it manually
2107+
if ($httpBody instanceof \stdClass) {
2108+
$httpBody = \GuzzleHttp\json_encode($httpBody);
2109+
}
2110+
// array has no __toString(), so we should encode it manually
2111+
if(is_array($httpBody)) {
2112+
$httpBody = \GuzzleHttp\json_encode(ObjectSerializer::sanitizeForSerialization($httpBody));
2113+
}
20582114
}
20592115
} elseif (count($formParams) > 0) {
20602116
if ($multipart) {

0 commit comments

Comments
 (0)