[wp-trac] [WordPress Trac] #51757: REST API: Add const validation
WordPress Trac
noreply at wordpress.org
Fri Nov 13 01:16:21 UTC 2020
#51757: REST API: Add const validation
-----------------------------------+------------------------------
Reporter: ajlende | Owner: (none)
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version:
Severity: normal | Resolution:
Keywords: has-patch json-schema | Focuses:
-----------------------------------+------------------------------
Comment (by TimothyBlynJacobs):
> we're already not strictly spec compliant for v4—there are gotchas like
assuming the top-level array is properties, assuming 'type' => 'object' at
the top-level
An important thing about this, is that this assumption is only baked into
`rest_get_endpoint_args_for_schema()`. Our underlying schema validators
don't make this assumption.
> and using the required boolean for individual properties
Yeah this is the v3 syntax. We do support the v4 syntax now at a nested
level. But I'd like to support it at the controller schema level too.
One of the things I'd like to get to is for the route to actually be aware
of the schema as an args definition. Right now we validate using whatever
is in `args` and that only contains the properties definition. So we don't
have the `$schema` keyword available, or the actual top level type of the
resource, etc... If we were able to capture that properly in the schema,
we could then make `rest_validate_value_from_schema` and friends aware of
the schema version.
I'd like to try and tackle that in WP 5.7. Both so we could explore things
like v6 features, but also so we could support some really important v4
features like `$ref` which also require the whole schema as context.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/51757#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list