forked from loafle/openapi-generator-original
86 lines
2.2 KiB
PHP
86 lines
2.2 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);
|
|
|
|
try {
|
|
$apiResult = $this->api->call123TestSpecialTags($client);
|
|
} catch (\Exception $exception) {
|
|
// This shouldn't happen
|
|
report($exception);
|
|
return response()->json(['error' => $exception->getMessage()], 500);
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|