Skip to content

Commit 2b1f618

Browse files
authored
[php][php-nextgen] Mark nullable things as nullable in phpdoc (#22650)
* [php][php-nextgen] Mark nullable things as nullable in phpdoc * [php][php-nextgen] Use exts instead of vendorExtensions
1 parent 17f2e46 commit 2b1f618

File tree

8 files changed

+76
-76
lines changed

8 files changed

+76
-76
lines changed

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

Lines changed: 49 additions & 49 deletions
Large diffs are not rendered by default.

modules/openapi-generator/src/main/resources/php-nextgen/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-nextgen/api_test.mustache

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

modules/openapi-generator/src/main/resources/php-nextgen/model_enum.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
enum {{classname}}: {{vendorExtensions.x-php-enum-type}}
1+
enum {{classname}}: {{exts.x-php-enum-type}}
22
{
33
{{#allowableValues}}
44
{{#enumVars}}

modules/openapi-generator/src/main/resources/php-nextgen/model_generic.mustache

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,27 +376,27 @@ class {{classname}} {{#parentSchema}}extends {{{parent}}}{{/parentSchema}}{{^par
376376
/**
377377
* Gets {{name}}
378378
*
379-
* @return {{{dataType}}}{{^required}}|null{{/required}}
379+
* @return {{{dataType}}}{{#notRequiredOrIsNullable}}|null{{/notRequiredOrIsNullable}}
380380
{{#deprecated}}
381381
* @deprecated
382382
{{/deprecated}}
383383
*/
384-
public function {{getter}}(): {{vendorExtensions.x-php-prop-type}}
384+
public function {{getter}}(): {{exts.x-php-prop-type}}
385385
{
386386
return $this->container['{{name}}'];
387387
}
388388

389389
/**
390390
* Sets {{name}}
391391
*
392-
* @param {{{dataType}}}{{^required}}|null{{/required}} ${{name}}{{#description}} {{{.}}}{{/description}}{{^description}} {{{name}}}{{/description}}
392+
* @param {{{dataType}}}{{#notRequiredOrIsNullable}}|null{{/notRequiredOrIsNullable}} ${{name}}{{#description}} {{{.}}}{{/description}}{{^description}} {{{name}}}{{/description}}
393393
*
394394
* @return $this
395395
{{#deprecated}}
396396
* @deprecated
397397
{{/deprecated}}
398398
*/
399-
public function {{setter}}({{vendorExtensions.x-php-prop-type}} ${{name}}): static
399+
public function {{setter}}({{exts.x-php-prop-type}} ${{name}}): static
400400
{
401401
{{#isNullable}}
402402
if (is_null(${{name}})) {

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ use {{invokerPackage}}\ObjectSerializer;
156156
{{/-last}}
157157
{{/servers}}
158158
{{#allParams}}
159-
* @param {{{dataType}}}{{^required}}|null{{/required}} ${{paramName}}{{#description}} {{.}}{{/description}}{{^description}} {{paramName}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
159+
* @param {{{dataType}}}{{#notRequiredOrIsNullable}}|null{{/notRequiredOrIsNullable}} ${{paramName}}{{#description}} {{.}}{{/description}}{{^description}} {{paramName}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
160160
{{/allParams}}
161161
{{#servers}}
162162
{{#-first}}
@@ -215,7 +215,7 @@ use {{invokerPackage}}\ObjectSerializer;
215215
{{/-last}}
216216
{{/servers}}
217217
{{#allParams}}
218-
* @param {{{dataType}}}{{^required}}|null{{/required}} ${{paramName}}{{#description}} {{.}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
218+
* @param {{{dataType}}}{{#notRequiredOrIsNullable}}|null{{/notRequiredOrIsNullable}} ${{paramName}}{{#description}} {{.}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
219219
{{/allParams}}
220220
{{#servers}}
221221
{{#-first}}
@@ -374,7 +374,7 @@ use {{invokerPackage}}\ObjectSerializer;
374374
{{/-last}}
375375
{{/servers}}
376376
{{#allParams}}
377-
* @param {{{dataType}}}{{^required}}|null{{/required}} ${{paramName}}{{#description}} {{.}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
377+
* @param {{{dataType}}}{{#notRequiredOrIsNullable}}|null{{/notRequiredOrIsNullable}} ${{paramName}}{{#description}} {{.}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
378378
{{/allParams}}
379379
{{#servers}}
380380
{{#-first}}
@@ -436,7 +436,7 @@ use {{invokerPackage}}\ObjectSerializer;
436436
{{/-last}}
437437
{{/servers}}
438438
{{#allParams}}
439-
* @param {{{dataType}}}{{^required}}|null{{/required}} ${{paramName}}{{#description}} {{.}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
439+
* @param {{{dataType}}}{{#notRequiredOrIsNullable}}|null{{/notRequiredOrIsNullable}} ${{paramName}}{{#description}} {{.}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
440440
{{/allParams}}
441441
{{#servers}}
442442
{{#-first}}
@@ -526,7 +526,7 @@ use {{invokerPackage}}\ObjectSerializer;
526526
{{/-last}}
527527
{{/servers}}
528528
{{#allParams}}
529-
* @param {{{dataType}}}{{^required}}|null{{/required}} ${{paramName}}{{#description}} {{.}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
529+
* @param {{{dataType}}}{{#notRequiredOrIsNullable}}|null{{/notRequiredOrIsNullable}} ${{paramName}}{{#description}} {{.}}{{/description}} {{#required}}(required){{/required}}{{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}}{{#isDeprecated}} (deprecated){{/isDeprecated}}
530530
{{/allParams}}
531531
{{#servers}}
532532
{{#-first}}

samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4581,7 +4581,7 @@ public function testAdditionalPropertiesReferenceRequest(
45814581
/**
45824582
* Operation testBodyWithBinary
45834583
*
4584-
* @param \SplFileObject $body image to upload (required)
4584+
* @param \SplFileObject|null $body image to upload (required)
45854585
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation
45864586
*
45874587
* @throws ApiException on non-2xx response or if the response body is not in the expected format
@@ -4599,7 +4599,7 @@ public function testBodyWithBinary(
45994599
/**
46004600
* Operation testBodyWithBinaryWithHttpInfo
46014601
*
4602-
* @param \SplFileObject $body image to upload (required)
4602+
* @param \SplFileObject|null $body image to upload (required)
46034603
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation
46044604
*
46054605
* @throws ApiException on non-2xx response or if the response body is not in the expected format
@@ -4648,7 +4648,7 @@ public function testBodyWithBinaryWithHttpInfo(
46484648
/**
46494649
* Operation testBodyWithBinaryAsync
46504650
*
4651-
* @param \SplFileObject $body image to upload (required)
4651+
* @param \SplFileObject|null $body image to upload (required)
46524652
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation
46534653
*
46544654
* @throws InvalidArgumentException
@@ -4670,7 +4670,7 @@ function ($response) {
46704670
/**
46714671
* Operation testBodyWithBinaryAsyncWithHttpInfo
46724672
*
4673-
* @param \SplFileObject $body image to upload (required)
4673+
* @param \SplFileObject|null $body image to upload (required)
46744674
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation
46754675
*
46764676
* @throws InvalidArgumentException
@@ -4710,7 +4710,7 @@ function ($exception) {
47104710
/**
47114711
* Create request for operation 'testBodyWithBinary'
47124712
*
4713-
* @param \SplFileObject $body image to upload (required)
4713+
* @param \SplFileObject|null $body image to upload (required)
47144714
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation
47154715
*
47164716
* @throws InvalidArgumentException

samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4429,7 +4429,7 @@ public function testAdditionalPropertiesReferenceRequest($request_body, string $
44294429
/**
44304430
* Operation testBodyWithBinary
44314431
*
4432-
* @param \SplFileObject $body image to upload (required)
4432+
* @param \SplFileObject|null $body image to upload (required)
44334433
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation
44344434
*
44354435
* @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
@@ -4444,7 +4444,7 @@ public function testBodyWithBinary($body, string $contentType = self::contentTyp
44444444
/**
44454445
* Operation testBodyWithBinaryWithHttpInfo
44464446
*
4447-
* @param \SplFileObject $body image to upload (required)
4447+
* @param \SplFileObject|null $body image to upload (required)
44484448
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation
44494449
*
44504450
* @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format
@@ -4491,7 +4491,7 @@ public function testBodyWithBinaryWithHttpInfo($body, string $contentType = self
44914491
/**
44924492
* Operation testBodyWithBinaryAsync
44934493
*
4494-
* @param \SplFileObject $body image to upload (required)
4494+
* @param \SplFileObject|null $body image to upload (required)
44954495
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation
44964496
*
44974497
* @throws \InvalidArgumentException
@@ -4510,7 +4510,7 @@ function ($response) {
45104510
/**
45114511
* Operation testBodyWithBinaryAsyncWithHttpInfo
45124512
*
4513-
* @param \SplFileObject $body image to upload (required)
4513+
* @param \SplFileObject|null $body image to upload (required)
45144514
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation
45154515
*
45164516
* @throws \InvalidArgumentException
@@ -4547,7 +4547,7 @@ function ($exception) {
45474547
/**
45484548
* Create request for operation 'testBodyWithBinary'
45494549
*
4550-
* @param \SplFileObject $body image to upload (required)
4550+
* @param \SplFileObject|null $body image to upload (required)
45514551
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testBodyWithBinary'] to see the possible values for this operation
45524552
*
45534553
* @throws \InvalidArgumentException

0 commit comments

Comments
 (0)