Skip to content

Commit a6c753e

Browse files
authored
php template minor refactoring (#22310)
1 parent 81285b7 commit a6c753e

File tree

6 files changed

+58
-58
lines changed

6 files changed

+58
-58
lines changed

modules/openapi-generator/src/main/resources/php/api.mustache

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ use {{invokerPackage}}\ObjectSerializer;
131131
* {{.}}
132132
*
133133
{{/description}}
134-
{{#vendorExtensions.x-group-parameters}}
134+
{{#exts.x-group-parameters}}
135135
* Note: the input parameter is an associative array with the keys listed as the parameter name below
136136
*
137-
{{/vendorExtensions.x-group-parameters}}
137+
{{/exts.x-group-parameters}}
138138
{{#servers}}
139139
{{#-first}}
140140
* This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host.
@@ -173,9 +173,9 @@ use {{invokerPackage}}\ObjectSerializer;
173173
* @deprecated
174174
{{/isDeprecated}}
175175
*/
176-
public function {{operationId}}({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
176+
public function {{operationId}}({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}})
177177
{
178-
{{#returnType}}list($response) = {{/returnType}}$this->{{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});{{#returnType}}
178+
{{#returnType}}list($response) = {{/returnType}}$this->{{operationId}}WithHttpInfo({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}});{{#returnType}}
179179
return $response;{{/returnType}}
180180
}
181181

@@ -190,10 +190,10 @@ use {{invokerPackage}}\ObjectSerializer;
190190
* {{.}}
191191
*
192192
{{/description}}
193-
{{#vendorExtensions.x-group-parameters}}
193+
{{#exts.x-group-parameters}}
194194
* Note: the input parameter is an associative array with the keys listed as the parameter name below
195195
*
196-
{{/vendorExtensions.x-group-parameters}}
196+
{{/exts.x-group-parameters}}
197197
{{#servers}}
198198
{{#-first}}
199199
* This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host.
@@ -232,9 +232,9 @@ use {{invokerPackage}}\ObjectSerializer;
232232
* @deprecated
233233
{{/isDeprecated}}
234234
*/
235-
public function {{operationId}}WithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
235+
public function {{operationId}}WithHttpInfo({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}})
236236
{
237-
$request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});
237+
$request = $this->{{operationId}}Request({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}});
238238

239239
try {
240240
$options = $this->createHttpClientOption();
@@ -349,10 +349,10 @@ use {{invokerPackage}}\ObjectSerializer;
349349
* {{.}}
350350
*
351351
{{/description}}
352-
{{#vendorExtensions.x-group-parameters}}
352+
{{#exts.x-group-parameters}}
353353
* Note: the input parameter is an associative array with the keys listed as the parameter name below
354354
*
355-
{{/vendorExtensions.x-group-parameters}}
355+
{{/exts.x-group-parameters}}
356356
{{#servers}}
357357
{{#-first}}
358358
* This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host.
@@ -390,9 +390,9 @@ use {{invokerPackage}}\ObjectSerializer;
390390
* @deprecated
391391
{{/isDeprecated}}
392392
*/
393-
public function {{operationId}}Async({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
393+
public function {{operationId}}Async({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}})
394394
{
395-
return $this->{{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
395+
return $this->{{operationId}}AsyncWithHttpInfo({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}})
396396
->then(
397397
function ($response) {
398398
return $response[0];
@@ -411,10 +411,10 @@ use {{invokerPackage}}\ObjectSerializer;
411411
* {{.}}
412412
*
413413
{{/description}}
414-
{{#vendorExtensions.x-group-parameters}}
414+
{{#exts.x-group-parameters}}
415415
* Note: the input parameter is an associative array with the keys listed as the parameter name below
416416
*
417-
{{/vendorExtensions.x-group-parameters}}
417+
{{/exts.x-group-parameters}}
418418
{{#servers}}
419419
{{#-first}}
420420
* This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host.
@@ -452,10 +452,10 @@ use {{invokerPackage}}\ObjectSerializer;
452452
* @deprecated
453453
{{/isDeprecated}}
454454
*/
455-
public function {{operationId}}AsyncWithHttpInfo({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
455+
public function {{operationId}}AsyncWithHttpInfo({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}})
456456
{
457457
$returnType = '{{{returnType}}}';
458-
$request = $this->{{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}});
458+
$request = $this->{{operationId}}Request({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}, {{/allParams}}{{#servers}}{{#-first}}$hostIndex, $variables, {{/-first}}{{/servers}}$contentType{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}});
459459

460460
return $this->client
461461
->sendAsync($request, $this->createHttpClientOption())
@@ -501,10 +501,10 @@ use {{invokerPackage}}\ObjectSerializer;
501501
/**
502502
* Create request for operation '{{{operationId}}}'
503503
*
504-
{{#vendorExtensions.x-group-parameters}}
504+
{{#exts.x-group-parameters}}
505505
* Note: the input parameter is an associative array with the keys listed as the parameter name below
506506
*
507-
{{/vendorExtensions.x-group-parameters}}
507+
{{/exts.x-group-parameters}}
508508
{{#servers}}
509509
{{#-first}}
510510
* This operation contains host(s) defined in the OpenAPI spec. Use 'hostIndex' to select the host.
@@ -542,9 +542,9 @@ use {{invokerPackage}}\ObjectSerializer;
542542
* @deprecated
543543
{{/isDeprecated}}
544544
*/
545-
public function {{operationId}}Request({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associative_array{{/vendorExtensions.x-group-parameters}})
545+
public function {{operationId}}Request({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}{{^required}} = {{#defaultValue}}{{{.}}}{{/defaultValue}}{{^defaultValue}}null{{/defaultValue}}{{/required}}, {{/allParams}}{{#servers}}{{#-first}}?int $hostIndex = null, array $variables = [], {{/-first}}{{/servers}}string $contentType = self::contentTypes['{{{operationId}}}'][0]{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associative_array{{/exts.x-group-parameters}})
546546
{
547-
{{#vendorExtensions.x-group-parameters}}
547+
{{#exts.x-group-parameters}}
548548
// unbox the parameters from the associative array
549549
{{#allParams}}
550550
${{paramName}} = array_key_exists('{{paramName}}', $associative_array) ? $associative_array['{{paramName}}'] : {{{defaultValue}}}{{^defaultValue}}null{{/defaultValue}};
@@ -553,7 +553,7 @@ use {{invokerPackage}}\ObjectSerializer;
553553
$variables = array_key_exists('variables', $associative_array) ? $associative_array['variables'] : [];
554554
{{/servers.0}}
555555
$contentType = $associative_array['contentType'] ?? self::contentTypes['{{{operationId}}}'][0];
556-
{{/vendorExtensions.x-group-parameters}}{{#allParams}}
556+
{{/exts.x-group-parameters}}{{#allParams}}
557557
{{#required}}
558558
// verify the required parameter '{{paramName}}' is set
559559
if (${{paramName}} === null || (is_array(${{paramName}}) && count(${{paramName}}) === 0)) {

modules/openapi-generator/src/main/resources/php/api_doc.mustache

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ $apiInstance = new {{invokerPackage}}\Api\{{classname}}(
4747
new GuzzleHttp\Client(){{#hasAuthMethods}},
4848
$config{{/hasAuthMethods}}
4949
);
50-
{{^vendorExtensions.x-group-parameters}}
50+
{{^exts.x-group-parameters}}
5151
{{#allParams}}${{paramName}} = {{{example}}}; // {{{dataType}}}{{#description}} | {{{.}}}{{/description}}
5252
{{/allParams}}{{#servers}}{{#-first}}
5353
$hostIndex = 0;
5454
$variables = [{{#variables}}
5555
'{{{name}}}' => '{{{default}}}{{^default}}YOUR_VALUE{{/default}}',{{/variables}}
5656
];
57-
{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}
57+
{{/-first}}{{/servers}}{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}
5858
$associative_array = [
5959
{{#allParams}} '{{paramName}}' => {{{example}}}, // {{{dataType}}}{{#description}} | {{{.}}}{{/description}}
6060
{{/allParams}}
@@ -64,10 +64,10 @@ $associative_array = [
6464
'{{{name}}}' => '{{{default}}}{{^default}}YOUR_VALUE{{/default}}',{{/variables}}
6565
],
6666
{{/-first}}{{/servers}}];
67-
{{/vendorExtensions.x-group-parameters}}
67+
{{/exts.x-group-parameters}}
6868

6969
try {
70-
{{#returnType}}$result = {{/returnType}}$apiInstance->{{{operationId}}}({{^vendorExtensions.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}$hostIndex, $variables{{/-first}}{{/servers}}{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}$associate_array{{/vendorExtensions.x-group-parameters}});{{#returnType}}
70+
{{#returnType}}$result = {{/returnType}}$apiInstance->{{{operationId}}}({{^exts.x-group-parameters}}{{#allParams}}${{paramName}}{{^-last}}, {{/-last}}{{/allParams}}{{#servers}}{{#-first}}{{#allParams}}{{#-first}}, {{/-first}}{{/allParams}}$hostIndex, $variables{{/-first}}{{/servers}}{{/exts.x-group-parameters}}{{#exts.x-group-parameters}}$associate_array{{/exts.x-group-parameters}});{{#returnType}}
7171
print_r($result);{{/returnType}}
7272
} catch (Exception $e) {
7373
echo 'Exception when calling {{classname}}->{{operationId}}: ', $e->getMessage(), PHP_EOL;
@@ -76,10 +76,10 @@ try {
7676

7777
### Parameters
7878

79-
{{#vendorExtensions.x-group-parameters}}
79+
{{#exts.x-group-parameters}}
8080
Note: the input parameter is an associative array with the keys listed as the parameter names below.
8181

82-
{{/vendorExtensions.x-group-parameters}}
82+
{{/exts.x-group-parameters}}
8383
{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#allParams}}{{#-last}}| Name | Type | Description | Notes |
8484
| ------------- | ------------- | ------------- | ------------- |{{/-last}}{{/allParams}}
8585
{{#allParams}}| **{{paramName}}** | {{#isFile}}**{{{dataType}}}**{{/isFile}}{{#isPrimitiveType}}**{{{dataType}}}**{{/isPrimitiveType}}{{^isPrimitiveType}}{{^isFile}}[**{{{dataType}}}**](../Model/{{baseType}}.md){{/isFile}}{{/isPrimitiveType}}| {{description}} |{{^required}} [optional]{{/required}}{{#defaultValue}} [default to {{.}}]{{/defaultValue}} |

modules/openapi-generator/src/main/resources/php/api_test.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ use PHPUnit\Framework\TestCase;
7070
* {{{summary}}}.
7171
*
7272
*/
73-
public function test{{vendorExtensions.x-test-operation-id}}()
73+
public function test{{exts.x-test-operation-id}}()
7474
{
7575
// TODO: implement
7676
self::markTestIncomplete('Not implemented');

0 commit comments

Comments
 (0)