-
Notifications
You must be signed in to change notification settings - Fork 651
Return user schema and request args in body of OPTIONs request #1262
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This repeat declaration of schema isn't great. Better ideas?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we register the schema on the route rather than each endpoint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this:
register_rest_route( 'wp/v2', '/posts', array(
array( ... )
), false, array( 'schema' => $schema ) );There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not add more parameters to register_rest_route. Can we just add it to the existing route stuff?
register_rest_route( 'wp/v2', '/comments', array(
array(
'methods' => WP_REST_Server::READABLE,
...
),
array(
'methods' => WP_REST_Server::CREATABLE,
...
),
'schema' => ...
) );There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Similar to meta queries with relation mixed with the indexed arrays)
|
@joehoyle Would love your input on this. The abstraction seems a bit messy at the moment. |
|
Response looks a bit like this right now: |
|
@joehoyle Could you weigh in on this? Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this cast to an object? Pretty much everything else return an array / ArrayAccess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because I want to make sure it's always an object, even when empty. Otherwise it will be an array when empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh. Derp. I guess it was empty at one point, and then I changed my code.
|
Implementation is ok I think - though don't like the repeated schema so much - as I think there should only be one schema per route. By using |
|
So, question: if you don't already know how to form the URL, how do you get the schema for it? For example, (Working with a few others on porting the dotcom console and noticed this one.) |
|
Consensus is to chuck everything into the index, as well as return it for |
Rather than just spewing out the raw data (and causing json_encode to be called on the Controller objects), this whitelists certain pieces of data.
|
Splitting the index part out to #1305 so we can ship this sucker. @WP-API/amigos #reviewmerge |
|
Punting to b3 to get passing tests. |
(Also, because as pointed out, this really only affects user endpoints, and we should probably tackle them all.) |
|
I believe this has been taken care of in #1415 |
|
This has since been addressed. |
See #1222