Created
February 27, 2017 19:46
-
-
Save petenelson/ae99ed55b9a06342a70450dff61e979a to your computer and use it in GitHub Desktop.
WordPress: Example of REST API route with schema type of array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
register_rest_route( 'test', '/v1/schema-test', array( | |
'methods' => 'POST', | |
'callback' => __NAMESPACE__ . '\handle_endpoint', | |
'args' => array( | |
'mybools' => array( | |
'required' => true, | |
'type' => 'array', // We require an array of items. | |
'items' => array( | |
'type' => 'boolean', // The items must be all boolean values. | |
), | |
) | |
), | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you do a POST with
mybools=true,1,0
ormybools[]=true&mybools[]=1&mybools[]=0
it will perform the boolean schema check on all of the items.