Problem/Motivation

jsonapi_views breaks openapi resource export/download with unexpected error.

Steps to reproduce

Enable jsonapi_views and then try to download resource json from "admin/config/services/openapi"

Proposed resolution

Resource type key is missing from jsonapi_views generated routes.

Remaining tasks

-

User interface changes

-

API changes

-

Data model changes

-

CommentFileSizeAuthor
#2 3265781-2.patch1.39 KBvarshith
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

varshith created an issue. See original summary.

varshith’s picture

Assigned: varshith » Unassigned
Status: Active » Needs review
StatusFileSize
new1.39 KB

Adding the resource type to route defaults fixes this. I am attaching a patch that works for me.

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

anybody’s picture

Thanks @varshith I turned #2 into a MR to push things forward. Maybe someone using openapi could confirm the fix / workaround?

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

deciphered changed the visibility of the branch 8.x-1.x to hidden.

deciphered’s picture

Thanks @varshith for finding the missing resource-type route default. Thanks @anybody for opening MR !18 from it.

MR !18's fix sets a fake resource type, ResourceType('view', 'view', ...), on every view's route. Testing it against a real openapi_jsonapi install showed every view gets the same generic "View" tag and no schema in the OpenAPI output, not real documentation. The crash in this issue also does not reproduce on current openapi/openapi_jsonapi releases: their own getPaths() method already skips routes with no resource_type default, a guard that landed in 2020 for their issue #3173177, before this issue was filed.

A separate MR takes a different approach: a view can have more than one bundle, so a single resource_type default only has one correct answer when the view has exactly one bundle. That MR sets the real type in that case, and leaves the default unset for views spanning several bundles, since no single type is correct there. Kernel tests cover both cases, plus a bundle with no matching resource type.

  • deciphered committed 4b175743 on 8.x-1.x
    fix(#3265781): add resource type route default for single-bundle views
    
deciphered’s picture

Status: Needs review » Fixed

Fixed and committed for a 8.x-1.2 release.

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.