Files
openapi-generator/samples/server/petstore/php-laravel/Http/Controllers/AnotherFakeController.php
William Cheng 87231c3b58 [php][php-nextgen] add new github workflow to perform syntax check on php files (#21678)
* update php laravel samples

* add php-nextgen to the github workflow

* trigger build failure

* add syntax checker workflow

* Revert "trigger build failure"

This reverts commit 5be28f2e768cb22d9edca83ec897cbaa9cf296e9.
2025-08-01 17:48:04 +08:00

81 lines
2.0 KiB
PHP

<?php declare(strict_types=1);
/**
* OpenAPI Petstore
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
* 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\AnotherFakeApiInterface;
class AnotherFakeController extends Controller
{
/**
* Constructor
*/
public function __construct(
private readonly AnotherFakeApiInterface $api,
private readonly SerdeCommon $serde = new SerdeCommon(),
)
{
}
/**
* Operation call123TestSpecialTags
*
* To test special tags.
*
*/
public function call123TestSpecialTags(Request $request): JsonResponse
{
$validator = Validator::make(
array_merge(
[
],
$request->all(),
),
[
],
);
if ($validator->fails()) {
return response()->json(['error' => 'Invalid input'], 400);
}
$client = $this->serde->deserialize($request->getContent(), from: 'json', to: \OpenAPI\Server\Model\Client::class);
$apiResult = $this->api->call123TestSpecialTags($client);
if ($apiResult instanceof \OpenAPI\Server\Model\Client) {
return response()->json($this->serde->serialize($apiResult, format: 'array'), 200);
}
// This shouldn't happen
return response()->abort(500);
}
}