Object_Schema
extends Schema
in package
Represents a schema for an object.
See: https://developer.wordpress.org/rest-api/extending-the-rest-api/schema/#objects
Table of Contents
- $schema : array<string|int, mixed>
- Schema definition.
- additionalProperties() : self
- Set the required properties of the object.
- default() : static
- Set the default value.
- description() : static
- Set the description of the schema.
- disableAdditionalProperties() : self
- Disables additional properties.
- field() : static
- Set the field name and value.
- maxProperties() : self
- Sets the maximum number of properties in the object.
- minProperties() : self
- Sets the minimum number of properties in the object.
- non_nullable() : static
- Sets the schema as non-nullable.
- nullable() : static
- Sets the schema as nullable.
- optional() : static
- Unsets the required property.
- patternProperties() : self
- Keys of $properties are regular expressions without leading/trailing delimiters.
- properties() : self
- Set the required properties of the object.
- required() : static
- Sets the schema as required.
- title() : static
- Set the title of the schema.
- to_array() : array<string|int, mixed>
- Returns the schema as an array.
- to_string() : string
- Returns the schema as a JSON string.
- get_reserved_keywords() : array<string|int, string>
- Returns reserved keywords.
- unset_schema_property() : static
- Unsets the schema property.
- update_schema_property() : static
- Updates the schema property.
- validate_pattern() : void
- Validates the regular expression pattern.
Properties
$schema
Schema definition.
protected
array<string|int, mixed>
$schema
= array('type' => 'object')
Methods
additionalProperties()
Set the required properties of the object.
public
additionalProperties(Schema $schema) : self
Parameters
- $schema : Schema
-
Schema of the additional properties.
Return values
self —default()
Set the default value.
public
default(mixed $default_value) : static
Parameters
- $default_value : mixed
-
Default value.
Return values
static —description()
Set the description of the schema.
public
description(string $description) : static
Parameters
- $description : string
-
Description.
Return values
static —disableAdditionalProperties()
Disables additional properties.
public
disableAdditionalProperties() : self
Return values
self —field()
Set the field name and value.
public
field(string $name, mixed $value) : static
Parameters
- $name : string
-
Name of the field.
- $value : mixed
-
Value of the field.
Tags
Return values
static —maxProperties()
Sets the maximum number of properties in the object.
public
maxProperties(int $value) : self
Parameters
- $value : int
-
Maximum number of properties in the object.
Return values
self —minProperties()
Sets the minimum number of properties in the object.
public
minProperties(int $value) : self
Parameters
- $value : int
-
Minimum number of properties in the object.
Return values
self —non_nullable()
Sets the schema as non-nullable.
public
non_nullable() : static
Return values
static —nullable()
Sets the schema as nullable.
public
nullable() : static
Return values
static —optional()
Unsets the required property.
public
optional() : static
Return values
static —patternProperties()
Keys of $properties are regular expressions without leading/trailing delimiters.
public
patternProperties(array<string, Schema> $properties) : self
See: https://developer.wordpress.org/rest-api/extending-the-rest-api/schema/#patternproperties
Parameters
- $properties : array<string, Schema>
-
Regular expressions and their schemas.
Return values
self —properties()
Set the required properties of the object.
public
properties(array<string, Schema> $properties) : self
Parameters
- $properties : array<string, Schema>
-
Required properties.
Return values
self —required()
Sets the schema as required.
public
required() : static
Return values
static —title()
Set the title of the schema.
public
title(string $title) : static
Parameters
- $title : string
-
Title.
Return values
static —to_array()
Returns the schema as an array.
public
to_array() : array<string|int, mixed>
Return values
array<string|int, mixed> —to_string()
Returns the schema as a JSON string.
public
to_string() : string
Tags
Return values
string —get_reserved_keywords()
Returns reserved keywords.
protected
get_reserved_keywords() : array<string|int, string>
Return values
array<string|int, string> —unset_schema_property()
Unsets the schema property.
protected
unset_schema_property(string $name) : static
Parameters
- $name : string
-
Property name.
Return values
static —update_schema_property()
Updates the schema property.
protected
update_schema_property(string $name, mixed $value) : static
Parameters
- $name : string
-
Property name.
- $value : mixed
-
Property value.
Return values
static —validate_pattern()
Validates the regular expression pattern.
protected
validate_pattern(string $pattern) : void
Parameters
- $pattern : string
-
Regular expression pattern.