iron-bound-designs / wp-rest-api-schema-validator

Validate WP REST API requests using a complete JSON Schema validator.
https://timothybjacobs.com/2017/05/17/json-schema-and-the-wp-rest-api/
MIT License
12 stars 2 forks source link

Check for null WP_REST_Request content type. #6

Closed thefrosty closed 3 years ago

thefrosty commented 3 years ago

Fixes #5

TimothyBJacobs commented 3 years ago

Thanks for the PR! To answer your question from the issue, the content-type must be set to JSON for it to be treated as JSON, by default we just treat it as regular post variables.

When I originally wrote this, though, WP_REST_Request::set_param didn't have its logic updated to properly handle setting the value in the correct "slot". That got fixed in 4.8, so we could probably drop this method entirely and just call WP_REST_Request::set_param directly.

thefrosty commented 3 years ago

Let me know which you prefer.

TimothyBJacobs commented 3 years ago

Yeah let's just call the Core method directly.

TimothyBJacobs commented 3 years ago

Thanks for the patch!