Skip to content

Commit f6146b2

Browse files
authored
[PHP] better operationId handling, add CI for PHP slim server (#723)
* better operationId handling, add CI for PHP slim * use spaces instead of tabs * replace tab with space * install php
1 parent 2b429ee commit f6146b2

17 files changed

Lines changed: 124 additions & 60 deletions

File tree

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
@@ -496,6 +496,12 @@ public String toOperationId(String operationId) {
496496
operationId = "call_" + operationId;
497497
}
498498

499+
// operationId starts with a number
500+
if (operationId.matches("^\\d.*")) {
501+
LOGGER.warn(operationId + " (starting with a number) cannot be used as method name. Renamed to " + camelize(sanitizeName("call_" + operationId), true));
502+
operationId = "call_" + operationId;
503+
}
504+
499505
return camelize(sanitizeName(operationId), true);
500506
}
501507

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -982,6 +982,7 @@
982982
<module>samples/server/petstore/spring-mvc</module>
983983
<module>samples/server/petstore/spring-mvc-j8-async</module>
984984
<module>samples/server/petstore/spring-mvc-j8-localdatetime</module>
985+
<module>samples/server/petstore/php-slim</module>
985986
</modules>
986987
</profile>
987988
</profiles>

samples/client/petstore/php/OpenAPIClient-php/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ $apiInstance = new OpenAPI\Client\Api\AnotherFakeApi(
6464
$client = new \OpenAPI\Client\Model\Client(); // \OpenAPI\Client\Model\Client | client model
6565

6666
try {
67-
$result = $apiInstance->123testSpecialTags($client);
67+
$result = $apiInstance->call123TestSpecialTags($client);
6868
print_r($result);
6969
} catch (Exception $e) {
70-
echo 'Exception when calling AnotherFakeApi->123testSpecialTags: ', $e->getMessage(), PHP_EOL;
70+
echo 'Exception when calling AnotherFakeApi->call123TestSpecialTags: ', $e->getMessage(), PHP_EOL;
7171
}
7272

7373
?>
@@ -79,7 +79,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
7979

8080
Class | Method | HTTP request | Description
8181
------------ | ------------- | ------------- | -------------
82-
*AnotherFakeApi* | [**123testSpecialTags**](docs/Api/AnotherFakeApi.md#123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
82+
*AnotherFakeApi* | [**call123TestSpecialTags**](docs/Api/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
8383
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/Api/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
8484
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/Api/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite |
8585
*FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number |

samples/client/petstore/php/OpenAPIClient-php/docs/Api/AnotherFakeApi.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7-
[**123testSpecialTags**](AnotherFakeApi.md#123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
7+
[**call123TestSpecialTags**](AnotherFakeApi.md#call123TestSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
88

99

10-
# **123testSpecialTags**
11-
> \OpenAPI\Client\Model\Client 123testSpecialTags($client)
10+
# **call123TestSpecialTags**
11+
> \OpenAPI\Client\Model\Client call123TestSpecialTags($client)
1212
1313
To test special tags
1414

@@ -27,10 +27,10 @@ $apiInstance = new OpenAPI\Client\Api\AnotherFakeApi(
2727
$client = new \OpenAPI\Client\Model\Client(); // \OpenAPI\Client\Model\Client | client model
2828

2929
try {
30-
$result = $apiInstance->123testSpecialTags($client);
30+
$result = $apiInstance->call123TestSpecialTags($client);
3131
print_r($result);
3232
} catch (Exception $e) {
33-
echo 'Exception when calling AnotherFakeApi->123testSpecialTags: ', $e->getMessage(), PHP_EOL;
33+
echo 'Exception when calling AnotherFakeApi->call123TestSpecialTags: ', $e->getMessage(), PHP_EOL;
3434
}
3535
?>
3636
```

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function getConfig()
8888
}
8989

9090
/**
91-
* Operation 123testSpecialTags
91+
* Operation call123TestSpecialTags
9292
*
9393
* To test special tags
9494
*
@@ -98,14 +98,14 @@ public function getConfig()
9898
* @throws \InvalidArgumentException
9999
* @return \OpenAPI\Client\Model\Client
100100
*/
101-
public function 123testSpecialTags($client)
101+
public function call123TestSpecialTags($client)
102102
{
103-
list($response) = $this->123testSpecialTagsWithHttpInfo($client);
103+
list($response) = $this->call123TestSpecialTagsWithHttpInfo($client);
104104
return $response;
105105
}
106106

107107
/**
108-
* Operation 123testSpecialTagsWithHttpInfo
108+
* Operation call123TestSpecialTagsWithHttpInfo
109109
*
110110
* To test special tags
111111
*
@@ -115,9 +115,9 @@ public function 123testSpecialTags($client)
115115
* @throws \InvalidArgumentException
116116
* @return array of \OpenAPI\Client\Model\Client, HTTP status code, HTTP response headers (array of strings)
117117
*/
118-
public function 123testSpecialTagsWithHttpInfo($client)
118+
public function call123TestSpecialTagsWithHttpInfo($client)
119119
{
120-
$request = $this->123testSpecialTagsRequest($client);
120+
$request = $this->call123TestSpecialTagsRequest($client);
121121

122122
try {
123123
$options = $this->createHttpClientOption();
@@ -199,7 +199,7 @@ public function 123testSpecialTagsWithHttpInfo($client)
199199
}
200200

201201
/**
202-
* Operation 123testSpecialTagsAsync
202+
* Operation call123TestSpecialTagsAsync
203203
*
204204
* To test special tags
205205
*
@@ -208,9 +208,9 @@ public function 123testSpecialTagsWithHttpInfo($client)
208208
* @throws \InvalidArgumentException
209209
* @return \GuzzleHttp\Promise\PromiseInterface
210210
*/
211-
public function 123testSpecialTagsAsync($client)
211+
public function call123TestSpecialTagsAsync($client)
212212
{
213-
return $this->123testSpecialTagsAsyncWithHttpInfo($client)
213+
return $this->call123TestSpecialTagsAsyncWithHttpInfo($client)
214214
->then(
215215
function ($response) {
216216
return $response[0];
@@ -219,7 +219,7 @@ function ($response) {
219219
}
220220

221221
/**
222-
* Operation 123testSpecialTagsAsyncWithHttpInfo
222+
* Operation call123TestSpecialTagsAsyncWithHttpInfo
223223
*
224224
* To test special tags
225225
*
@@ -228,10 +228,10 @@ function ($response) {
228228
* @throws \InvalidArgumentException
229229
* @return \GuzzleHttp\Promise\PromiseInterface
230230
*/
231-
public function 123testSpecialTagsAsyncWithHttpInfo($client)
231+
public function call123TestSpecialTagsAsyncWithHttpInfo($client)
232232
{
233233
$returnType = '\OpenAPI\Client\Model\Client';
234-
$request = $this->123testSpecialTagsRequest($client);
234+
$request = $this->call123TestSpecialTagsRequest($client);
235235

236236
return $this->client
237237
->sendAsync($request, $this->createHttpClientOption())
@@ -271,19 +271,19 @@ function ($exception) {
271271
}
272272

273273
/**
274-
* Create request for operation '123testSpecialTags'
274+
* Create request for operation 'call123TestSpecialTags'
275275
*
276276
* @param \OpenAPI\Client\Model\Client $client client model (required)
277277
*
278278
* @throws \InvalidArgumentException
279279
* @return \GuzzleHttp\Psr7\Request
280280
*/
281-
protected function 123testSpecialTagsRequest($client)
281+
protected function call123TestSpecialTagsRequest($client)
282282
{
283283
// verify the required parameter 'client' is set
284284
if ($client === null || (is_array($client) && count($client) === 0)) {
285285
throw new \InvalidArgumentException(
286-
'Missing the required parameter $client when calling 123testSpecialTags'
286+
'Missing the required parameter $client when calling call123TestSpecialTags'
287287
);
288288
}
289289

samples/client/petstore/php/OpenAPIClient-php/test/Api/AnotherFakeApiTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ public static function tearDownAfterClass()
7272
}
7373

7474
/**
75-
* Test case for 123testSpecialTags
75+
* Test case for call123TestSpecialTags
7676
*
7777
* To test special tags.
7878
*
7979
*/
80-
public function test123testSpecialTags()
80+
public function testCall123TestSpecialTags()
8181
{
8282
}
8383
}

samples/openapi3/client/petstore/php/OpenAPIClient-php/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ $apiInstance = new OpenAPI\Client\Api\AnotherFakeApi(
6464
$client = new \OpenAPI\Client\Model\Client(); // \OpenAPI\Client\Model\Client | client model
6565

6666
try {
67-
$result = $apiInstance->123testSpecialTags($client);
67+
$result = $apiInstance->call123TestSpecialTags($client);
6868
print_r($result);
6969
} catch (Exception $e) {
70-
echo 'Exception when calling AnotherFakeApi->123testSpecialTags: ', $e->getMessage(), PHP_EOL;
70+
echo 'Exception when calling AnotherFakeApi->call123TestSpecialTags: ', $e->getMessage(), PHP_EOL;
7171
}
7272

7373
?>
@@ -79,7 +79,7 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
7979

8080
Class | Method | HTTP request | Description
8181
------------ | ------------- | ------------- | -------------
82-
*AnotherFakeApi* | [**123testSpecialTags**](docs/Api/AnotherFakeApi.md#123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
82+
*AnotherFakeApi* | [**call123TestSpecialTags**](docs/Api/AnotherFakeApi.md#call123testspecialtags) | **PATCH** /another-fake/dummy | To test special tags
8383
*FakeApi* | [**fakeOuterBooleanSerialize**](docs/Api/FakeApi.md#fakeouterbooleanserialize) | **POST** /fake/outer/boolean |
8484
*FakeApi* | [**fakeOuterCompositeSerialize**](docs/Api/FakeApi.md#fakeoutercompositeserialize) | **POST** /fake/outer/composite |
8585
*FakeApi* | [**fakeOuterNumberSerialize**](docs/Api/FakeApi.md#fakeouternumberserialize) | **POST** /fake/outer/number |

samples/openapi3/client/petstore/php/OpenAPIClient-php/docs/Api/AnotherFakeApi.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ All URIs are relative to *http://petstore.swagger.io:80/v2*
44

55
Method | HTTP request | Description
66
------------- | ------------- | -------------
7-
[**123testSpecialTags**](AnotherFakeApi.md#123testSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
7+
[**call123TestSpecialTags**](AnotherFakeApi.md#call123TestSpecialTags) | **PATCH** /another-fake/dummy | To test special tags
88

99

10-
# **123testSpecialTags**
11-
> \OpenAPI\Client\Model\Client 123testSpecialTags($client)
10+
# **call123TestSpecialTags**
11+
> \OpenAPI\Client\Model\Client call123TestSpecialTags($client)
1212
1313
To test special tags
1414

@@ -27,10 +27,10 @@ $apiInstance = new OpenAPI\Client\Api\AnotherFakeApi(
2727
$client = new \OpenAPI\Client\Model\Client(); // \OpenAPI\Client\Model\Client | client model
2828

2929
try {
30-
$result = $apiInstance->123testSpecialTags($client);
30+
$result = $apiInstance->call123TestSpecialTags($client);
3131
print_r($result);
3232
} catch (Exception $e) {
33-
echo 'Exception when calling AnotherFakeApi->123testSpecialTags: ', $e->getMessage(), PHP_EOL;
33+
echo 'Exception when calling AnotherFakeApi->call123TestSpecialTags: ', $e->getMessage(), PHP_EOL;
3434
}
3535
?>
3636
```

samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/AnotherFakeApi.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function getConfig()
8888
}
8989

9090
/**
91-
* Operation 123testSpecialTags
91+
* Operation call123TestSpecialTags
9292
*
9393
* To test special tags
9494
*
@@ -98,14 +98,14 @@ public function getConfig()
9898
* @throws \InvalidArgumentException
9999
* @return \OpenAPI\Client\Model\Client
100100
*/
101-
public function 123testSpecialTags($client)
101+
public function call123TestSpecialTags($client)
102102
{
103-
list($response) = $this->123testSpecialTagsWithHttpInfo($client);
103+
list($response) = $this->call123TestSpecialTagsWithHttpInfo($client);
104104
return $response;
105105
}
106106

107107
/**
108-
* Operation 123testSpecialTagsWithHttpInfo
108+
* Operation call123TestSpecialTagsWithHttpInfo
109109
*
110110
* To test special tags
111111
*
@@ -115,9 +115,9 @@ public function 123testSpecialTags($client)
115115
* @throws \InvalidArgumentException
116116
* @return array of \OpenAPI\Client\Model\Client, HTTP status code, HTTP response headers (array of strings)
117117
*/
118-
public function 123testSpecialTagsWithHttpInfo($client)
118+
public function call123TestSpecialTagsWithHttpInfo($client)
119119
{
120-
$request = $this->123testSpecialTagsRequest($client);
120+
$request = $this->call123TestSpecialTagsRequest($client);
121121

122122
try {
123123
$options = $this->createHttpClientOption();
@@ -199,7 +199,7 @@ public function 123testSpecialTagsWithHttpInfo($client)
199199
}
200200

201201
/**
202-
* Operation 123testSpecialTagsAsync
202+
* Operation call123TestSpecialTagsAsync
203203
*
204204
* To test special tags
205205
*
@@ -208,9 +208,9 @@ public function 123testSpecialTagsWithHttpInfo($client)
208208
* @throws \InvalidArgumentException
209209
* @return \GuzzleHttp\Promise\PromiseInterface
210210
*/
211-
public function 123testSpecialTagsAsync($client)
211+
public function call123TestSpecialTagsAsync($client)
212212
{
213-
return $this->123testSpecialTagsAsyncWithHttpInfo($client)
213+
return $this->call123TestSpecialTagsAsyncWithHttpInfo($client)
214214
->then(
215215
function ($response) {
216216
return $response[0];
@@ -219,7 +219,7 @@ function ($response) {
219219
}
220220

221221
/**
222-
* Operation 123testSpecialTagsAsyncWithHttpInfo
222+
* Operation call123TestSpecialTagsAsyncWithHttpInfo
223223
*
224224
* To test special tags
225225
*
@@ -228,10 +228,10 @@ function ($response) {
228228
* @throws \InvalidArgumentException
229229
* @return \GuzzleHttp\Promise\PromiseInterface
230230
*/
231-
public function 123testSpecialTagsAsyncWithHttpInfo($client)
231+
public function call123TestSpecialTagsAsyncWithHttpInfo($client)
232232
{
233233
$returnType = '\OpenAPI\Client\Model\Client';
234-
$request = $this->123testSpecialTagsRequest($client);
234+
$request = $this->call123TestSpecialTagsRequest($client);
235235

236236
return $this->client
237237
->sendAsync($request, $this->createHttpClientOption())
@@ -271,19 +271,19 @@ function ($exception) {
271271
}
272272

273273
/**
274-
* Create request for operation '123testSpecialTags'
274+
* Create request for operation 'call123TestSpecialTags'
275275
*
276276
* @param \OpenAPI\Client\Model\Client $client client model (required)
277277
*
278278
* @throws \InvalidArgumentException
279279
* @return \GuzzleHttp\Psr7\Request
280280
*/
281-
protected function 123testSpecialTagsRequest($client)
281+
protected function call123TestSpecialTagsRequest($client)
282282
{
283283
// verify the required parameter 'client' is set
284284
if ($client === null || (is_array($client) && count($client) === 0)) {
285285
throw new \InvalidArgumentException(
286-
'Missing the required parameter $client when calling 123testSpecialTags'
286+
'Missing the required parameter $client when calling call123TestSpecialTags'
287287
);
288288
}
289289

samples/openapi3/client/petstore/php/OpenAPIClient-php/test/Api/AnotherFakeApiTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ public static function tearDownAfterClass()
7272
}
7373

7474
/**
75-
* Test case for 123testSpecialTags
75+
* Test case for call123TestSpecialTags
7676
*
7777
* To test special tags.
7878
*
7979
*/
80-
public function test123testSpecialTags()
80+
public function testCall123TestSpecialTags()
8181
{
8282
}
8383
}

0 commit comments

Comments
 (0)