diff --git a/packages/wp-types/readme.md b/packages/wp-types/readme.md index fdcb8d6..1be89b0 100644 --- a/packages/wp-types/readme.md +++ b/packages/wp-types/readme.md @@ -71,10 +71,10 @@ Route | Schema /wp/v2/menu-items/{id} | `WP_REST_API_Menu_Item` /wp/v2/menu-items/{id}/autosaves | Todo /wp/v2/menu-items/{parent}/autosaves/{id} | Todo -/wp/v2/menu-locations | Todo -/wp/v2/menu-locations/{location} | Todo -/wp/v2/menus | Todo -/wp/v2/menus/{id} | Todo +/wp/v2/menu-locations | `WP_REST_API_Menu_Locations` +/wp/v2/menu-locations/{location} | `WP_REST_API_Menu_Location` +/wp/v2/menus | `WP_REST_API_Menus` +/wp/v2/menus/{id} | `WP_REST_API_Menu` /wp/v2/navigation | Todo /wp/v2/navigation/{id} | Todo /wp/v2/navigation/{id}/autosaves | Todo diff --git a/readme.md b/readme.md index 36f8ee1..8b2ed32 100644 --- a/readme.md +++ b/readme.md @@ -75,10 +75,10 @@ Route | Schema /wp/v2/menu-items/{id} | `WP_REST_API_Menu_Item` /wp/v2/menu-items/{id}/autosaves | Todo /wp/v2/menu-items/{parent}/autosaves/{id} | Todo -/wp/v2/menu-locations | Todo -/wp/v2/menu-locations/{location} | Todo -/wp/v2/menus | Todo -/wp/v2/menus/{id} | Todo +/wp/v2/menu-locations | `WP_REST_API_Menu_Locations` +/wp/v2/menu-locations/{location} | `WP_REST_API_Menu_Location` +/wp/v2/menus | `WP_REST_API_Menus` +/wp/v2/menus/{id} | `WP_REST_API_Menu` /wp/v2/navigation | Todo /wp/v2/navigation/{id} | Todo /wp/v2/navigation/{id}/autosaves | Todo diff --git a/schema.json b/schema.json index e0884fe..35ce564 100644 --- a/schema.json +++ b/schema.json @@ -218,6 +218,18 @@ "Menu_Items": { "$ref": "schemas/rest-api/collections/menu-items.json" }, + "Menu_Location": { + "$ref": "schemas/rest-api/menu-location.json" + }, + "Menu_Locations": { + "$ref": "schemas/rest-api/collections/menu-locations.json" + }, + "Menu": { + "$ref": "schemas/rest-api/menu.json" + }, + "Menus": { + "$ref": "schemas/rest-api/collections/menus.json" + }, "Error": { "$ref": "schemas/rest-api/error.json" } @@ -271,6 +283,10 @@ "Application_Passwords", "Menu_Item", "Menu_Items", + "Menu_Location", + "Menu_Locations", + "Menu", + "Menus", "Error" ], "additionalProperties": false diff --git a/schemas/rest-api/collections/menu-locations.json b/schemas/rest-api/collections/menu-locations.json new file mode 100644 index 0000000..95b1a36 --- /dev/null +++ b/schemas/rest-api/collections/menu-locations.json @@ -0,0 +1,10 @@ +{ + "$schema": "http://json-schema.org/draft-07/hyper-schema#", + "$id": "https://raw.githubusercontent.com/johnbillion/wp-json-schemas/trunk/schemas/rest-api/collections/menu-locations.json", + "title": "WP_REST_API_Menu_Locations", + "description": "A collection of menu locations in a REST API context.", + "type": "object", + "additionalProperties": { + "$ref": "../menu-location.json" + } +} diff --git a/schemas/rest-api/collections/menus.json b/schemas/rest-api/collections/menus.json new file mode 100644 index 0000000..bddb4c9 --- /dev/null +++ b/schemas/rest-api/collections/menus.json @@ -0,0 +1,10 @@ +{ + "$schema": "http://json-schema.org/draft-07/hyper-schema#", + "$id": "https://raw.githubusercontent.com/johnbillion/wp-json-schemas/trunk/schemas/rest-api/collections/menus.json", + "title": "WP_REST_API_Menus", + "description": "A collection of menus in a REST API context.", + "type": "array", + "items": { + "$ref": "../menu.json" + } +} diff --git a/schemas/rest-api/menu-location.json b/schemas/rest-api/menu-location.json new file mode 100644 index 0000000..2d99d14 --- /dev/null +++ b/schemas/rest-api/menu-location.json @@ -0,0 +1,59 @@ +{ + "$schema": "http://json-schema.org/draft-07/hyper-schema#", + "$id": "https://raw.githubusercontent.com/johnbillion/wp-json-schemas/trunk/schemas/rest-api/menu-location.json", + "title": "WP_REST_API_Menu_Location", + "description": "A menu location in a REST API context.", + "type": "object", + "required": [ + "name", + "description", + "menu", + "_links" + ], + "properties": { + "name": { + "description": "The name of the menu location.", + "type": "string", + "readOnly": true + }, + "description": { + "description": "The description of the menu location.", + "type": "string", + "readOnly": true + }, + "menu": { + "description": "The ID of the assigned menu.", + "type": "integer", + "readOnly": true + }, + "_links": { + "$ref": "properties/object-links.json" + } + }, + "links": [ + { + "rel": "self", + "href": "/wp/v2/menu-locations/{name}", + "hrefSchema": { + "properties": { + "name": { + "$ref": "#/properties/name" + } + } + }, + "targetSchema": { + "$ref": "#" + } + }, + { + "rel": "collection", + "href": "/wp/v2/menu-locations", + "targetSchema": { + "type": "array", + "items": { + "$ref": "#" + } + } + } + ] +} diff --git a/schemas/rest-api/menu.json b/schemas/rest-api/menu.json new file mode 100644 index 0000000..de54fed --- /dev/null +++ b/schemas/rest-api/menu.json @@ -0,0 +1,100 @@ +{ + "$schema": "http://json-schema.org/draft-07/hyper-schema#", + "$id": "https://raw.githubusercontent.com/johnbillion/wp-json-schemas/trunk/schemas/rest-api/menu.json", + "title": "WP_REST_API_Menu", + "description": "A menu in a REST API context.", + "type": "object", + "required": [ + "id", + "description", + "name", + "slug", + "meta", + "locations", + "auto_add", + "_links" + ], + "properties": { + "id": { + "description": "Unique identifier for the term.", + "type": "integer", + "readOnly": true + }, + "description": { + "description": "HTML description of the term.", + "type": "string" + }, + "name": { + "description": "HTML title for the term.", + "type": "string" + }, + "slug": { + "description": "An alphanumeric identifier for the term unique to its type.", + "type": "string" + }, + "meta": { + "description": "Meta fields.", + "oneOf": [ + { + "$ref": "../../schema.json#/definitions/EmptyArray" + }, + { + "type": "object" + } + ] + }, + "locations": { + "description": "The locations assigned to the menu.", + "type": "array", + "items": { + "type": "string" + } + }, + "auto_add": { + "description": "Whether to automatically add top level pages to this menu.", + "type": "boolean" + }, + "_links": { + "$ref": "properties/object-links.json" + }, + "_embedded": { + "description": "The embedded representation of relations. Only present when the '_embed' query parameter is set.", + "type": "object", + "required": [ + "wp:menu-location" + ], + "properties": { + "wp:menu-location": { + "description": "The menu locations.", + "type": "array" + } + } + } + }, + "links": [ + { + "rel": "self", + "href": "/wp/v2/menus/{id}", + "hrefSchema": { + "properties": { + "id": { + "$ref": "#/properties/id" + } + } + }, + "targetSchema": { + "$ref": "#" + } + }, + { + "rel": "collection", + "href": "/wp/v2/menus", + "targetSchema": { + "type": "array", + "items": { + "$ref": "#" + } + } + } + ] +}