Just discussed with @e0ipso, @gabesullice, @tedbow and I on the weekly API-First call:

  1. Remove file download URL work-around (because unnecessary in 8.5): #2929932: Work around core's ill-designed @FieldType-level TimestampItemNormalizer normalization until #2926508 lands
  2. Enforce >=8.5, which will allow us to drop some BC code (specially around isInternal features).
  3. Move config entity POST/PATCH/DELETE support to jsonapi_extras (because not ready for prime time): #2887313: JSON API indicates it supports POST/PATCH/DELETE of config entity types, but that's impossible +
    #2957474: Move the write functionality of config entities to a sub-module in preparation for removal
  4. Move EntityToJsonApi service to jsonapi_extras to consolidate the feature and have more flexibility to evolve that API. This will also have the benefit to remove the only public service from the module, leaving all the PHP API as internal. #2958504: Stop using jsonapi.entity.to_jsonapi service in ResourceTestBase #2982210: Move EntityToJsonApi service to JSON API Extras
  5. Relatively minor things that can happen once we require 8.5:
  6. #2971040: PHP 7.1 Compatibility Warning

Doing this blocks #2931785: The path for JSON API to core.

We agreed to wait a week or so, to let this sink in, and surface other things.

Comments

Wim Leers created an issue. See original summary.

e0ipso’s picture

Issue summary: View changes

Minor IS edits.

wim leers’s picture

#2++

gabesullice’s picture

Let's add the link manager to the list. It is currently @deprecated, but should be @internal.

I won't add it to the IS. So, if another maintainer agrees, please just do so :)

wim leers’s picture

#4++

e0ipso’s picture

#4 will $entity->toUrl('api_json') just work for other other modules to create HATEOAS links?

gabesullice’s picture

@e0ipso

That is blocked by: #2878463: [PP-1] Define a JSON API link relation for entities
which is blocked by: #2353611: Make it possible to link to an entity by UUID

However, modules can use:
Url::fromRoute('entity.node--page.individual', ['node' => $node->uuid()]);

FWIW, I completely agree that there should be a good way to get JSON API HATEOAS links, the possibilities there are really promising.

The LinkManager has been deprecated for a while now though. In fact, I think at one point you agreed with me that it should be @internal, but it seems we only marked it @deprecated instead.

gabesullice’s picture

While we're on the topic of "things we'd like to break"...

GET /jsonap/node/article/uuid

ought to be

GET /jsonap/node--article/uuid

The latter is much more conventional and will unify our resource type names across the module. This would also make the entrypoint a little nicer.

The former continues to imply that we treat 'articles' and 'pages' as a child of 'node' rather than as siblings.

This breaks the spec recommendation to treat URLs as though they're they're part of a reference document.

I believe the current implementation is a holdover from early days of the module when we had shakier UUID support and no concept of a ResourceType.

Edit: Adding a more radical idea (because it's almost 1am and I'm feeling impulsive) s/node--article/node:article/g simply because it's aesthetically pleasing

e0ipso’s picture

#8: I'd like to separate that one since it's incredibly disruptive to ALL existing installations without gaining us a feature or a fixing a bug. Maybe open a new issue for discussion?


#7:

The LinkManager has been deprecated for a while now though. In fact, I think at one point you agreed with me that it should be @internal, but it seems we only marked it @deprecated instead.

Yeah. My comment was more on the lines of what to recommend instead, and not let's hold that off. However I do feel we should not recommend using route names to generate links. They are an internal implementation detail that is not guaranteed to stay as is. IMO toUrl should be the way to go.

gabesullice’s picture

I'd like to separate that one since it's incredibly disruptive to ALL existing installations without gaining us a feature or a fixing a bug. Maybe open a new issue for discussion?

Ah! I should have said that this could easily be handled with a BC flag. Then it wouldn't break any sites.

A few features this would buy us: conventions, less confusion, following a spec recommendation, compatibility with existing JS clients like Orbit.js which almost always template the URL by using the type name.

#2949635: Make the resource type aware of the resource path is what have me the hope that we could do this.

I'm a little surprised because JSON API Extras has been altering the path for quite some time (although not with the new method). In fact, it's probably one of it's most used features.

I don't think it's necessary to go into a separate issue, that implies a really long running discussion. Which I really don't think is necessary.


This brings up a good point though, we should try our best to make the upgrade path as smooth and painless as possible.


Yeah. My comment was more on the lines of what to recommend instead, and not let's hold that off. However I do feel we should not recommend using route names to generate links. They are an internal implementation detail that is not guaranteed to stay as is. IMO toUrl should be the way to go.

