-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
REST API: Improve the block type schema for the name
field
#5278
REST API: Improve the block type schema for the name
field
#5278
Conversation
@gziolo Don't we need to regenerate this line -https://github.com/WordPress/wordpress-develop/blob/trunk/tests/qunit/fixtures/wp-api-generated.js |
Do you mean we should also update the pattern used with URLs, like:
or
I executed all unit tests and this file hasn't changed. The comment included explains that the file is auto-generated with |
Thank you! I'll have a closer look in a bit, but one thing I was wondering -- could we express the fact that the keys in |
There is a code comment included in the same method which suggests it can't be used: wordpress-develop/src/wp-includes/rest-api/endpoints/class-wp-rest-block-types-controller.php Line 397 in e00f028
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Committed with 56676. |
Trac ticket: https://core.trac.wordpress.org/ticket/59346
The goal of this PR is to align the schema between
block.json
and the REST API endpoint for block types. It looks like thename
field isn't validated in all places and if it uses pattern matching in the REST API code, then it's slightly different.https://github.com/WordPress/gutenberg/blob/aa938166f28bcfff6c7b8d1caac5a95f78852f97/schemas/json/block.json#L26
https://github.com/WordPress/gutenberg/blob/f6d16f0b9f0a71d51c7178d35902c078b0d33c08/packages/blocks/src/api/registration.js#L231
I opted for using the same pattern as during block registration in JavaScript:
'^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$'
This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.