Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 8722 #283

Merged
merged 2 commits into from
Jan 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/resources/handlebars/php/ObjectSerializer.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class ObjectSerializer
// determine file name
if (array_key_exists('Content-Disposition', $httpHeaders) &&
preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match)) {
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . self::sanitizeFilename($match[1]);
$filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . DIRECTORY_SEPARATOR . self::sanitizeFilename($match[1]);
} else {
$filename = tempnam(Configuration::getDefaultConfiguration()->getTempFolderPath(), '');
}
Expand All @@ -283,7 +283,7 @@ class ObjectSerializer
// If a discriminator is defined and points to a valid subclass, use it.
$discriminator = $class::DISCRIMINATOR;
if (!empty($discriminator) && isset($data->{$discriminator}) && is_string($data->{$discriminator})) {
$subclass = '{{backslash}}{{invokerPackage}}\Model\\' . $data->{$discriminator};
$subclass = '\{{invokerPackage}}\Model\\' . $data->{$discriminator};
if (is_subclass_of($subclass, $class)) {
$class = $subclass;
}
Expand Down
50 changes: 26 additions & 24 deletions src/main/resources/handlebars/php/README.mustache
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# {{packagePath}}
{{#appDescription}}{{{appDescription}}}{{/appDescription}}
{{#appDescription}}
{{{appDescription}}}
{{/appDescription}}

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

Expand Down Expand Up @@ -64,34 +66,35 @@ 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}}{{#has ../this 'auth-methods'}}{{#authMethods}}{{#is this 'basic'}}
{{#apiInfo}}{{#apis}}{{#@first}}{{#operations}}{{#operation}}{{#contents}}{{#@first}}{{#hasAuthMethods}}{{#authMethods}}{{#isBasic}}
// Configure HTTP basic authorization: {{{name}}}
$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()
->setUsername('YOUR_USERNAME')
->setPassword('YOUR_PASSWORD');{{/is}}{{#is this 'api-key'}}
->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');{{/is}}{{#is this 'oauth'}}
// $config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setApiKeyPrefix('{{{keyParamName}}}', 'Bearer');{{/isApiKey}}{{#isOAuth}}
// Configure OAuth2 access token for authorization: {{{name}}}
$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');{{/is}}{{/authMethods}}
{{/has}}
$config = {{{invokerPackage}}}\Configuration::getDefaultConfiguration()->setAccessToken('YOUR_ACCESS_TOKEN');{{/isOAuth}}{{/authMethods}}
{{/hasAuthMethods}}

$apiInstance = new {{concat apiPackage '\\' 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.
new GuzzleHttp\Client(){{#has ../this 'auth-methods'}},
$config{{/has}}
new GuzzleHttp\Client(){{#hasAuthMethods}},
$config{{/hasAuthMethods}}
);
{{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}}
{{/allParams}}
{{#parameters}}${{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}}
{{/parameters}}

try {
{{#returnType}}$result = {{/returnType}}$apiInstance->{{{operationId}}}({{#allParams}}${{paramName}}{{#has this 'more'}}, {{/has}}{{/allParams}});{{#returnType}}
{{#returnType}}$result = {{/returnType}}$apiInstance->{{{operationId}}}({{#parameters}}${{paramName}}{{#hasMore}}, {{/hasMore}}{{/parameters}});{{#returnType}}
print_r($result);{{/returnType}}
} catch (Exception $e) {
echo 'Exception when calling {{classname}}->{{operationId}}: ', $e->getMessage(), PHP_EOL;
}
{{/@first}}{{/operation}}{{/operations}}{{/@first}}{{/apis}}{{/apiInfo}}
{{/@first}}{{/contents}}{{/operation}}{{/operations}}{{/@first}}{{/apis}}{{/apiInfo}}
?>
```

Expand All @@ -115,25 +118,24 @@ Class | Method | HTTP request | Description
{{/authMethods}}{{#authMethods}}{{#last}} Authentication schemes defined for the API:{{/last}}{{/authMethods}}
{{#authMethods}}## {{{name}}}

{{#is this 'api-key'}}- **Type**: API key
{{#isApiKey}}- **Type**: API key
- **API key parameter name**: {{{keyParamName}}}
- **Location**: {{#is this 'key-in-query'}}URL query string{{/is}}{{#is this 'key-in-header'}}HTTP header{{/is}}
{{/is}}
{{#is this 'basic'}}- **Type**: HTTP basic authentication
{{/is}}
{{#is this 'oauth'}}- **Type**: OAuth
- **Location**: {{#isKeyInQuery}}URL query string{{/isKeyInQuery}}{{#isKeyInHeader}}HTTP header{{/isKeyInHeader}}
{{/isApiKey}}
{{#isBasic}}- **Type**: HTTP basic authentication
{{/isBasic}}
{{#isOAuth}}- **Type**: OAuth
- **Flow**: {{{flow}}}
- **Authorization URL**: {{{authorizationUrl}}}
- **Scopes**: {{^scopes}}N/A{{/scopes}}

{{#each scopes}} - **{{{@key}}}**: {{this}}
{{/each}}
{{/is}}
{{#scopes}} - **{{{scope}}}**: {{{description}}}
{{/scopes}}
{{/isOAuth}}

{{/authMethods}}

## Author

{{#apiInfo}}{{#apis}}{{#has ../../../this 'more'}}{{infoEmail}}
{{/has}}{{/apis}}{{/apiInfo}}
{{#apiInfo}}{{#apis}}{{^hasMore}}{{infoEmail}}
{{/hasMore}}{{/apis}}{{/apiInfo}}

Loading