👍

wim leers’s picture

#8: I like it, but it's massively disruptive of course.

#10: handling this with a BC flag is doable. But … you say that this gets us more conventions, less confusion. This is only going to be true for those that don't have this BC layer enabled. For everybody else, there's going to be confusing/conflicting documentation!
Now I'm going to contradict myself: it's actually even possible to provide BC for this without a BC flag: with a InboundPathProcessorInterface implementation, much like \Drupal\rest\PathProcessor\PathProcessorEntityResourceBC, we could just rewrite incoming URLs and have this work transparently! We can then remove it in a far future version, for example version 3. Something like this should work:

class JsonApiPathBC implements InboundPathProcessorInterface {

  /**
   * {@inheritdoc}
   */
  public function processInbound($path, Request $request) {
    if (strpos($path, '/jsonapi/') === 0) {
      $parts = explode('/', $path);
      // Rewrite ap old JSON API paths to new ones:
      // - from: /jsonapi/node/article/UUID
      // - to: /jsonapi/node:article/UUID
      if (count($parts) === 4) {
        return sprintf('/%s/%s:%s/%s', $parts[0], $parts[1], $parts[2], $parts[3]);
      }
    }
  }

}
e0ipso’s picture

I believe fiercely on no BC shenanigans, specially for no gain. I still don't see what benefit this brings. I think it's just fine as it is and should not be modified.

wim leers’s picture

I think I agree with you, @e0ipso. The benefit seems very small. Until we hear people actually complain about this, this is probably fine.

wim leers’s picture

So did we agree that LinkManager should be marked @internal in the next major?

e0ipso’s picture

#15 yes, I believe so.

gabesullice’s picture

Just gonna chime in and say I'm fine with not doing #8. I still think it would be nice. But it's small enough to say, "forget about it" :)

bojanz’s picture

Why would dropping support for unmaintained Drupal core versions require a new major?
I have enforced the "current core branch" requirement on most my modules (Commerce, Address) with no problems.

e0ipso’s picture

@bojanz we support all the supported versions, which is IIRC >=current-1. In any case the major includes a good bunch of other stuff as well, not just the core requirements.

I'm interested to hear your impressions on upgrade speed from site owners. Are they upgrading core quickly from your perception?

BTW it's awesome to see you around this issue queue.

gabesullice’s picture

FTR only, prior minor versions are not supported.

Previous minor releases will become unsupported when a new minor release is published.

See: https://www.drupal.org/core/release-cycle-overview

I only know this now because I heard @xjm say this was a common misconception the other day.

IDC about whether we support only the current or the previous one too.

wim leers’s picture

Apparently the 8.x-2.x branch was created?

wim leers’s picture

wim leers’s picture

@dawehner explicitly asked in #2843147-60: Add JSON:API to core as a stable module to do #2926463: [>=8.5] Remove JSON API's "file URL" field work-around now that Drupal core 8.5 fixed it and remove the jsonapi.entity.to_jsonapi service before JSON API is moved into core. This further stresses the need for v2.

wim leers’s picture

And #2958504: Stop using jsonapi.entity.to_jsonapi service in ResourceTestBase is an issue that paves the path for

  1. Move EntityToJsonApi service to jsonapi_extras to consolidate the feature and have more flexibility to evolve that API. This will also have the benefit to remove the only public service from the module, leaving all the PHP API as internal.
wim leers’s picture

wim leers’s picture

Version: 8.x-1.x-dev » 8.x-2.x-dev
wim leers’s picture

I think #2942549: Spec Compliance: JSON API allows POSTing relationship fields in 'attributes' rather than in 'relationships' is perhaps another relatively minor bug that we should only fix in 2.x, to minimize breakage (despite our clear statements in jsonapi.api.php about spec compatibility).

gabesullice’s picture

#27++

wim leers’s picture

wim leers’s picture

wim leers’s picture

Issue summary: View changes

#2982210: Move EntityToJsonApi service to JSON API Extras is now the actual issue for

  1. Move EntityToJsonApi service to jsonapi_extras to consolidate the feature and have more flexibility to evolve that API. This will also have the benefit to remove the only public service from the module, leaving all the PHP API as internal.
wim leers’s picture

Issue summary: View changes
Status: Active » Fixed

The 2.x branch has started. The majority of the issues listed above have already been committed!

wim leers’s picture

Issue tags: +API-First Initiative

Status: Fixed » Closed (fixed)

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