Open API tries to upcast the resource_type parameter, which JSON:API Resource routes do not attach. This causes a crash in Open API. One thing we could do is take the first _jsonapi_resource_types value and set that as the default. It isn't perfect, and still causes issues for custom resource types. But it prevents Open API from crashing.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3109873-2.patch | 1.4 KB | mglaman |
Comments
Comment #2
mglamanI'm not sold on the idea. But here's a patch to at least make it work as a bandaid.
Comment #3
bradjones1This also unlocks
jsonapi_schemahypermedia links withjsonapi_hypermedia.Comment #4
bradjones1Comment #5
dmitry.korhovJSON:API by its specification allows to use polymorphic collections but how can we add it to a custom resource?
Right now only the first type from an array is used.
Can we add callback, somehow, instead of string with
resource_typethat will construct schema for us? Or multipledescribedbystrings are possible?Comment #6
bradjones1OpenAPI for JSON:API is getting a complete rewrite so I think this may no longer be necessary.
Comment #7
ptmkenny commentedSomething to consider: while debugging #3114758: Support JSON:API filters and trying to filter a resource, I was getting lots of errors until I realized that the first element of the array is used as the resource type, as noted in #5. Since
_jsonapi_resource_typesis an array, I had (wrongly) assumed that order didn't matter and put all the types in alphabetical order.It would be great to find a way to make this more clear to devs.
Comment #8
andrewsizz commentedAny update here?
Comment #9
bradjones1If there are updates they will be posted here.