WordPress.org

Make WordPress Core

Opened 8 months ago

Closed 8 months ago

Last modified 6 months ago

#38792 closed defect (bug) (fixed)

REST API: Clean up argument and property types

Reported by: jnylen0 Owned by: joehoyle
Milestone: 4.7 Priority: normal
Severity: normal Version: 4.7
Component: REST API Keywords: has-patch
Focuses: Cc:

Description

Fixes a few remaining issues with argument and property types, found using this script to automatically check endpoint arguments and item schemas. (Current output of the script against trunk is here.)

  • All args/properties should have a type and description
  • All array args/properties should have an item type
  • All context and capabilities properties should be consistently typed
  • A couple of checks specific to our object properties with rendered and raw fields.

Follow-up to https://core.trac.wordpress.org/ticket/38531#comment:21.

Putting this in 4.7 because this is a good change for API consistency and because we currently allow some funky things like sending an array as the post password, so there are some minor BC implications here.

Attachments (1)

38792.diff (4.8 KB) - added by jnylen0 8 months ago.

Download all attachments as: .zip

Change History (9)

@jnylen0
8 months ago

#1 @joehoyle
8 months ago

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

In 39250:

REST API: Clean up argument and property types.

There's a couple of places where we were missing type notes for arguments, which mainly affects documentation.

Props jnylen0.
Fixes #38792.

#2 @rmccue
8 months ago

@jnylen0 @joehoyle I'm wondering: should we convert this script to a unit test? Seems like a good way to ensure future arguments/endpoints are registered with all the necessary pieces pretty nicely.

(We could get the index for wp/v2 instead of the root if we're concerned about stepping on other components'/plugin's toes.)

This ticket was mentioned in Slack in #core-restapi by jnylen. View the logs.


8 months ago

This ticket was mentioned in Slack in #core-restapi by rachelbaker. View the logs.


8 months ago

#5 @joehoyle
6 months ago

In 39954:

REST API: Unify object access handling for simplicity.

Rather than repeating ourselves, unifying the access into a single method keeps everything tidy. While we're at it, add in additional schema handling for common parameters.

See #38792.

#6 @ocean90
6 months ago

In 39957:

REST API: Unify object access handling for simplicity.

Rather than repeating ourselves, unifying the access into a single method keeps everything tidy. While we're at it, add in additional schema handling for common parameters.

Merge of [39954] to the 4.7 branch.

See #38792.

#7 @boonebgorges
6 months ago

In 39992:

Revert to pre-4.7 behavior for fetching object instances by id.

This changeset reverts [38381], which caused inconsistencies in the way the
REST API fetches posts and other objects.

See #38792, #37738.

#8 @boonebgorges
6 months ago

In 39993:

Revert to pre-4.7 behavior for fetching object instances by id.

This changeset reverts [38381], which caused inconsistencies in the way the
REST API fetches posts and other objects.

Merge of [39992] to the 4.7 branch.

See #38792, #37738.

Note: See TracTickets for help on using tickets.