Problem/Motivation
In #2821554: [FEATURE] Deprecate jsonapi_docson in favor of Schemata. we lost the schemas for our resources. We should go back and have that information added back with the new schemas generated via the Schemata module.
Proposed resolution
Have a contrib module that has support for the JSON API specification using the Schemata module (or a similar technique). The use the reverse patch that removed the schema support in #2821554: [FEATURE] Deprecate jsonapi_docson in favor of Schemata. to add the information back to the resource info.
Additionally we should add a link to the schema in the output as a sibiling of self
.
Comments
Comment #2
Wim LeersIsn't this a duplicate of #2917260: Validate against specific JSON Schemas if Schemata is present?
Assigning to @e0ipso to find out.
Comment #3
gabesulliceThis is not a duplicate. This is about exposing schemas via the API itself. For example, we might have a link like
/jsonapi/node/article/schema
, which would return the schema for node articles.This is important for generic JSON API clients to interact with our API without any foreknowledge of our specific implementation.
Comment #4
Wim LeersOh, interesting! That'd be powerful for https://www.drupal.org/project/openapi!
Comment #5
e0ipsoThis should be "simple" since we're already generating the schemas when validating against them if schemata is present.
For clarity, there is already a way to download / access the schema via a URL using the Schemata module. We could issue a 3xx or respond directly.
Comment #6
Wim LeersThis would only work when the Schemata module is installed, right?
Comment #7
e0ipsoYes.
Comment #8
Wim LeersThen perhaps 3xx redirects with URLs generated using
internal:
rather than using Schemata's routes would work. That way, we don't depend on Schemata at all, and the 3xx response will point to a 404 response, but upon installing the Schemata module, those 404s would become 200s.Comment #9
e0ipsoYeah, that would further simplify the implentation.
+1
Comment #10
Wim LeersComment #11
Wim LeersFYI: this is being discussed in the JSON API spec project: https://github.com/json-api/json-api/issues/1281
Comment #12
e0ipsoThat's really interesting @Wim Leers, thanks for linking that issue. Schema autodiscovery & integration would be a killer feature indeed.
Comment #13
Wim LeersNo problem, I should've linked it a month ago or so, when I first saw it! Sorry for not doing it sooner.
Comment #14
Wim LeersThis is blocked on #2994473: [META] JSON API's normalizers support schema tracking, to guarantee comprehensive schema.
Comment #15
bradjones1Moving to core.