Skip to content

Commit

Permalink
Add caching to schema of REST API. (#52045)
Browse files Browse the repository at this point in the history
  • Loading branch information
spacedmonkey authored Jun 29, 2023
1 parent 14e1c6f commit 76e03d7
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public function prepare_item_for_response( $item, $request ) {
* @return array Item schema data.
*/
public function get_item_schema() {
if ( $this->schema ) {
return $this->add_additional_fields_schema( $this->schema );
}

$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'block-pattern-category',
Expand All @@ -73,6 +77,8 @@ public function get_item_schema() {
),
);

return $this->add_additional_fields_schema( $schema );
$this->schema = $schema;

return $this->add_additional_fields_schema( $this->schema );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ public function prepare_item_for_response( $item, $request ) {
* @return array Item schema data.
*/
public function get_item_schema() {
if ( $this->schema ) {
return $this->add_additional_fields_schema( $this->schema );
}

$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'block-pattern',
Expand Down Expand Up @@ -153,7 +157,9 @@ public function get_item_schema() {
),
);

return $this->add_additional_fields_schema( $schema );
$this->schema = $schema;

return $this->add_additional_fields_schema( $this->schema );
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public function prepare_item_for_response( $item, $request ) {
* @return array Item schema data.
*/
public function get_item_schema() {
if ( $this->schema ) {
return $this->add_additional_fields_schema( $this->schema );
}

$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'block-pattern',
Expand Down Expand Up @@ -150,6 +154,8 @@ public function get_item_schema() {
),
);

return $this->add_additional_fields_schema( $schema );
$this->schema = $schema;

return $this->add_additional_fields_schema( $this->schema );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function get_item_schema() {
return $this->add_additional_fields_schema( $this->schema );
}

$this->schema = array(
$schema = array(
'$schema' => 'http://json-schema.org/draft-04/schema#',
'title' => 'block-editor-settings-item',
'type' => 'object',
Expand Down Expand Up @@ -311,6 +311,8 @@ public function get_item_schema() {
),
);

$this->schema = $schema;

return $this->add_additional_fields_schema( $this->schema );
}
}

0 comments on commit 76e03d7

Please sign in to comment.