core icon indicating copy to clipboard operation
core copied to clipboard

Accept absolute URLs for ApiResource URI template.

Open landure opened this issue 4 months ago • 1 comments

Description

If the API use a remote API for a relation (with a local database cache), it would be a nice features for IRIs to point to the resource on the remote API:

Example

use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;

#[ApiResource(
    uriTemplate: 'https://remote.api/custom/api/brands/{id}',
    provider: null,
)]
#[Get]
final readonly class Brand
{

With API Platform 4.1.11, this generates /api/https://remote.api/custom/api/brands/d1d08e37-1234-4567-918c-354b6b210ae1.

It would be nice to allow it to generate https://remote.api/custom/api/brands/d1d08e37-1234-4567-918c-354b6b210ae1

landure avatar Aug 11 '25 13:08 landure

@landure Can you test with

#[ApiResource(
    uriTemplate: '/custom/api/brands/{id}',
    host: 'remote.api',
    urlGenerationStrategy: UrlGeneratorInterface::ABS_URL,
)]
#[Get]
final readonly class Brand
{
``

aaa2000 avatar Nov 26 '25 16:11 aaa2000