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_prefix to myrest.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

Command icon 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

sergeydruua created an issue. See original summary.

  • sergeydruua committed 15f9c35c on 1.0.x
    Issue #3619185: Make the API path prefix and the generated plugin IDs...
sergeydruua’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

sergeydruua’s picture

Status: Fixed » Closed (fixed)