Skip to content

Commit 78f2f70

Browse files
authored
[PHP] Add missing qualifier for enum parameters (#19567)
1 parent 98783f8 commit 78f2f70

File tree

24 files changed

+1450
-160
lines changed

24 files changed

+1450
-160
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import io.swagger.v3.oas.models.media.Schema;
2020
import io.swagger.v3.oas.models.media.StringSchema;
21+
import io.swagger.v3.oas.models.parameters.Parameter;
2122
import lombok.Getter;
2223
import lombok.Setter;
2324
import org.apache.commons.io.FilenameUtils;
@@ -384,6 +385,11 @@ public String getTypeDeclaration(String name) {
384385
return super.getTypeDeclaration(name);
385386
}
386387

388+
@Override
389+
protected String getParameterDataType(Parameter parameter, Schema schema) {
390+
return getTypeDeclaration(schema);
391+
}
392+
387393
@Override
388394
public String getSchemaType(Schema p) {
389395
String openAPIType = super.getSchemaType(p);

modules/openapi-generator/src/test/resources/3_0/php-nextgen/petstore-with-fake-endpoints-models-for-testing.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,42 @@ paths:
13031303
responses:
13041304
200:
13051305
description: The instance started successfully
1306+
/fake/enum/endpoint:
1307+
get:
1308+
tags:
1309+
- fake
1310+
summary: test endpoint with enum parameter
1311+
operationId: fake-enum-endpoint
1312+
parameters:
1313+
- name: enum-class
1314+
in: query
1315+
description: enum class parameter
1316+
required: true
1317+
schema:
1318+
$ref: '#/components/schemas/EnumClass'
1319+
- name: enum-class-array
1320+
in: query
1321+
description: enum class parameter
1322+
required: true
1323+
schema:
1324+
type: array
1325+
items:
1326+
$ref: '#/components/schemas/EnumClass'
1327+
- name: enum-class-map
1328+
in: query
1329+
description: enum class parameter
1330+
required: true
1331+
schema:
1332+
type: object
1333+
additionalProperties:
1334+
$ref: '#/components/schemas/EnumClass'
1335+
responses:
1336+
200:
1337+
description: The instance started successfully
1338+
content:
1339+
application/json:
1340+
schema:
1341+
$ref: '#/components/schemas/EnumClass'
13061342
servers:
13071343
- url: 'http://{server}.swagger.io:{port}/v2'
13081344
description: petstore server

modules/openapi-generator/src/test/resources/3_0/php/petstore-with-fake-endpoints-models-for-testing.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1327,6 +1327,42 @@ paths:
13271327
responses:
13281328
200:
13291329
description: OK
1330+
/fake/enum/endpoint:
1331+
get:
1332+
tags:
1333+
- fake
1334+
summary: test endpoint with enum parameter
1335+
operationId: fake-enum-endpoint
1336+
parameters:
1337+
- name: enum-class
1338+
in: query
1339+
description: enum class parameter
1340+
required: true
1341+
schema:
1342+
$ref: '#/components/schemas/EnumClass'
1343+
- name: enum-class-array
1344+
in: query
1345+
description: enum class parameter
1346+
required: true
1347+
schema:
1348+
type: array
1349+
items:
1350+
$ref: '#/components/schemas/EnumClass'
1351+
- name: enum-class-map
1352+
in: query
1353+
description: enum class parameter
1354+
required: true
1355+
schema:
1356+
type: object
1357+
additionalProperties:
1358+
$ref: '#/components/schemas/EnumClass'
1359+
responses:
1360+
200:
1361+
description: The instance started successfully
1362+
content:
1363+
application/json:
1364+
schema:
1365+
$ref: '#/components/schemas/EnumClass'
13301366
servers:
13311367
- url: 'http://{server}.swagger.io:{port}/v2'
13321368
description: petstore server

samples/client/echo_api/php-nextgen-streaming/docs/Api/HeaderApi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ $integer_header = 56; // int
3434
$boolean_header = True; // bool
3535
$string_header = 'string_header_example'; // string
3636
$enum_nonref_string_header = 'enum_nonref_string_header_example'; // string
37-
$enum_ref_string_header = new \OpenAPI\Client\Model\StringEnumRef(); // StringEnumRef
37+
$enum_ref_string_header = new \OpenAPI\Client\Model\\OpenAPI\Client\Model\StringEnumRef(); // \OpenAPI\Client\Model\StringEnumRef
3838

3939
try {
4040
$result = $apiInstance->testHeaderIntegerBooleanStringEnums($integer_header, $boolean_header, $string_header, $enum_nonref_string_header, $enum_ref_string_header);
@@ -52,7 +52,7 @@ try {
5252
| **boolean_header** | **bool**| | [optional] |
5353
| **string_header** | **string**| | [optional] |
5454
| **enum_nonref_string_header** | **string**| | [optional] |
55-
| **enum_ref_string_header** | [**StringEnumRef**](../Model/.md)| | [optional] |
55+
| **enum_ref_string_header** | [**\OpenAPI\Client\Model\StringEnumRef**](../Model/.md)| | [optional] |
5656

5757
### Return type
5858

samples/client/echo_api/php-nextgen-streaming/docs/Api/PathApi.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ $apiInstance = new OpenAPI\Client\Api\PathApi(
3333
$path_string = 'path_string_example'; // string
3434
$path_integer = 56; // int
3535
$enum_nonref_string_path = 'enum_nonref_string_path_example'; // string
36-
$enum_ref_string_path = new \OpenAPI\Client\Model\StringEnumRef(); // StringEnumRef
36+
$enum_ref_string_path = new \OpenAPI\Client\Model\\OpenAPI\Client\Model\StringEnumRef(); // \OpenAPI\Client\Model\StringEnumRef
3737

3838
try {
3939
$result = $apiInstance->testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath($path_string, $path_integer, $enum_nonref_string_path, $enum_ref_string_path);
@@ -50,7 +50,7 @@ try {
5050
| **path_string** | **string**| | |
5151
| **path_integer** | **int**| | |
5252
| **enum_nonref_string_path** | **string**| | |
53-
| **enum_ref_string_path** | [**StringEnumRef**](../Model/.md)| | |
53+
| **enum_ref_string_path** | [**\OpenAPI\Client\Model\StringEnumRef**](../Model/.md)| | |
5454

5555
### Return type
5656

samples/client/echo_api/php-nextgen-streaming/docs/Api/QueryApi.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ $apiInstance = new OpenAPI\Client\Api\QueryApi(
4040
new GuzzleHttp\Client()
4141
);
4242
$enum_nonref_string_query = 'enum_nonref_string_query_example'; // string
43-
$enum_ref_string_query = new \OpenAPI\Client\Model\StringEnumRef(); // StringEnumRef
43+
$enum_ref_string_query = new \OpenAPI\Client\Model\\OpenAPI\Client\Model\StringEnumRef(); // \OpenAPI\Client\Model\StringEnumRef
4444

4545
try {
4646
$result = $apiInstance->testEnumRefString($enum_nonref_string_query, $enum_ref_string_query);
@@ -55,7 +55,7 @@ try {
5555
| Name | Type | Description | Notes |
5656
| ------------- | ------------- | ------------- | ------------- |
5757
| **enum_nonref_string_query** | **string**| | [optional] |
58-
| **enum_ref_string_query** | [**StringEnumRef**](../Model/.md)| | [optional] |
58+
| **enum_ref_string_query** | [**\OpenAPI\Client\Model\StringEnumRef**](../Model/.md)| | [optional] |
5959

6060
### Return type
6161

@@ -217,7 +217,7 @@ $apiInstance = new OpenAPI\Client\Api\QueryApi(
217217
// This is optional, `GuzzleHttp\Client` will be used as default.
218218
new GuzzleHttp\Client()
219219
);
220-
$query_object = new \OpenAPI\Client\Model\Pet(); // Pet
220+
$query_object = new \OpenAPI\Client\Model\\OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet
221221

222222
try {
223223
$result = $apiInstance->testQueryStyleDeepObjectExplodeTrueObject($query_object);
@@ -231,7 +231,7 @@ try {
231231

232232
| Name | Type | Description | Notes |
233233
| ------------- | ------------- | ------------- | ------------- |
234-
| **query_object** | [**Pet**](../Model/.md)| | [optional] |
234+
| **query_object** | [**\OpenAPI\Client\Model\Pet**](../Model/.md)| | [optional] |
235235

236236
### Return type
237237

@@ -273,7 +273,7 @@ $apiInstance = new OpenAPI\Client\Api\QueryApi(
273273
// This is optional, `GuzzleHttp\Client` will be used as default.
274274
new GuzzleHttp\Client()
275275
);
276-
$query_object = new \OpenAPI\Client\Model\TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(); // TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
276+
$query_object = new \OpenAPI\Client\Model\\OpenAPI\Client\Model\TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter(); // \OpenAPI\Client\Model\TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter
277277

278278
try {
279279
$result = $apiInstance->testQueryStyleDeepObjectExplodeTrueObjectAllOf($query_object);
@@ -287,7 +287,7 @@ try {
287287

288288
| Name | Type | Description | Notes |
289289
| ------------- | ------------- | ------------- | ------------- |
290-
| **query_object** | [**TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter**](../Model/.md)| | [optional] |
290+
| **query_object** | [**\OpenAPI\Client\Model\TestQueryStyleDeepObjectExplodeTrueObjectAllOfQueryObjectParameter**](../Model/.md)| | [optional] |
291291

292292
### Return type
293293

@@ -441,7 +441,7 @@ $apiInstance = new OpenAPI\Client\Api\QueryApi(
441441
// This is optional, `GuzzleHttp\Client` will be used as default.
442442
new GuzzleHttp\Client()
443443
);
444-
$query_object = new \OpenAPI\Client\Model\TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(); // TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
444+
$query_object = new \OpenAPI\Client\Model\\OpenAPI\Client\Model\TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter(); // \OpenAPI\Client\Model\TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter
445445

446446
try {
447447
$result = $apiInstance->testQueryStyleFormExplodeTrueArrayString($query_object);
@@ -455,7 +455,7 @@ try {
455455

456456
| Name | Type | Description | Notes |
457457
| ------------- | ------------- | ------------- | ------------- |
458-
| **query_object** | [**TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter**](../Model/.md)| | [optional] |
458+
| **query_object** | [**\OpenAPI\Client\Model\TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter**](../Model/.md)| | [optional] |
459459

460460
### Return type
461461

@@ -497,7 +497,7 @@ $apiInstance = new OpenAPI\Client\Api\QueryApi(
497497
// This is optional, `GuzzleHttp\Client` will be used as default.
498498
new GuzzleHttp\Client()
499499
);
500-
$query_object = new \OpenAPI\Client\Model\Pet(); // Pet
500+
$query_object = new \OpenAPI\Client\Model\\OpenAPI\Client\Model\Pet(); // \OpenAPI\Client\Model\Pet
501501

502502
try {
503503
$result = $apiInstance->testQueryStyleFormExplodeTrueObject($query_object);
@@ -511,7 +511,7 @@ try {
511511

512512
| Name | Type | Description | Notes |
513513
| ------------- | ------------- | ------------- | ------------- |
514-
| **query_object** | [**Pet**](../Model/.md)| | [optional] |
514+
| **query_object** | [**\OpenAPI\Client\Model\Pet**](../Model/.md)| | [optional] |
515515

516516
### Return type
517517

@@ -553,7 +553,7 @@ $apiInstance = new OpenAPI\Client\Api\QueryApi(
553553
// This is optional, `GuzzleHttp\Client` will be used as default.
554554
new GuzzleHttp\Client()
555555
);
556-
$query_object = new \OpenAPI\Client\Model\DataQuery(); // DataQuery
556+
$query_object = new \OpenAPI\Client\Model\\OpenAPI\Client\Model\DataQuery(); // \OpenAPI\Client\Model\DataQuery
557557

558558
try {
559559
$result = $apiInstance->testQueryStyleFormExplodeTrueObjectAllOf($query_object);
@@ -567,7 +567,7 @@ try {
567567

568568
| Name | Type | Description | Notes |
569569
| ------------- | ------------- | ------------- | ------------- |
570-
| **query_object** | [**DataQuery**](../Model/.md)| | [optional] |
570+
| **query_object** | [**\OpenAPI\Client\Model\DataQuery**](../Model/.md)| | [optional] |
571571

572572
### Return type
573573

samples/client/echo_api/php-nextgen-streaming/src/Api/HeaderApi.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public function getConfig(): Configuration
132132
* @param bool|null $boolean_header boolean_header (optional)
133133
* @param string|null $string_header string_header (optional)
134134
* @param string|null $enum_nonref_string_header enum_nonref_string_header (optional)
135-
* @param StringEnumRef|null $enum_ref_string_header enum_ref_string_header (optional)
135+
* @param \OpenAPI\Client\Model\StringEnumRef|null $enum_ref_string_header enum_ref_string_header (optional)
136136
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanStringEnums'] to see the possible values for this operation
137137
*
138138
* @throws ApiException on non-2xx response or if the response body is not in the expected format
@@ -144,7 +144,7 @@ public function testHeaderIntegerBooleanStringEnums(
144144
?bool $boolean_header = null,
145145
?string $string_header = null,
146146
?string $enum_nonref_string_header = null,
147-
?StringEnumRef $enum_ref_string_header = null,
147+
?\OpenAPI\Client\Model\StringEnumRef $enum_ref_string_header = null,
148148
string $contentType = self::contentTypes['testHeaderIntegerBooleanStringEnums'][0]
149149
): string
150150
{
@@ -161,7 +161,7 @@ public function testHeaderIntegerBooleanStringEnums(
161161
* @param bool|null $boolean_header (optional)
162162
* @param string|null $string_header (optional)
163163
* @param string|null $enum_nonref_string_header (optional)
164-
* @param StringEnumRef|null $enum_ref_string_header (optional)
164+
* @param \OpenAPI\Client\Model\StringEnumRef|null $enum_ref_string_header (optional)
165165
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanStringEnums'] to see the possible values for this operation
166166
*
167167
* @throws ApiException on non-2xx response or if the response body is not in the expected format
@@ -173,7 +173,7 @@ public function testHeaderIntegerBooleanStringEnumsWithHttpInfo(
173173
?bool $boolean_header = null,
174174
?string $string_header = null,
175175
?string $enum_nonref_string_header = null,
176-
?StringEnumRef $enum_ref_string_header = null,
176+
?\OpenAPI\Client\Model\StringEnumRef $enum_ref_string_header = null,
177177
string $contentType = self::contentTypes['testHeaderIntegerBooleanStringEnums'][0]
178178
): array
179179
{
@@ -296,7 +296,7 @@ public function testHeaderIntegerBooleanStringEnumsWithHttpInfo(
296296
* @param bool|null $boolean_header (optional)
297297
* @param string|null $string_header (optional)
298298
* @param string|null $enum_nonref_string_header (optional)
299-
* @param StringEnumRef|null $enum_ref_string_header (optional)
299+
* @param \OpenAPI\Client\Model\StringEnumRef|null $enum_ref_string_header (optional)
300300
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanStringEnums'] to see the possible values for this operation
301301
*
302302
* @throws InvalidArgumentException
@@ -307,7 +307,7 @@ public function testHeaderIntegerBooleanStringEnumsAsync(
307307
?bool $boolean_header = null,
308308
?string $string_header = null,
309309
?string $enum_nonref_string_header = null,
310-
?StringEnumRef $enum_ref_string_header = null,
310+
?\OpenAPI\Client\Model\StringEnumRef $enum_ref_string_header = null,
311311
string $contentType = self::contentTypes['testHeaderIntegerBooleanStringEnums'][0]
312312
): PromiseInterface
313313
{
@@ -328,7 +328,7 @@ function ($response) {
328328
* @param bool|null $boolean_header (optional)
329329
* @param string|null $string_header (optional)
330330
* @param string|null $enum_nonref_string_header (optional)
331-
* @param StringEnumRef|null $enum_ref_string_header (optional)
331+
* @param \OpenAPI\Client\Model\StringEnumRef|null $enum_ref_string_header (optional)
332332
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanStringEnums'] to see the possible values for this operation
333333
*
334334
* @throws InvalidArgumentException
@@ -389,7 +389,7 @@ function ($exception) {
389389
* @param bool|null $boolean_header (optional)
390390
* @param string|null $string_header (optional)
391391
* @param string|null $enum_nonref_string_header (optional)
392-
* @param StringEnumRef|null $enum_ref_string_header (optional)
392+
* @param \OpenAPI\Client\Model\StringEnumRef|null $enum_ref_string_header (optional)
393393
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testHeaderIntegerBooleanStringEnums'] to see the possible values for this operation
394394
*
395395
* @throws InvalidArgumentException

samples/client/echo_api/php-nextgen-streaming/src/Api/PathApi.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ public function getConfig(): Configuration
131131
* @param string $path_string path_string (required)
132132
* @param int $path_integer path_integer (required)
133133
* @param string $enum_nonref_string_path enum_nonref_string_path (required)
134-
* @param StringEnumRef $enum_ref_string_path enum_ref_string_path (required)
134+
* @param \OpenAPI\Client\Model\StringEnumRef $enum_ref_string_path enum_ref_string_path (required)
135135
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'] to see the possible values for this operation
136136
*
137137
* @throws ApiException on non-2xx response or if the response body is not in the expected format
@@ -142,7 +142,7 @@ public function testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathE
142142
string $path_string,
143143
int $path_integer,
144144
string $enum_nonref_string_path,
145-
StringEnumRef $enum_ref_string_path,
145+
\OpenAPI\Client\Model\StringEnumRef $enum_ref_string_path,
146146
string $contentType = self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'][0]
147147
): string
148148
{
@@ -158,7 +158,7 @@ public function testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathE
158158
* @param string $path_string (required)
159159
* @param int $path_integer (required)
160160
* @param string $enum_nonref_string_path (required)
161-
* @param StringEnumRef $enum_ref_string_path (required)
161+
* @param \OpenAPI\Client\Model\StringEnumRef $enum_ref_string_path (required)
162162
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'] to see the possible values for this operation
163163
*
164164
* @throws ApiException on non-2xx response or if the response body is not in the expected format
@@ -169,7 +169,7 @@ public function testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathE
169169
string $path_string,
170170
int $path_integer,
171171
string $enum_nonref_string_path,
172-
StringEnumRef $enum_ref_string_path,
172+
\OpenAPI\Client\Model\StringEnumRef $enum_ref_string_path,
173173
string $contentType = self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'][0]
174174
): array
175175
{
@@ -291,7 +291,7 @@ public function testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathE
291291
* @param string $path_string (required)
292292
* @param int $path_integer (required)
293293
* @param string $enum_nonref_string_path (required)
294-
* @param StringEnumRef $enum_ref_string_path (required)
294+
* @param \OpenAPI\Client\Model\StringEnumRef $enum_ref_string_path (required)
295295
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'] to see the possible values for this operation
296296
*
297297
* @throws InvalidArgumentException
@@ -301,7 +301,7 @@ public function testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathE
301301
string $path_string,
302302
int $path_integer,
303303
string $enum_nonref_string_path,
304-
StringEnumRef $enum_ref_string_path,
304+
\OpenAPI\Client\Model\StringEnumRef $enum_ref_string_path,
305305
string $contentType = self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'][0]
306306
): PromiseInterface
307307
{
@@ -321,7 +321,7 @@ function ($response) {
321321
* @param string $path_string (required)
322322
* @param int $path_integer (required)
323323
* @param string $enum_nonref_string_path (required)
324-
* @param StringEnumRef $enum_ref_string_path (required)
324+
* @param \OpenAPI\Client\Model\StringEnumRef $enum_ref_string_path (required)
325325
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'] to see the possible values for this operation
326326
*
327327
* @throws InvalidArgumentException
@@ -380,7 +380,7 @@ function ($exception) {
380380
* @param string $path_string (required)
381381
* @param int $path_integer (required)
382382
* @param string $enum_nonref_string_path (required)
383-
* @param StringEnumRef $enum_ref_string_path (required)
383+
* @param \OpenAPI\Client\Model\StringEnumRef $enum_ref_string_path (required)
384384
* @param string $contentType The value for the Content-Type header. Check self::contentTypes['testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathEnumRefStringPath'] to see the possible values for this operation
385385
*
386386
* @throws InvalidArgumentException

0 commit comments

Comments
 (0)