Make WordPress Core

Opened 5 years ago

Closed 3 years ago

Last modified 3 years ago

#53079 closed defect (bug) (invalid)

Rest API Json Schema is invalid

Reported by: bukowa Owned by: rachelbaker
Priority: low Milestone:
Component: REST API Version: 5.7.1
Severity: trivial Keywords: reporter-feedback close
Cc: Focuses: docs, rest-api, coding-standards

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 (4)

#1 @SergeyBiryukov
5 years ago

  • Component HTTP APIREST API
  • Keywords needs-design needs-design-feedback removed

#2 @bukowa
5 years 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 ?

#3 @rachelbaker
4 years ago

  • Keywords reporter-feedback close added; needs-patch dev-feedback needs-testing needs-docs removed
  • Owner set to rachelbaker
  • Priority normallow
  • Severity criticaltrivial
  • Status newassigned

The WordPress REST API schema follows the JSON-schema draft 6 specification. I tested a few endpoint schemas with some online validators and they passed.

In addition to the OPTIONS request, you can view a site's schema and endpoint documentation via the /wp-json url path for any WordPress site and find the links to other registered endpoint schemas.

It is unclear the form of support you are seeking in this ticket. Can you share what was flagged as invalid and what error/validation output you receive?

#4 @hellofromTonya
3 years ago

  • Milestone Awaiting Review
  • Resolutioninvalid
  • Status assignedclosed

11 months Rachel flagged this ticket as a close candidate, provided reasoning, and asked the following:

It is unclear the form of support you are seeking in this ticket. Can you share what was flagged as invalid and what error/validation output you receive?

As there's been no follow-up since then, I'll close this ticket.

However, @bukowa if you get the opportunity to follow-up to Rachel's question and have more information, please reopen and share. Thank you.

Last edited 3 years ago by hellofromTonya (previous) (diff)
Note: See TracTickets for help on using tickets.