Skip to content

Invalid IRIs in output DTOs #6475

@bpolaszek

Description

@bpolaszek

Discussed in #6473

Originally posted by bpolaszek July 17, 2024
Hello there,

I just noticed that when using DTO output to create a different representation of the resource, the IRI returned by API-Platform is a generated one (as of API-Platform 3.x), instead of the original one (as of API-Platform 2.x).

TL; DR:

When requesting GET /api/books/1, I get

{
  "@type": "BookOutput",
  "@id": "/api/.well-known/genid/b10ecd57cce7b0b65b14"
}

instead of

{
  "@type": "Book",
  "@id": "/api/books/1"
}

After further investigation, I think this is a regression from API-Platform 2.x.
Here's a minimal repository to reproduce the issue:

The final API consumer should not know anything about BookOutput, they should just see a Book with a valid IRI.

Thank you,
Ben

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions