Skip to content

Deeply nested subresources not supported? #5673

Answered by usu
usu asked this question in Q&A
Discussion options

You must be logged in to vote

Looking at the code of LinksHandlerTrait, I figured I can use expandedValue to have LinksHandlerTrait ignoring the uri variable. Below code seems to work - I don't know why, though 🤣

fooId is properly populated into $context['uri_variables'] and I can use a QueryCollectionExtensionInterface to filter the Baz collection by fooId:

#[ApiResource(
    uriTemplate: '/foo/{fooId}/baz.{_format}',
    uriVariables: [
        'fooId' => new Link(
            fromClass: Foo::class,
            expandedValue: "{fooId}"
        ),
    ],
    operations: [
        new GetCollection(),
    ]
)]
class Baz { ... }

The only issue is, that fooId will not appear in OpenAPI documentation as available parameter.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@TNAJanssen
Comment options

@soyuka
Comment options

Answer selected by soyuka
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants