Make WordPress Core

Opened 2 months ago

Last modified 2 months ago

#53621 new defect (bug)

The `wp/v2/block-directory/search` schema is incorrect

Reported by: johnbillion Owned by:
Milestone: 5.9 Priority: normal
Severity: normal Version: 5.5
Component: REST API Keywords: has-patch
Focuses: rest-api Cc:


Some problems with the declared schema for the wp/v2/block-directory/search endpoint:

  • rating is a float, not an integer
  • active_installs is an integer, not a string
  • author_block_rating is a float, not an integer

This can be seen by performing a search for a common term such as "block" and looking through the various results.

This can also be seen in the code: https://github.com/WordPress/wordpress-develop/blob/73e24c997c1182ac48856c1546cf4719b51ae27d/src/wp-includes/rest-api/endpoints/class-wp-rest-block-directory-controller.php#L127-L130

Change History (2)

This ticket was mentioned in PR #1487 on WordPress/wordpress-develop by johnbillion.

2 months ago

  • Keywords has-patch added; needs-patch removed

#2 @johnbillion
2 months ago

I've got test coverage for this in my wp-json-schemas package that runs a live search and then validates the response against its JSON schema: https://github.com/johnbillion/wp-json-schemas/commit/1eeb02c23a2d80bb57c67cb4efd95997b29ca99a . I had to correct these three types to get the validation to pass.

It would be good to have coverage here either via a live search or via a mock response from the w.org API.

Note: See TracTickets for help on using tickets.