WordPress.org

Make WordPress Core

Opened 2 months ago

Last modified 2 months ago

#53079 new defect (bug)

Rest API Json Schema is invalid

Reported by: bukowa Owned by:
Milestone: Awaiting Review Priority: normal
Severity: critical Version: 5.7.1
Component: REST API Keywords: needs-patch dev-feedback needs-testing needs-docs
Focuses: docs, rest-api, coding-standards Cc:

Description

Hello i tried to validate JSON SCHEMA using online validators from https://json-schema.org/implementations.html#validators

Looks like the schema does not pass any validator. I would like to generate some client code in different languages but all of them says schema is invalid.

Overall i couldn't find a way to get the schema directly from wordpress documentation. After some googling i found out i have to call curl -X OPTIONS https://mydomain.com/wp-json/wp/v2/posts and then there's a nested 'schema' property.

Also the docs at https://developer.wordpress.org/rest-api/reference/posts/ are kinda missleading because for the 'content' it says 'object' - so that can be actually anything?

I would really like to work with wordpress and the REST API it provides but overall i find it pretty difficult.

Change History (2)

#1 @SergeyBiryukov
2 months ago

  • Component changed from HTTP API to REST API
  • Keywords needs-design needs-design-feedback removed

#2 @bukowa
2 months ago

I found out the OPTIONS is actually in the documenation at: https://developer.wordpress.org/rest-api/reference/#a-distributed-api

It says:

or via an OPTIONS request to any endpoint, allowing human- or machine-discovery of endpoint capabilities.


Is the format returned by that request following any standard beside the "schema" which is json-schema v4 ?

Note: See TracTickets for help on using tickets.