Many REST API schemas do not match their response contents
-
Hi,
I’m working on a tool that uses schema objects from
OPTIONS /wp-json/wp/v2
endpoints.I noticed that many of them do not represent their
GET
endpoints.GET /wp-json/wp/v2/posts
returns the following response, which is an array of Post object[ { "id": 1, "date": "2022-07-06T08:15:30", "date_gmt": "2022-07-06T08:15:30", "guid": { "rendered": "https://woodev.local/?p=1" }, "title": { "rendered": "Hello world!" }, "content": { "rendered": "\n<p>Welcome to WordPress. This is your first post. Edit or delete it, then start writing!</p>\n", "protected": false }, ... } ]
OPTION /wp-json/wp/v2/posts
returns the following schema{ "$schema": "https://json-schema.org/draft-04/schema#", "title": "post", "type": "object", "properties": { "date": { "description": "The date the post was published, in the site's timezone.", "type": [ "string", "null" ], "format": "date-time", "context": [ "view", "edit", "embed" ] }, "date_gmt": { "description": "The date the post was published, as GMT.", "type": [ "string", "null" ], "format": "date-time", "context": [ "view", "edit" ] }, .... } }
It only represents a single Post. Shouldn’t it return the following schema instead?
{ "$schema": "https://json-schema.org/draft-04/schema#", "title": "posts", "type": "array", "items": { "type": "object", "properties": { "date": { "description": "The date the post was published, in the site's timezone.", "type": [ "string", "null" ], "format": "date-time", "context": [ "view", "edit", "embed" ] }, "date_gmt": { "description": "The date the post was published, as GMT.", "type": [ "string", "null" ], "format": "date-time", "context": [ "view", "edit" ] }, .... } } }
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Many REST API schemas do not match their response contents’ is closed to new replies.