forked from loafle/openapi-generator-original
[PHP] Improve docs and README (#6935)
* Fix wrong client class, add details about client * Improve example for Configuration * camelcase * Improve README like api doc * Update samples
This commit is contained in:
committed by
William Cheng
parent
62444a7aaf
commit
9ca9887de4
@@ -19,11 +19,15 @@ To test special tags
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\AnotherFakeApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\AnotherFakeApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$body = new \Swagger\Client\Model\Client(); // \Swagger\Client\Model\Client | client model
|
||||
|
||||
try {
|
||||
$result = $api_instance->testSpecialTags($body);
|
||||
$result = $apiInstance->testSpecialTags($body);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling AnotherFakeApi->testSpecialTags: ', $e->getMessage(), PHP_EOL;
|
||||
|
||||
@@ -27,11 +27,15 @@ Test serialization of outer boolean types
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\FakeApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\FakeApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$body = new \Swagger\Client\Model\OuterBoolean(); // \Swagger\Client\Model\OuterBoolean | Input boolean as post body
|
||||
|
||||
try {
|
||||
$result = $api_instance->fakeOuterBooleanSerialize($body);
|
||||
$result = $apiInstance->fakeOuterBooleanSerialize($body);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling FakeApi->fakeOuterBooleanSerialize: ', $e->getMessage(), PHP_EOL;
|
||||
@@ -72,11 +76,15 @@ Test serialization of object with outer number type
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\FakeApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\FakeApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$body = new \Swagger\Client\Model\OuterComposite(); // \Swagger\Client\Model\OuterComposite | Input composite as post body
|
||||
|
||||
try {
|
||||
$result = $api_instance->fakeOuterCompositeSerialize($body);
|
||||
$result = $apiInstance->fakeOuterCompositeSerialize($body);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling FakeApi->fakeOuterCompositeSerialize: ', $e->getMessage(), PHP_EOL;
|
||||
@@ -117,11 +125,15 @@ Test serialization of outer number types
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\FakeApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\FakeApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$body = new \Swagger\Client\Model\OuterNumber(); // \Swagger\Client\Model\OuterNumber | Input number as post body
|
||||
|
||||
try {
|
||||
$result = $api_instance->fakeOuterNumberSerialize($body);
|
||||
$result = $apiInstance->fakeOuterNumberSerialize($body);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling FakeApi->fakeOuterNumberSerialize: ', $e->getMessage(), PHP_EOL;
|
||||
@@ -162,11 +174,15 @@ Test serialization of outer string types
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\FakeApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\FakeApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$body = new \Swagger\Client\Model\OuterString(); // \Swagger\Client\Model\OuterString | Input string as post body
|
||||
|
||||
try {
|
||||
$result = $api_instance->fakeOuterStringSerialize($body);
|
||||
$result = $apiInstance->fakeOuterStringSerialize($body);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling FakeApi->fakeOuterStringSerialize: ', $e->getMessage(), PHP_EOL;
|
||||
@@ -207,11 +223,15 @@ To test \"client\" model
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\FakeApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\FakeApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$body = new \Swagger\Client\Model\Client(); // \Swagger\Client\Model\Client | client model
|
||||
|
||||
try {
|
||||
$result = $api_instance->testClientModel($body);
|
||||
$result = $apiInstance->testClientModel($body);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling FakeApi->testClientModel: ', $e->getMessage(), PHP_EOL;
|
||||
@@ -253,10 +273,17 @@ Fake endpoint for testing various parameters 假端點 偽のエンドポイン
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
// Configure HTTP basic authorization: http_basic_test
|
||||
Swagger\Client\Configuration::getDefaultConfiguration()->setUsername('YOUR_USERNAME');
|
||||
Swagger\Client\Configuration::getDefaultConfiguration()->setPassword('YOUR_PASSWORD');
|
||||
$config = Swagger\Client\Configuration::getDefaultConfiguration()
|
||||
->setUsername('YOUR_USERNAME')
|
||||
->setPassword('YOUR_PASSWORD');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\FakeApi(new \Http\Adapter\Guzzle6\Client());
|
||||
|
||||
$apiInstance = new Swagger\Client\Api\FakeApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$number = 8.14; // float | None
|
||||
$double = 1.2; // double | None
|
||||
$pattern_without_delimiter = "pattern_without_delimiter_example"; // string | None
|
||||
@@ -273,7 +300,7 @@ $password = "password_example"; // string | None
|
||||
$callback = "callback_example"; // string | None
|
||||
|
||||
try {
|
||||
$api_instance->testEndpointParameters($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback);
|
||||
$apiInstance->testEndpointParameters($number, $double, $pattern_without_delimiter, $byte, $integer, $int32, $int64, $float, $string, $binary, $date, $date_time, $password, $callback);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling FakeApi->testEndpointParameters: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
@@ -326,7 +353,11 @@ To test enum parameters
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\FakeApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\FakeApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$enum_form_string_array = array("enum_form_string_array_example"); // string[] | Form parameter enum test (string array)
|
||||
$enum_form_string = "-efg"; // string | Form parameter enum test (string)
|
||||
$enum_header_string_array = array("enum_header_string_array_example"); // string[] | Header parameter enum test (string array)
|
||||
@@ -337,7 +368,7 @@ $enum_query_integer = 56; // int | Query parameter enum test (double)
|
||||
$enum_query_double = 1.2; // double | Query parameter enum test (double)
|
||||
|
||||
try {
|
||||
$api_instance->testEnumParameters($enum_form_string_array, $enum_form_string, $enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double);
|
||||
$apiInstance->testEnumParameters($enum_form_string_array, $enum_form_string, $enum_header_string_array, $enum_header_string, $enum_query_string_array, $enum_query_string, $enum_query_integer, $enum_query_double);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling FakeApi->testEnumParameters: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
@@ -384,11 +415,15 @@ test inline additionalProperties
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\FakeApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\FakeApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$param = new \stdClass; // object | request body
|
||||
|
||||
try {
|
||||
$api_instance->testInlineAdditionalProperties($param);
|
||||
$apiInstance->testInlineAdditionalProperties($param);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling FakeApi->testInlineAdditionalProperties: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
@@ -428,12 +463,16 @@ test json serialization of form data
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\FakeApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\FakeApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$param = "param_example"; // string | field1
|
||||
$param2 = "param2_example"; // string | field2
|
||||
|
||||
try {
|
||||
$api_instance->testJsonFormData($param, $param2);
|
||||
$apiInstance->testJsonFormData($param, $param2);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling FakeApi->testJsonFormData: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
@@ -18,15 +18,20 @@ To test class name in snake case
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
// Configure API key authorization: api_key_query
|
||||
Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key_query', 'YOUR_API_KEY');
|
||||
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key_query', 'YOUR_API_KEY');
|
||||
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||
// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key_query', 'Bearer');
|
||||
// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key_query', 'Bearer');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\FakeClassnameTags123Api(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\FakeClassnameTags123Api(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$body = new \Swagger\Client\Model\Client(); // \Swagger\Client\Model\Client | client model
|
||||
|
||||
try {
|
||||
$result = $api_instance->testClassname($body);
|
||||
$result = $apiInstance->testClassname($body);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling FakeClassnameTags123Api->testClassname: ', $e->getMessage(), PHP_EOL;
|
||||
|
||||
@@ -27,13 +27,18 @@ Add a new pet to the store
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\PetApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$body = new \Swagger\Client\Model\Pet(); // \Swagger\Client\Model\Pet | Pet object that needs to be added to the store
|
||||
|
||||
try {
|
||||
$api_instance->addPet($body);
|
||||
$apiInstance->addPet($body);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->addPet: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
@@ -74,14 +79,19 @@ Deletes a pet
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\PetApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$pet_id = 789; // int | Pet id to delete
|
||||
$api_key = "api_key_example"; // string |
|
||||
|
||||
try {
|
||||
$api_instance->deletePet($pet_id, $api_key);
|
||||
$apiInstance->deletePet($pet_id, $api_key);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->deletePet: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
@@ -123,13 +133,18 @@ Multiple status values can be provided with comma separated strings
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\PetApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$status = array("status_example"); // string[] | Status values that need to be considered for filter
|
||||
|
||||
try {
|
||||
$result = $api_instance->findPetsByStatus($status);
|
||||
$result = $apiInstance->findPetsByStatus($status);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->findPetsByStatus: ', $e->getMessage(), PHP_EOL;
|
||||
@@ -171,13 +186,18 @@ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\PetApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$tags = array("tags_example"); // string[] | Tags to filter by
|
||||
|
||||
try {
|
||||
$result = $api_instance->findPetsByTags($tags);
|
||||
$result = $apiInstance->findPetsByTags($tags);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->findPetsByTags: ', $e->getMessage(), PHP_EOL;
|
||||
@@ -219,15 +239,20 @@ Returns a single pet
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
// Configure API key authorization: api_key
|
||||
Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY');
|
||||
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY');
|
||||
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||
// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer');
|
||||
// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\PetApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$pet_id = 789; // int | ID of pet to return
|
||||
|
||||
try {
|
||||
$result = $api_instance->getPetById($pet_id);
|
||||
$result = $apiInstance->getPetById($pet_id);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->getPetById: ', $e->getMessage(), PHP_EOL;
|
||||
@@ -269,13 +294,18 @@ Update an existing pet
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\PetApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$body = new \Swagger\Client\Model\Pet(); // \Swagger\Client\Model\Pet | Pet object that needs to be added to the store
|
||||
|
||||
try {
|
||||
$api_instance->updatePet($body);
|
||||
$apiInstance->updatePet($body);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->updatePet: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
@@ -316,15 +346,20 @@ Updates a pet in the store with form data
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\PetApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$pet_id = 789; // int | ID of pet that needs to be updated
|
||||
$name = "name_example"; // string | Updated name of the pet
|
||||
$status = "status_example"; // string | Updated status of the pet
|
||||
|
||||
try {
|
||||
$api_instance->updatePetWithForm($pet_id, $name, $status);
|
||||
$apiInstance->updatePetWithForm($pet_id, $name, $status);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->updatePetWithForm: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
@@ -367,15 +402,20 @@ uploads an image
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
// Configure OAuth2 access token for authorization: petstore_auth
|
||||
Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\PetApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\PetApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
$pet_id = 789; // int | ID of pet to update
|
||||
$additional_metadata = "additional_metadata_example"; // string | Additional data to pass to server
|
||||
$file = "/path/to/file.txt"; // \SplFileObject | file to upload
|
||||
|
||||
try {
|
||||
$result = $api_instance->uploadFile($pet_id, $additional_metadata, $file);
|
||||
$result = $apiInstance->uploadFile($pet_id, $additional_metadata, $file);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling PetApi->uploadFile: ', $e->getMessage(), PHP_EOL;
|
||||
|
||||
@@ -22,11 +22,15 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\StoreApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\StoreApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$order_id = "order_id_example"; // string | ID of the order that needs to be deleted
|
||||
|
||||
try {
|
||||
$api_instance->deleteOrder($order_id);
|
||||
$apiInstance->deleteOrder($order_id);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling StoreApi->deleteOrder: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
@@ -67,14 +71,19 @@ Returns a map of status codes to quantities
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
// Configure API key authorization: api_key
|
||||
Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY');
|
||||
$config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKey('api_key', 'YOUR_API_KEY');
|
||||
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
|
||||
// Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer');
|
||||
// $config = Swagger\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\StoreApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\StoreApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client(),
|
||||
$config
|
||||
);
|
||||
|
||||
try {
|
||||
$result = $api_instance->getInventory();
|
||||
$result = $apiInstance->getInventory();
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling StoreApi->getInventory: ', $e->getMessage(), PHP_EOL;
|
||||
@@ -112,11 +121,15 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\StoreApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\StoreApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$order_id = 789; // int | ID of pet that needs to be fetched
|
||||
|
||||
try {
|
||||
$result = $api_instance->getOrderById($order_id);
|
||||
$result = $apiInstance->getOrderById($order_id);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling StoreApi->getOrderById: ', $e->getMessage(), PHP_EOL;
|
||||
@@ -157,11 +170,15 @@ Place an order for a pet
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\StoreApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\StoreApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$body = new \Swagger\Client\Model\Order(); // \Swagger\Client\Model\Order | order placed for purchasing the pet
|
||||
|
||||
try {
|
||||
$result = $api_instance->placeOrder($body);
|
||||
$result = $apiInstance->placeOrder($body);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling StoreApi->placeOrder: ', $e->getMessage(), PHP_EOL;
|
||||
|
||||
@@ -26,11 +26,15 @@ This can only be done by the logged in user.
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\UserApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\UserApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$body = new \Swagger\Client\Model\User(); // \Swagger\Client\Model\User | Created user object
|
||||
|
||||
try {
|
||||
$api_instance->createUser($body);
|
||||
$apiInstance->createUser($body);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling UserApi->createUser: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
@@ -70,11 +74,15 @@ Creates list of users with given input array
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\UserApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\UserApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$body = array(new \Swagger\Client\Model\User()); // \Swagger\Client\Model\User[] | List of user object
|
||||
|
||||
try {
|
||||
$api_instance->createUsersWithArrayInput($body);
|
||||
$apiInstance->createUsersWithArrayInput($body);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling UserApi->createUsersWithArrayInput: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
@@ -114,11 +122,15 @@ Creates list of users with given input array
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\UserApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\UserApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$body = array(new \Swagger\Client\Model\User()); // \Swagger\Client\Model\User[] | List of user object
|
||||
|
||||
try {
|
||||
$api_instance->createUsersWithListInput($body);
|
||||
$apiInstance->createUsersWithListInput($body);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling UserApi->createUsersWithListInput: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
@@ -158,11 +170,15 @@ This can only be done by the logged in user.
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\UserApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\UserApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$username = "username_example"; // string | The name that needs to be deleted
|
||||
|
||||
try {
|
||||
$api_instance->deleteUser($username);
|
||||
$apiInstance->deleteUser($username);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling UserApi->deleteUser: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
@@ -202,11 +218,15 @@ Get user by user name
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\UserApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\UserApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$username = "username_example"; // string | The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
try {
|
||||
$result = $api_instance->getUserByName($username);
|
||||
$result = $apiInstance->getUserByName($username);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling UserApi->getUserByName: ', $e->getMessage(), PHP_EOL;
|
||||
@@ -247,12 +267,16 @@ Logs user into the system
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\UserApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\UserApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$username = "username_example"; // string | The user name for login
|
||||
$password = "password_example"; // string | The password for login in clear text
|
||||
|
||||
try {
|
||||
$result = $api_instance->loginUser($username, $password);
|
||||
$result = $apiInstance->loginUser($username, $password);
|
||||
print_r($result);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling UserApi->loginUser: ', $e->getMessage(), PHP_EOL;
|
||||
@@ -294,10 +318,14 @@ Logs out current logged in user session
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\UserApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\UserApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
|
||||
try {
|
||||
$api_instance->logoutUser();
|
||||
$apiInstance->logoutUser();
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling UserApi->logoutUser: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
@@ -334,12 +362,16 @@ This can only be done by the logged in user.
|
||||
<?php
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
|
||||
$api_instance = new Swagger\Client\Api\UserApi(new \Http\Adapter\Guzzle6\Client());
|
||||
$apiInstance = new Swagger\Client\Api\UserApi(
|
||||
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
|
||||
// This is optional, `GuzzleHttp\Client` will be used as default.
|
||||
new GuzzleHttp\Client()
|
||||
);
|
||||
$username = "username_example"; // string | name that need to be deleted
|
||||
$body = new \Swagger\Client\Model\User(); // \Swagger\Client\Model\User | Updated user object
|
||||
|
||||
try {
|
||||
$api_instance->updateUser($username, $body);
|
||||
$apiInstance->updateUser($username, $body);
|
||||
} catch (Exception $e) {
|
||||
echo 'Exception when calling UserApi->updateUser: ', $e->getMessage(), PHP_EOL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user