Problem/Motivation

In order to resolve #2735665: [BUGFIX] Name collision with bundles with same name we need to move the bundle level resources namespaced under the entity type.

Proposed resolution

Fix the path routes and refactor the tests to reflect the change.

API changes

Resources will be moved under a new route from now on.

Comments

e0ipso created an issue. See original summary.

e0ipso’s picture

dawehner’s picture

+1 for chosing /{entity_type_id}/{bundle}/{id}. If people care they could create aliases or so.

e0ipso’s picture

Status: Active » Needs review
StatusFileSize
new1.51 KB

Added patch.

I'm not sure how I feel about entities with a single bundle. I guess that I will have better visibility when I work on #2751527: [FEATURE] Create entity level resources.

e0ipso’s picture

StatusFileSize
new11.92 KB
new11.78 KB

Namespace the type as well.

  • dawehner committed d517ec8 on 8.x-1.x authored by e0ipso
    Issue #2751525 by e0ipso: [FEATURE] Move the resources to /{...
dawehner’s picture

Looks perfect for me. One thing we could discuss later is whether we want to treat entity types without bundles (like many config ones) in a special way.

dawehner’s picture

Status: Needs review » Fixed
e0ipso’s picture

I'm not sure how I feel about entities with a single bundle.

One thing we could discuss later is whether we want to treat entity types without bundles (like many config ones) in a special way.

The problem I see is BC with the API when the 2nd bundle is introduced and the API already has some consumers implemented around the special single-bundle case. Is there an entity definition that does not accept bundles at all?

dawehner’s picture

The problem I see is BC with the API when the 2nd bundle is introduced and the API already has some consumers implemented around the special single-bundle case. Is there an entity definition that does not accept bundles at all?

Given \Drupal\Core\Entity\ContentEntityBase::bundle I'm wondering whether its safe to check whether the 'bundle' entity type exists.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

dremy’s picture

It may be that the README.md needs to be updated or somethings not working, however when I navigate to a test article at:

  • /node/article/1?_format=api_json
  • /api/article/1?_format=api_json
  • /api/node/article/1?_format=api_json

None of these or any of the other illustrated paths work. This is using the most recent jsonapi dev download with all modules (serializiation, rest web services, and even restui) installed on a clean updated pantheon d8 build (8.1.7).

Instead I get messoges like:

{
message: "No route found for "GET /api/article/1""
}

e0ipso’s picture

@dremy the README may need some love, it's outdated. Maybe you'll want to send a patch on that.

Unless you explicitly change that, you'll need to use the UUID instead of the entity ID. See https://www.youtube.com/watch?v=K58Zou9zA9o&list=PLZOQ_ZMpYrZsyO-3IstImK...

You can list the articles by going to /api/node/article?_format=api_json and use the UUID, as shown in the video.

dremy’s picture

Yup. I'll create a new issue and update.