-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Abstract PHP support of "original" for variableNamingConvention #21336
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
Merged
wing328
merged 6 commits into
OpenAPITools:master
from
aghajani:php-off-support-for-variableNamingConvention
Jun 9, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e247de7
feat(php): add support for 'off' variable naming convention in Abstra…
aghajani 8eef1d3
feat(php-laravel): add tests for issue 21334 with API and model defin…
aghajani 05e7311
feat(php-laravel): update variableNamingConvention option in php-lara…
aghajani 4e4c00e
feat: enhance variableNamingConvention options to include 'off' and d…
aghajani c39c62f
feat(php): update variableNamingConvention from 'off' to 'original' i…
aghajani 0b1e14e
feat: include php-laravel-issue-21334 in workflow triggers for push a…
aghajani File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
generatorName: php-laravel | ||
outputDir: samples/server/petstore/php-laravel-issue-21334 | ||
inputSpec: modules/openapi-generator/src/test/resources/3_0/issue21334.yaml | ||
templateDir: modules/openapi-generator/src/main/resources/php-laravel | ||
gitUserId: openapitools | ||
gitRepoId: petstore | ||
additionalProperties: | ||
variableNamingConvention: "original" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
modules/openapi-generator/src/test/resources/3_0/issue21334.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
openapi: 3.0.3 | ||
info: | ||
title: Issue 21334 - Abstract PHP Variable Naming Convention | ||
description: '' | ||
version: 1.0.0 | ||
paths: | ||
/dummy: | ||
get: | ||
description: '' | ||
operationId: getDummy | ||
parameters: | ||
- name: paramCamelCase | ||
in: query | ||
required: false | ||
schema: | ||
type: string | ||
- name: ParamPascalCase | ||
in: query | ||
required: false | ||
schema: | ||
type: string | ||
- name: param_withRandomCase | ||
in: query | ||
required: false | ||
schema: | ||
type: string | ||
responses: | ||
'200': | ||
description: successful operation | ||
components: | ||
schemas: | ||
SampleModelToTestNamingConvention: | ||
type: object | ||
properties: | ||
propCamelCase: | ||
type: string | ||
default: 'defaultName' | ||
PropPascalCase: | ||
type: string | ||
default: 'DefaultName' | ||
Prop_withRandomCase: | ||
type: string | ||
default: 'defaultName' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/vendor/ |
23 changes: 23 additions & 0 deletions
23
samples/server/petstore/php-laravel-issue-21334/.openapi-generator-ignore
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# OpenAPI Generator Ignore | ||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator | ||
|
||
# Use this file to prevent files from being overwritten by the generator. | ||
# The patterns follow closely to .gitignore or .dockerignore. | ||
|
||
# As an example, the C# client generator defines ApiClient.cs. | ||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: | ||
#ApiClient.cs | ||
|
||
# You can match any string of characters against a directory, file or extension with a single asterisk (*): | ||
#foo/*/qux | ||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux | ||
|
||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**): | ||
#foo/**/qux | ||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux | ||
|
||
# You can also negate patterns with an exclamation (!). | ||
# For example, you can ignore all files in a docs folder with the file extension .md: | ||
#docs/*.md | ||
# Then explicitly reverse the ignore rule for a single file: | ||
#!docs/README.md |
9 changes: 9 additions & 0 deletions
9
samples/server/petstore/php-laravel-issue-21334/.openapi-generator/FILES
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.gitignore | ||
Api/DefaultApiInterface.php | ||
Http/Controllers/DefaultController.php | ||
Model/NoContent200.php | ||
Model/SampleModelToTestNamingConvention.php | ||
README.md | ||
composer.json | ||
phpunit.xml.dist | ||
routes.php |
1 change: 1 addition & 0 deletions
1
samples/server/petstore/php-laravel-issue-21334/.openapi-generator/VERSION
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
7.14.0-SNAPSHOT |
42 changes: 42 additions & 0 deletions
42
samples/server/petstore/php-laravel-issue-21334/Api/DefaultApiInterface.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* Issue 21334 - Abstract PHP Variable Naming Convention | ||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | ||
* PHP version 8.1 | ||
* | ||
* The version of the OpenAPI document: 1.0.0 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI-Generator | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
* | ||
* Source files are located at: | ||
* | ||
* > https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/php-laravel/ | ||
*/ | ||
|
||
|
||
namespace OpenAPI\Server\Api; | ||
|
||
|
||
interface DefaultApiInterface { | ||
|
||
|
||
/** | ||
* Operation getDummy | ||
* @param null | string $paramCamelCase | ||
* @param null | string $ParamPascalCase | ||
* @param null | string $param_withRandomCase | ||
* @return \OpenAPI\Server\Model\NoContent200 | ||
*/ | ||
public function getDummy( | ||
?string $paramCamelCase, | ||
?string $ParamPascalCase, | ||
?string $param_withRandomCase, | ||
): | ||
\OpenAPI\Server\Model\NoContent200 | ||
; | ||
|
||
} |
98 changes: 98 additions & 0 deletions
98
samples/server/petstore/php-laravel-issue-21334/Http/Controllers/DefaultController.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* Issue 21334 - Abstract PHP Variable Naming Convention | ||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) | ||
* PHP version 8.1 | ||
* | ||
* The version of the OpenAPI document: 1.0.0 | ||
* | ||
* | ||
* NOTE: This class is auto generated by OpenAPI-Generator | ||
* https://openapi-generator.tech | ||
* Do not edit the class manually. | ||
* | ||
* Source files are located at: | ||
* | ||
* > https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/php-laravel/ | ||
*/ | ||
|
||
|
||
namespace OpenAPI\Server\Http\Controllers; | ||
|
||
use Crell\Serde\SerdeCommon; | ||
use Illuminate\Routing\Controller; | ||
use Illuminate\Http\JsonResponse; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Support\Facades\Validator; | ||
|
||
|
||
use OpenAPI\Server\Api\DefaultApiInterface; | ||
|
||
class DefaultController extends Controller | ||
{ | ||
/** | ||
* Constructor | ||
*/ | ||
public function __construct( | ||
private readonly DefaultApiInterface $api, | ||
private readonly SerdeCommon $serde = new SerdeCommon(), | ||
) | ||
{ | ||
} | ||
|
||
/** | ||
* Operation getDummy | ||
* | ||
* . | ||
* | ||
*/ | ||
public function getDummy(Request $request): JsonResponse | ||
{ | ||
$validator = Validator::make( | ||
array_merge( | ||
[ | ||
|
||
], | ||
$request->all(), | ||
), | ||
[ | ||
'paramCamelCase' => [ | ||
'string', | ||
], | ||
'ParamPascalCase' => [ | ||
'string', | ||
], | ||
'param_withRandomCase' => [ | ||
'string', | ||
], | ||
], | ||
); | ||
|
||
if ($validator->fails()) { | ||
return response()->json(['error' => 'Invalid input'], 400); | ||
} | ||
|
||
$paramCamelCase = $request->string('paramCamelCase')->value(); | ||
|
||
$ParamPascalCase = $request->string('ParamPascalCase')->value(); | ||
|
||
$param_withRandomCase = $request->string('param_withRandomCase')->value(); | ||
|
||
try { | ||
$apiResult = $this->api->getDummy($paramCamelCase, $ParamPascalCase, $param_withRandomCase); | ||
} catch (\Exception $exception) { | ||
// This shouldn't happen | ||
report($exception); | ||
return response()->json(['error' => $exception->getMessage()], 500); | ||
} | ||
|
||
if ($apiResult instanceof \OpenAPI\Server\Model\NoContent200) { | ||
return response()->json($this->serde->serialize($apiResult, format: 'array'), 200); | ||
} | ||
|
||
|
||
// This shouldn't happen | ||
return response()->abort(500); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.