diff --git a/tests/data/rest-api/routes/oembed-1-0-embed.json b/tests/data/rest-api/routes/oembed-1-0-embed.json new file mode 100644 index 0000000..e8ae274 --- /dev/null +++ b/tests/data/rest-api/routes/oembed-1-0-embed.json @@ -0,0 +1,3 @@ +{ + "route": "/oembed/1.0/embed" +} \ No newline at end of file diff --git a/tests/data/rest-api/routes/oembed-1-0-proxy.json b/tests/data/rest-api/routes/oembed-1-0-proxy.json new file mode 100644 index 0000000..9094d47 --- /dev/null +++ b/tests/data/rest-api/routes/oembed-1-0-proxy.json @@ -0,0 +1,3 @@ +{ + "route": "/oembed/1.0/proxy" +} \ No newline at end of file diff --git a/tests/data/rest-api/routes/oembed-1-0.json b/tests/data/rest-api/routes/oembed-1-0.json new file mode 100644 index 0000000..add2d9f --- /dev/null +++ b/tests/data/rest-api/routes/oembed-1-0.json @@ -0,0 +1,3 @@ +{ + "route": "/oembed/1.0" +} \ No newline at end of file diff --git a/tests/data/rest-api/routes/routes.json b/tests/data/rest-api/routes/routes.json index 3e2a40f..844f9ae 100644 --- a/tests/data/rest-api/routes/routes.json +++ b/tests/data/rest-api/routes/routes.json @@ -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", diff --git a/tests/data/rest-api/routes/wp-block-editor-v1-export.json b/tests/data/rest-api/routes/wp-block-editor-v1-export.json new file mode 100644 index 0000000..6309dd2 --- /dev/null +++ b/tests/data/rest-api/routes/wp-block-editor-v1-export.json @@ -0,0 +1,3 @@ +{ + "route": "/wp-block-editor/v1/export" +} \ No newline at end of file diff --git a/tests/data/rest-api/routes/wp-block-editor-v1-navigation-fallback.json b/tests/data/rest-api/routes/wp-block-editor-v1-navigation-fallback.json new file mode 100644 index 0000000..f4e0b62 --- /dev/null +++ b/tests/data/rest-api/routes/wp-block-editor-v1-navigation-fallback.json @@ -0,0 +1,3 @@ +{ + "route": "/wp-block-editor/v1/navigation-fallback" +} \ No newline at end of file diff --git a/tests/data/rest-api/routes/wp-block-editor-v1-url-details.json b/tests/data/rest-api/routes/wp-block-editor-v1-url-details.json new file mode 100644 index 0000000..f4c5bf9 --- /dev/null +++ b/tests/data/rest-api/routes/wp-block-editor-v1-url-details.json @@ -0,0 +1,3 @@ +{ + "route": "/wp-block-editor/v1/url-details" +} \ No newline at end of file diff --git a/tests/data/rest-api/routes/wp-block-editor-v1.json b/tests/data/rest-api/routes/wp-block-editor-v1.json new file mode 100644 index 0000000..fd3d9eb --- /dev/null +++ b/tests/data/rest-api/routes/wp-block-editor-v1.json @@ -0,0 +1,3 @@ +{ + "route": "/wp-block-editor/v1" +} \ No newline at end of file diff --git a/tests/data/rest-api/routes/wp-site-health-v1-directory-sizes.json b/tests/data/rest-api/routes/wp-site-health-v1-directory-sizes.json new file mode 100644 index 0000000..15b3455 --- /dev/null +++ b/tests/data/rest-api/routes/wp-site-health-v1-directory-sizes.json @@ -0,0 +1,3 @@ +{ + "route": "/wp-site-health/v1/directory-sizes" +} \ No newline at end of file diff --git a/tests/data/rest-api/routes/wp-site-health-v1-tests-authorization-header.json b/tests/data/rest-api/routes/wp-site-health-v1-tests-authorization-header.json new file mode 100644 index 0000000..74d1c06 --- /dev/null +++ b/tests/data/rest-api/routes/wp-site-health-v1-tests-authorization-header.json @@ -0,0 +1,3 @@ +{ + "route": "/wp-site-health/v1/tests/authorization-header" +} \ No newline at end of file diff --git a/tests/data/rest-api/routes/wp-site-health-v1-tests-background-updates.json b/tests/data/rest-api/routes/wp-site-health-v1-tests-background-updates.json new file mode 100644 index 0000000..d359970 --- /dev/null +++ b/tests/data/rest-api/routes/wp-site-health-v1-tests-background-updates.json @@ -0,0 +1,3 @@ +{ + "route": "/wp-site-health/v1/tests/background-updates" +} \ No newline at end of file diff --git a/tests/data/rest-api/routes/wp-site-health-v1-tests-dotorg-communication.json b/tests/data/rest-api/routes/wp-site-health-v1-tests-dotorg-communication.json new file mode 100644 index 0000000..4728c7d --- /dev/null +++ b/tests/data/rest-api/routes/wp-site-health-v1-tests-dotorg-communication.json @@ -0,0 +1,3 @@ +{ + "route": "/wp-site-health/v1/tests/dotorg-communication" +} \ No newline at end of file diff --git a/tests/data/rest-api/routes/wp-site-health-v1-tests-https-status.json b/tests/data/rest-api/routes/wp-site-health-v1-tests-https-status.json new file mode 100644 index 0000000..addda23 --- /dev/null +++ b/tests/data/rest-api/routes/wp-site-health-v1-tests-https-status.json @@ -0,0 +1,3 @@ +{ + "route": "/wp-site-health/v1/tests/https-status" +} \ No newline at end of file diff --git a/tests/data/rest-api/routes/wp-site-health-v1-tests-loopback-requests.json b/tests/data/rest-api/routes/wp-site-health-v1-tests-loopback-requests.json new file mode 100644 index 0000000..c469bf7 --- /dev/null +++ b/tests/data/rest-api/routes/wp-site-health-v1-tests-loopback-requests.json @@ -0,0 +1,3 @@ +{ + "route": "/wp-site-health/v1/tests/loopback-requests" +} \ No newline at end of file diff --git a/tests/data/rest-api/routes/wp-site-health-v1-tests-page-cache.json b/tests/data/rest-api/routes/wp-site-health-v1-tests-page-cache.json new file mode 100644 index 0000000..dcb957d --- /dev/null +++ b/tests/data/rest-api/routes/wp-site-health-v1-tests-page-cache.json @@ -0,0 +1,3 @@ +{ + "route": "/wp-site-health/v1/tests/page-cache" +} \ No newline at end of file diff --git a/tests/data/rest-api/routes/wp-site-health-v1.json b/tests/data/rest-api/routes/wp-site-health-v1.json new file mode 100644 index 0000000..fc5ab43 --- /dev/null +++ b/tests/data/rest-api/routes/wp-site-health-v1.json @@ -0,0 +1,3 @@ +{ + "route": "/wp-site-health/v1" +} \ No newline at end of file diff --git a/tests/output/routes.php b/tests/output/routes.php index 7426bc2..914016c 100644 --- a/tests/output/routes.php +++ b/tests/output/routes.php @@ -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;