Add Bearer authentication to PHP API client (#2013)

* add php bearer auth support

* add partial mustache

* add bearer format

* update php ze-ph samples
This commit is contained in:
William Cheng 2019-01-31 17:54:10 +08:00 committed by GitHub
parent 6801741592
commit 453eeb9e40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 153 additions and 55 deletions

View File

@ -46,7 +46,7 @@ class Configuration
protected $apiKeyPrefixes = [];
/**
* Access token for OAuth
* Access token for OAuth/Bearer authentication
*
* @var string
*/

View File

@ -66,19 +66,9 @@ Please follow the [installation procedure](#installation--usage) and then run th
```php
<?php
require_once(__DIR__ . '/vendor/autoload.php');
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}
// Configure HTTP basic authorization: {{{name}}}
$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()
->setUsername('YOUR_USERNAME')
->setPassword('YOUR_PASSWORD');{{/isBasic}}{{#isApiKey}}
// Configure API key authorization: {{{name}}}
$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKey('{{{keyParamName}}}', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKeyPrefix('{{{keyParamName}}}', 'Bearer');{{/isApiKey}}{{#isOAuth}}
// Configure OAuth2 access token for authorization: {{{name}}}
$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');{{/isOAuth}}{{/authMethods}}
{{/hasAuthMethods}}
{{#apiInfo}}{{#apis}}{{#-first}}{{#operations}}{{#operation}}{{#-first}}
{{> php_doc_auth_partial}}
$apiInstance = new {{invokerPackage}}\Api\{{classname}}(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.
@ -114,21 +104,33 @@ Class | Method | HTTP request | Description
## Documentation For Authorization
{{^authMethods}} All endpoints do not require authorization.
{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}}
{{#authMethods}}## {{{name}}}
{{^authMethods}}
All endpoints do not require authorization.
{{/authMethods}}
{{#authMethods}}
{{#last}} Authentication schemes defined for the API:{{/last}}
## {{{name}}}
{{#isApiKey}}- **Type**: API key
{{#isApiKey}}
- **Type**: API key
- **API key parameter name**: {{{keyParamName}}}
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
{{/isApiKey}}
{{#isBasic}}- **Type**: HTTP basic authentication
{{#isBasic}}
{{^isBasicBearer}}
- **Type**: HTTP basic authentication
{{/isBasicBearer}}
{{#isBasicBearer}}
- **Type**: Bearer authentication{{#bearerFormat}} ({{{.}}}){{/bearerFormat}}
{{/isBasicBearer}}
{{/isBasic}}
{{#isOAuth}}- **Type**: OAuth
{{#isOAuth}}
- **Type**: OAuth
- **Flow**: {{{flow}}}
- **Authorization URL**: {{{authorizationUrl}}}
- **Scopes**: {{^scopes}}N/A{{/scopes}}
{{#scopes}} - **{{{scope}}}**: {{{description}}}
{{#scopes}}
- **{{{scope}}}**: {{{description}}}
{{/scopes}}
{{/isOAuth}}

View File

@ -506,10 +506,18 @@ use {{invokerPackage}}\ObjectSerializer;
}
{{/isApiKey}}
{{#isBasic}}
{{^isBasicBearer}}
// this endpoint requires HTTP basic authentication
if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) {
$headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword());
}
{{/isBasicBearer}}
{{#isBasicBearer}}
// this endpoint requires Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} authentication (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
{{/isBasicBearer}}
{{/isBasic}}
{{#isOAuth}}
// this endpoint requires OAuth (access token)

View File

@ -22,27 +22,7 @@ Method | HTTP request | Description
<?php
require_once(__DIR__ . '/vendor/autoload.php');
{{#hasAuthMethods}}
{{#authMethods}}
{{#isBasic}}
// Configure HTTP basic authorization: {{{name}}}
$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()
->setUsername('YOUR_USERNAME')
->setPassword('YOUR_PASSWORD');
{{/isBasic}}
{{#isApiKey}}
// Configure API key authorization: {{{name}}}
$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKey('{{{keyParamName}}}', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKeyPrefix('{{{keyParamName}}}', 'Bearer');
{{/isApiKey}}
{{#isOAuth}}
// Configure OAuth2 access token for authorization: {{{name}}}
$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
{{/isOAuth}}
{{/authMethods}}
{{/hasAuthMethods}}
{{> php_doc_auth_partial}}
$apiInstance = new {{invokerPackage}}\Api\{{classname}}(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.

View File

@ -0,0 +1,27 @@
{{#hasAuthMethods}}
{{#authMethods}}
{{#isBasic}}
{{^isBasicBearer}}
// Configure HTTP basic authorization: {{{name}}}
$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()
->setUsername('YOUR_USERNAME')
->setPassword('YOUR_PASSWORD');
{{/isBasicBearer}}
{{#isBasicBearer}}
// Configure Bearer{{#bearerFormat}} ({{{.}}}){{/bearerFormat}} authorization: {{{name}}}
$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
{{/isBasicBearer}}
{{/isBasic}}
{{#isApiKey}}
// Configure API key authorization: {{{name}}}
$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKey('{{{keyParamName}}}', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKeyPrefix('{{{keyParamName}}}', 'Bearer');
{{/isApiKey}}
{{#isOAuth}}
// Configure OAuth2 access token for authorization: {{{name}}}
$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
{{/isOAuth}}
{{/authMethods}}
{{/hasAuthMethods}}

View File

@ -56,6 +56,8 @@ Please follow the [installation procedure](#installation--usage) and then run th
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -167,24 +169,27 @@ Class | Method | HTTP request | Description
- **API key parameter name**: api_key
- **Location**: HTTP header
## api_key_query
- **Type**: API key
- **API key parameter name**: api_key_query
- **Location**: URL query string
## http_basic_test
- **Type**: HTTP basic authentication
## petstore_auth
- **Type**: OAuth
- **Flow**: implicit
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
- **Scopes**:
- **write:pets**: modify pets in your account
- **read:pets**: read your pets
- **write:pets**: modify pets in your account
- **read:pets**: read your pets
## Author

View File

@ -19,6 +19,7 @@ To test special tags and operation ID starting with number
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.

View File

@ -31,6 +31,7 @@ this route creates an XmlItem
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -79,6 +80,7 @@ Test serialization of outer boolean types
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -128,6 +130,7 @@ Test serialization of object with outer number type
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -177,6 +180,7 @@ Test serialization of outer number types
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -226,6 +230,7 @@ Test serialization of outer string types
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -275,6 +280,7 @@ For this test, the body for this request much reference a schema named `File`.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -321,6 +327,7 @@ No authorization required
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -371,6 +378,7 @@ To test \"client\" model
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -425,6 +433,7 @@ $config = OpenAPI\Client\Configuration::getDefaultConfiguration()
->setUsername('YOUR_USERNAME')
->setPassword('YOUR_PASSWORD');
$apiInstance = new OpenAPI\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.
@ -500,6 +509,7 @@ To test enum parameters
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -562,6 +572,7 @@ Fake endpoint to test group parameters (optional)
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -620,6 +631,7 @@ test inline additionalProperties
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -666,6 +678,7 @@ test json serialization of form data
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.

View File

@ -24,6 +24,7 @@ $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKey('ap
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key_query', 'Bearer');
$apiInstance = new OpenAPI\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.

View File

@ -28,6 +28,7 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\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.
@ -78,6 +79,7 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\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.
@ -132,6 +134,7 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\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.
@ -185,6 +188,7 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\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.
@ -240,6 +244,7 @@ $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKey('ap
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer');
$apiInstance = new OpenAPI\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.
@ -291,6 +296,7 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\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.
@ -341,6 +347,7 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\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.
@ -395,6 +402,7 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\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.
@ -450,6 +458,7 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\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.

View File

@ -22,6 +22,7 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -75,6 +76,7 @@ $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKey('ap
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer');
$apiInstance = new OpenAPI\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.
@ -121,6 +123,7 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -168,6 +171,7 @@ Place an order for a pet
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.

View File

@ -26,6 +26,7 @@ This can only be done by the logged in user.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -72,6 +73,7 @@ Creates list of users with given input array
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -118,6 +120,7 @@ Creates list of users with given input array
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -166,6 +169,7 @@ This can only be done by the logged in user.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -212,6 +216,7 @@ Get user by user name
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -259,6 +264,7 @@ Logs user into the system
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -308,6 +314,7 @@ Logs out current logged in user session
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -352,6 +359,7 @@ This can only be done by the logged in user.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.

View File

@ -56,7 +56,7 @@ class Configuration
protected $apiKeyPrefixes = [];
/**
* Access token for OAuth
* Access token for OAuth/Bearer authentication
*
* @var string
*/

View File

@ -56,6 +56,8 @@ Please follow the [installation procedure](#installation--usage) and then run th
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -172,28 +174,32 @@ Class | Method | HTTP request | Description
- **API key parameter name**: api_key
- **Location**: HTTP header
## api_key_query
- **Type**: API key
- **API key parameter name**: api_key_query
- **Location**: URL query string
## bearer_test
- **Type**: HTTP basic authentication
- **Type**: Bearer authentication (JWT)
## http_basic_test
- **Type**: HTTP basic authentication
## petstore_auth
- **Type**: OAuth
- **Flow**: implicit
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
- **Scopes**:
- **write:pets**: modify pets in your account
- **read:pets**: read your pets
- **write:pets**: modify pets in your account
- **read:pets**: read your pets
## Author

View File

@ -19,6 +19,7 @@ To test special tags and operation ID starting with number
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.

View File

@ -17,6 +17,7 @@ Method | HTTP request | Description
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\Client\Api\DefaultApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
// This is optional, `GuzzleHttp\Client` will be used as default.

View File

@ -30,6 +30,7 @@ Test serialization of outer boolean types
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -79,6 +80,7 @@ Test serialization of object with outer number type
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -128,6 +130,7 @@ Test serialization of outer number types
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -177,6 +180,7 @@ Test serialization of outer string types
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -226,6 +230,7 @@ For this test, the body for this request much reference a schema named `File`.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -272,6 +277,7 @@ No authorization required
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -322,6 +328,7 @@ To test \"client\" model
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -376,6 +383,7 @@ $config = OpenAPI\Client\Configuration::getDefaultConfiguration()
->setUsername('YOUR_USERNAME')
->setPassword('YOUR_PASSWORD');
$apiInstance = new OpenAPI\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.
@ -451,6 +459,7 @@ To test enum parameters
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -513,10 +522,9 @@ Fake endpoint to test group parameters (optional)
<?php
require_once(__DIR__ . '/vendor/autoload.php');
// Configure HTTP basic authorization: bearer_test
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()
->setUsername('YOUR_USERNAME')
->setPassword('YOUR_PASSWORD');
// Configure Bearer (JWT) authorization: bearer_test
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\Client\Api\FakeApi(
// If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
@ -577,6 +585,7 @@ test inline additionalProperties
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -623,6 +632,7 @@ test json serialization of form data
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.

View File

@ -24,6 +24,7 @@ $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKey('ap
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key_query', 'Bearer');
$apiInstance = new OpenAPI\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.

View File

@ -28,6 +28,7 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\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.
@ -78,6 +79,7 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\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.
@ -132,6 +134,7 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\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.
@ -185,6 +188,7 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\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.
@ -240,6 +244,7 @@ $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKey('ap
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer');
$apiInstance = new OpenAPI\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.
@ -291,6 +296,7 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\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.
@ -341,6 +347,7 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\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.
@ -395,6 +402,7 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\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.
@ -450,6 +458,7 @@ require_once(__DIR__ . '/vendor/autoload.php');
// Configure OAuth2 access token for authorization: petstore_auth
$config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');
$apiInstance = new OpenAPI\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.

View File

@ -22,6 +22,7 @@ For valid response try integer IDs with value < 1000. Anything above 1000 or non
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -75,6 +76,7 @@ $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKey('ap
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// $config = OpenAPI\Client\Configuration::getDefaultConfiguration()->setApiKeyPrefix('api_key', 'Bearer');
$apiInstance = new OpenAPI\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.
@ -121,6 +123,7 @@ For valid response try integer IDs with value <= 5 or > 10. Other values will ge
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -168,6 +171,7 @@ Place an order for a pet
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.

View File

@ -26,6 +26,7 @@ This can only be done by the logged in user.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -72,6 +73,7 @@ Creates list of users with given input array
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -118,6 +120,7 @@ Creates list of users with given input array
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -166,6 +169,7 @@ This can only be done by the logged in user.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -212,6 +216,7 @@ Get user by user name
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -259,6 +264,7 @@ Logs user into the system
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -308,6 +314,7 @@ Logs out current logged in user session
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.
@ -352,6 +359,7 @@ This can only be done by the logged in user.
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiInstance = new OpenAPI\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.

View File

@ -2791,9 +2791,9 @@ class FakeApi
}
}
// this endpoint requires HTTP basic authentication
if ($this->config->getUsername() !== null || $this->config->getPassword() !== null) {
$headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword());
// this endpoint requires Bearer (JWT) authentication (access token)
if ($this->config->getAccessToken() !== null) {
$headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken();
}
$defaultHeaders = [];

View File

@ -56,7 +56,7 @@ class Configuration
protected $apiKeyPrefixes = [];
/**
* Access token for OAuth
* Access token for OAuth/Bearer authentication
*
* @var string
*/