Problem/Motivation
Coexistence is one of the guarantees this module has to make: on a site that already serves a REST API, installing this module must not collide with it. Today the path /api/v1/… is hardcoded in every resource plugin annotation, and the plugin IDs are chosen by hand. Once endpoints are generated from a content model, both become mechanical, and a collision with an existing resource ID or route stops being a theoretical risk.
Proposed resolution
- Add
api_path_prefixtomyrest.settings, defaulting to the current/api/v1, and build routes from it via the route subscriber rather than from the literal in each annotation. - Give generated plugin IDs a configurable namespace so that two generations, or a generation next to a handwritten resource, cannot claim the same ID.
- Detect a collision at scan time and report it rather than at route rebuild, where the error is unreadable.
- Keep the existing paths and IDs byte for byte on the sites that already run this module — the compatibility profile pins them.
Remaining tasks
Everything. This issue is a precondition for the generator: without it, generated resources cannot be installed next to an existing API.
Issue fork myrest-3619185
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #4
sergeydruua commentedComment #6
sergeydruua commented