Attributes, not YAML
Put a few PHP 8 attributes on your controllers. Luminous builds the full OpenAPI 3.2 spec automatically.
Generate OpenAPI 3.2 docs from PHP 8 Attributes. No YAML files to maintain. No docblocks to parse.
The controller you already have, and the OpenAPI it becomes.
#[ApiTag('Payments')]
class PaymentController extends Controller
{
#[ApiOperation('Create a payment')]
#[ApiResponse(201, PaymentResource::class, 'Payment created')]
#[ApiResponse(422, ErrorResource::class, 'Validation failed')]
public function store(CreatePaymentRequest $request): JsonResponse
{
// ...
}
}/api/payments:
post:
tags: [Payments]
summary: Create a payment
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreatePaymentRequest'
responses:
'201':
description: Payment created
content:
application/json:
schema:
$ref: '#/components/schemas/PaymentResource'
'422':
description: Validation failed
content:
application/json:
schema:
$ref: '#/components/schemas/ErrorResource'