WordPress.org

Make WordPress Core

Opened 4 months ago

Closed 3 months ago

Last modified 3 months ago

#50053 closed enhancement (fixed)

REST API: Support uuid json schema format

Reported by: TimothyBlynJacobs Owned by: TimothyBlynJacobs
Milestone: 5.5 Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords: json-schema good-first-bug has-patch has-unit-tests
Focuses: rest-api Cc:

Description

We should add support for format: "uuid" in rest_validate_value_from_schema. We can use the existing wp_is_uuid function for validation. And I'd imagine sanitize_text_field for sanitization.

At the moment, I think we can skip checking for a specific uuid version.

The list of formats is extensible, but uuid is also included as a format in the latest specs.

Change History (6)

This ticket was mentioned in PR #247 on WordPress/wordpress-develop by johnwatkins0.


3 months ago

https://core.trac.wordpress.org/ticket/50053

This adds support for the uuid format in WP REST JSON schema. As suggested in the ticket description, the format is validated with wp_is_uuid and sanitized with sanitize_text_field.

#2 @johnwatkins0
3 months ago

  • Keywords has-patch has-unit-tests added; needs-patch needs-unit-tests removed

#3 @TimothyBlynJacobs
3 months ago

  • Owner set to TimothyBlynJacobs
  • Resolution set to fixed
  • Status changed from new to closed

In 47753:

REST API: Support the uuid JSON Schema format.

This accepts a uuid of any version. A future commit could add support for restricting uuids to a specific version.

Props johnwatkins0.
Fixes #50053.

#5 @prbot
3 months ago

johnwatkins0 commented on PR #247:

Thanks, @TimothyBJacobs !

#6 @TimothyBlynJacobs
3 months ago

In 47811:

REST API: Add @since entries for rest_validate_value_from_schema().

See #49572, #48818, #44949, #50053, #48820, #49720, #42961, #44975, #43392, #38583.

Note: See TracTickets for help on using tickets.