Skip to content

"No item route associated with the type" for an ApiResource that's only available as an ApiSubresource? #4631

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

You must be logged in to vote

For anyone interested in this in the future, I solved it the following way:

  • I set the "composite_identifier" of the "attributes" key of the ApiResource attribute to false. This forces API Platform to use my two database identifiers, "range" and "address" instead of a single default "id" composed of both.

  • I then set the path of the default GET item route to a custom path.

    itemOperations: [
        'get' => [
            'method' => 'GET',
            'path' => '/ranges/{range}/addresses/{address}.{_format}',
        ],
    ],
  • I then ran into issues because an IP address can contain dots, so I set the "identifier" property of "ApiProperty" attribute on $address to false. Then, I…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by kevinreniers
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants