I have a GET endpoint that is not related to any entity. The endpoint returns the European VAT rate for a given date. I need to add a parameter named date with the type date (which should return a \DateTime object, for example).
I've successfully added other types of parameters but I'm struggling with this:
#[ApiResource(
shortName: 'VAT',
routePrefix: 'EU-vat',
operations: [
new Get(
name: 'vat_get',
uriTemplate: '/get-rate/{country_code}',
uriVariables: [
'country_code' => new Link(
description: 'ISO 3166-1 alpha-2 country code',
schema: [
'type' => 'string',
'example' => 'IT',
],
),
],
parameters: [
// Add the date parameter
],
output: GetVatRateResult::class,
provider: VatStateProvider::class,
),
],
)]
class Vat
{
}
Adding a simple QueryParameter and specify date as schema doesn't work:
parameters: [
'date' => new QueryParameter(
description: 'The date for which to retrieve the VAT rate',
schema: [
'type' => 'date',
],
),
],
The documentation lists the type as any, so it isn't recognized and the widget is rendered as a plain text field:
