Problem/Motivation

In Drupal 11 we support both v5 and v6 of justinrainbow/json-schema.

In Drupal 12 we can drop support for v5.

Steps to reproduce

Proposed resolution

Drop support for v5, keep v6 only.

Remaining tasks

Update the constraint in composer.json
Remove the PHPStan ignore in Drupal\jsonapi_response_validator\EventSubscriber\ResourceResponseValidator
Update checks in ComponentValidator and ComponentValidatorTest
Search for any other checks related to the version of the JSON Schema library

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3562477

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

bbrala created an issue. See original summary.

bbrala’s picture

Title: Remove PHPStan ignore in ResourceResponseValidator » Remove PHPStan ignore in ResourceResponseValidator when justinrainbow/json-schema:^5 is dropped
bbrala’s picture

Status: Active » Postponed
longwave’s picture

At the same time, in ComponentValidator:

        // Support 5.0 ($error['constraint']) and 6.0
        // ($error['constraint']['name']) at the same time.
        if (($error['constraint']['name'] ?? $error['constraint'] ?? '') !== 'type') {
          return TRUE;
        }

and ComponentValidatorTest:

        // This is a valid URI but for v5.2 of justinrainbow/json-schema it
        // does not pass validation without a custom constraint for format.
        // We pass a custom factory and it should be used.
        'href' => 'entity:node/1',

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

wim leers’s picture

Indeed, there’s more to be simplified once we no longer support version 5 :)

longwave’s picture

Title: Remove PHPStan ignore in ResourceResponseValidator when justinrainbow/json-schema:^5 is dropped » Drop support for justinrainbow/json-schema:^5
Component: jsonapi.module » composer
Issue summary: View changes
Status: Postponed » Active

Well, let's do this.

bbrala’s picture

and ComponentValidatorTest:

// This is a valid URI but for v5.2 of justinrainbow/json-schema it
// does not pass validation without a custom constraint for format.
// We pass a custom factory and it should be used.
'href' => 'entity:node/1',

Cant really remove the custom validator there?

JsonSchema\Tool\Validator\UriValidator only supports a fixed set of special urls.

        // RFC 3986: Non-Hierarchical URIs (mailto, data, urn, news)
        $nonHierarchicalPattern = '/^
                (mailto|data|urn|news|tel):          # Only allow known non-hierarchical schemes
                (.+)                                 # Must contain at least one character after scheme
        $/ix';

So that would mean we need to change core/modules/system/tests/modules/sdc_test/components/my-cta/my-cta.component.yml to end up in RelativeReferenceValidator which would mean the type should be uriref or uri-reference.

I can change that in the code, but that would kinda mean if there is components with format: uri those might break?

So not too sure about that part.

How to reproduce:

core/tests/Drupal/Tests/Core/Theme/Component/ComponentValidatorTest.php:257

    $component_validator->setValidator(/*new Validator((new Factory())->setConstraintClass('format', UrlHelperFormatConstraint::class))*/);

it will fail.

Then

core/modules/system/tests/modules/sdc_test/components/my-cta/my-cta.component.yml:19

      format: uri-reference

pdureau made their first commit to this issue’s fork.

pdureau’s picture

Sorry, i have pushed a rebase to the fork while I just wanted checking the issue.

quietone’s picture

Issue tags: -Drupal 12
longwave’s picture

We already dropped the dependency on ^5 in #3612963: Drop older dependency versions in Drupal 12, I forgot there was some supporting code here.

quietone’s picture

Status: Active » Needs review
smustgrave’s picture

Status: Needs review » Reviewed & tested by the community

Seems pretty straight forward with teh 5 version dropped already. LGTM.

  • longwave committed 4e63537f on main
    refactor: #3562477 Drop support for justinrainbow/json-schema:^5
    
    By:...
longwave’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed 4e63537fff2 to main. Thanks!

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.

Status: Fixed » Closed (fixed)

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