Skip to content

Commit

Permalink
Let's monitor all the available routes.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbillion committed Aug 13, 2024
1 parent bf169f0 commit e8c4767
Show file tree
Hide file tree
Showing 17 changed files with 72 additions and 8 deletions.
3 changes: 3 additions & 0 deletions tests/data/rest-api/routes/oembed-1-0-embed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/oembed/1.0/embed"
}
3 changes: 3 additions & 0 deletions tests/data/rest-api/routes/oembed-1-0-proxy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/oembed/1.0/proxy"
}
3 changes: 3 additions & 0 deletions tests/data/rest-api/routes/oembed-1-0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/oembed/1.0"
}
15 changes: 15 additions & 0 deletions tests/data/rest-api/routes/routes.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
[
"/oembed/1.0",
"/oembed/1.0/embed",
"/oembed/1.0/proxy",
"/wp-block-editor/v1",
"/wp-block-editor/v1/export",
"/wp-block-editor/v1/navigation-fallback",
"/wp-block-editor/v1/url-details",
"/wp-site-health/v1",
"/wp-site-health/v1/directory-sizes",
"/wp-site-health/v1/tests/authorization-header",
"/wp-site-health/v1/tests/background-updates",
"/wp-site-health/v1/tests/dotorg-communication",
"/wp-site-health/v1/tests/https-status",
"/wp-site-health/v1/tests/loopback-requests",
"/wp-site-health/v1/tests/page-cache",
"/wp/v2",
"/wp/v2/block-directory/search",
"/wp/v2/block-patterns/categories",
Expand Down
3 changes: 3 additions & 0 deletions tests/data/rest-api/routes/wp-block-editor-v1-export.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/wp-block-editor/v1/export"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/wp-block-editor/v1/navigation-fallback"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/wp-block-editor/v1/url-details"
}
3 changes: 3 additions & 0 deletions tests/data/rest-api/routes/wp-block-editor-v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/wp-block-editor/v1"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/wp-site-health/v1/directory-sizes"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/wp-site-health/v1/tests/authorization-header"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/wp-site-health/v1/tests/background-updates"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/wp-site-health/v1/tests/dotorg-communication"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/wp-site-health/v1/tests/https-status"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/wp-site-health/v1/tests/loopback-requests"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/wp-site-health/v1/tests/page-cache"
}
3 changes: 3 additions & 0 deletions tests/data/rest-api/routes/wp-site-health-v1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"route": "/wp-site-health/v1"
}
20 changes: 12 additions & 8 deletions tests/output/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@

namespace WPJsonSchemas;

$data = get_rest_response( 'GET', '/wp/v2', [] );

$d = $data->get_data();

$routes = array_map( function( array $data, string $route ) : array {
$data['route'] = $route;
return $data;
}, $d['routes'], array_keys( $d['routes'] ) );
$root = get_rest_response( 'GET', '/' )->get_data();
$namespaces = $root['namespaces'];
$routes = [];

foreach ( $namespaces as $namespace ) {
$d = get_rest_response( 'GET', '/' . $namespace )->get_data();
$namespace_routes = array_map( function( array $data, string $route ) : array {
$data['route'] = $route;
return $data;
}, $d['routes'], array_keys( $d['routes'] ) );
$routes = array_merge( $routes, $namespace_routes );
}

$dir = 'routes';
$dir = dirname( ABSPATH ) . '/data/rest-api/' . $dir;
Expand Down

0 comments on commit e8c4767

Please sign in to comment.