JSON API Extras @ResourceFieldEnhancer plugins should indicate to which field types they apply

Created on 11 December 2017, over 7 years ago
Updated 12 August 2025, 18 days ago

Problem/Motivation

Quoting @szeidler at #2921612: DateTimeEnhancer only work with Unix Timestamp fields :

Unfortunately it seems, that we do not have information about the field type at that time of processing, but as an workaround we might assume, that numeric values are timestamps.

This … sounds like a huge flaw in the @ResourceFieldEnhancer concept.

For pure structure-based enhancers like \Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancer\SingleNestedEnhancer, it makes sense to not be associated with a field type. But for most others, it doesn't make sense:

  1. \Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancer\DateTimeEnhancer
  2. \Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancer\DateTimeFromStringEnhancer
  3. \Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancer\UuidLinkEnhancer

A consequence is that without field type information, these field enhancers also cannot automatically update API docs such as https://www.drupal.org/project/openapi (marking critical for this reason).

Proposed resolution

TBD

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Closed: won't fix

Version

1.0

Component

Code

Created by

🇧🇪Belgium wim leers Ghent 🇧🇪🇪🇺

Live updates comments and jobs are added and updated live.
  • Documentation

    Primarily changes documentation, not code. For Drupal core issues, select the Documentation component instead of using this tag. In general, component selection is preferred over tag selection.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇬🇧United Kingdom joachim

    > If you have a textfield that contains an unix timestamp field, you should be able to enhance it.

    True.

    But some enhancers do expect a specific field type. E.g. the EntityShareUuidLinkEnhancer in Entity Share module expects to find a 'uri' property.

    So *some* enhancers could specify a field type, and some could be universal.

Production build 0.71.5 2024