Skip to content

feat(metadata): allow stringable objects in descriptions#8207

Open
daniser wants to merge 1 commit into
api-platform:mainfrom
daniser:feat/metadata-stringable-description
Open

feat(metadata): allow stringable objects in descriptions#8207
daniser wants to merge 1 commit into
api-platform:mainfrom
daniser:feat/metadata-stringable-description

Conversation

@daniser
Copy link
Copy Markdown

@daniser daniser commented May 28, 2026

Q A
Branch? main
Tickets N/A
License MIT
Doc PR N/A

Allow stringable objects in descriptions of operations and resources.
The most apparent usage is for localization purposes.

Example (Laravel):

final readonly class Trans implements \Stringable
{
    public function __construct(private string $key, private array $replace = []) {}

    public function __toString(): string
    {
        return trans($this->key, $this->replace);
    }
}

Usage:

#[ApiResource(description: new Trans('resources.airport.index'))]
class Airport
{
    #[ApiProperty(description: new Trans('resources.airport.code'))]
    public string $code;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant