handlebars.htmlDocs2.sample_php.mustache Maven / Gradle / Ivy
<?php
require_once(__DIR__ . '/vendor/autoload.php');
{{#hasAuthMethods}}{{#authMethods}}{{#is this 'basic'}}
// Configure HTTP basic authorization: {{{name}}}
{{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setUsername('YOUR_USERNAME');
{{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setPassword('YOUR_PASSWORD');{{/is}}{{#is this 'api-key'}}
// Configure API key authorization: {{{name}}}
{{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setApiKey('{{{keyParamName}}}', 'YOUR_API_KEY');
// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
// {{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setApiKeyPrefix('{{{keyParamName}}}', 'Bearer');{{/is}}{{#is this 'oauth'}}
// Configure OAuth2 access token for authorization: {{{name}}}
{{phpInvokerPackage}}\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');{{/is}}{{/authMethods}}
{{/hasAuthMethods}}
$api_instance = new Swagger\Client\Api{{backslash}}{{classname}}();
{{#parameters}}${{paramName}} = {{{example}}}; // {{{dataType}}} | {{{unescapedDescription}}}
{{/parameters}}
try {
{{#returnType}}$result = {{/returnType}}$api_instance->{{{operationId}}}({{#parameters}}${{paramName}}{{#has this 'more'}}, {{/has}}{{/parameters}});{{#returnType}}
print_r($result);{{/returnType}}
} catch (Exception $e) {
echo 'Exception when calling {{classname}}->{{operationId}}: ', $e->getMessage(), PHP_EOL;
}
?>