From 59c68aa3339cdd907201ea532f16837658b58084 Mon Sep 17 00:00:00 2001 From: leemour Date: Wed, 18 Nov 2026 11:40:40 +0100 Subject: [PATCH] feat(codegen): a WordPress API from the site's own index, and permission keys from a field's value WordPress has no OpenAPI, but /wp-json/?context=help lists every route with its arguments and the schema of its answer, the same one OPTIONS returns. syncWpJson keeps that one answer without the site's name, address and links; wpJsonToOpenApi turns a namespace's routes into OpenAPI 3.1 for adaptOpenApi: 152 operations from WordPress 6.9.4's wp/v2, ids from the method and path. A route whose value may hold a slash, and every namespace not offered, is left out and listed; an array in the query travels comma-separated, as PHP keeps only the last of a repeated name (checked on WordPress 6.9.4). permissions.valueKeys gives . to a write or delete whose field lists one of the values in its enum, through a reference or a union: status publish or future needs posts.publish, so a profile that denies publishing also stops the raw api group (RISK-2323). Where the field defaults to such a value (templates, template parts, menu items), the key applies on every call. A read that filters by the value gets none. OperationPermission.values carries it; cli-core checks it in the body and the query. sha256 and sortKeys move to snapshot.ts: discovery and graphql had a copy each. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 21 + docs/REFERENCE.md | 19 + docs/standards/kit-surface.md | 10 +- src/codegen/discovery.ts | 16 +- src/codegen/graphql.ts | 15 +- src/codegen/index.ts | 10 +- src/codegen/manifest.ts | 12 +- src/codegen/model.ts | 10 +- src/codegen/pipeline.ts | 71 +- src/codegen/snapshot.ts | 16 + src/codegen/wp-json.test.ts | 337 ++ src/codegen/wp-json.ts | 364 ++ test/fixtures/wp-json/LICENSE | 8 + test/fixtures/wp-json/wp-json-excerpt.json | 4510 ++++++++++++++++++++ 14 files changed, 5377 insertions(+), 42 deletions(-) create mode 100644 src/codegen/snapshot.ts create mode 100644 src/codegen/wp-json.test.ts create mode 100644 src/codegen/wp-json.ts create mode 100644 test/fixtures/wp-json/LICENSE create mode 100644 test/fixtures/wp-json/wp-json-excerpt.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 8877c00..575cc6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,27 @@ Versions before 0.8.0 are in the [git tags](https://github.com/WireCatLabs/cli-b Every entry says what changed as a caller sees it, why, and what to watch for — the rules are [`docs/dev/CONVENTIONS.md`](docs/dev/CONVENTIONS.md#the-changelog). +## Unreleased + +### Added + +- **A WordPress API from the site's own index: `syncWpJson`, `readWpJson` and `wpJsonToOpenApi`.** WordPress has no + OpenAPI, but `/wp-json/?context=help` lists every route with its arguments and the schema of its answer. + `syncWpJson` keeps that one answer, without the site's name, address and links, with its provenance; + `wpJsonToOpenApi` turns the routes of the namespaces a CLI offers into OpenAPI 3.1 for `adaptOpenApi`. WordPress + 6.9.4's `wp/v2` gives 152 operations (`getWpV2Posts`, `postWpV2PostsById`…). A route whose value may hold a slash + (templates, plugins, fonts) is left out and listed in `omissions`. Watch for: an array argument in the query is + one comma-separated string, as WordPress splits it and PHP keeps only the last of a repeated name, so it loses + its `enum`; WordPress's lists + page by headers, so `pagination: true` finds no paging for them yet. +- **A permission key from a field's value: `permissions.valueKeys`.** `{ key: "publish", field: "status", values: + ["publish", "future"] }` gives `posts.publish` to a write that sends `status: "publish"`, in the body or the query, + so a profile that denies publishing also stops the raw `api` group. Where the field defaults to such a value + (WordPress's templates, template parts and menu items), the key applies on every call, as leaving the field out + publishes. `OperationPermission.values` carries it in the manifest, and the coverage page's "When" says `` `status` is publish or future ``. Watch for: cli-core checks + `values` only from the release that reads them; an older cli-core asks for the key on every call of that operation, + as it does for a key with no flags. + ## 0.117.0 — 18.11.2026 ### Added diff --git a/docs/REFERENCE.md b/docs/REFERENCE.md index 5b7d1cf..d82d46d 100644 --- a/docs/REFERENCE.md +++ b/docs/REFERENCE.md @@ -272,6 +272,25 @@ is the GraphQL counterpart of `fakeApi`: it takes only a document `graphqlDocume type lacks, an object selected without fields and variables that break their schema, and answers `{ data: { } }` within the selection, or a scenario's `errors` with HTTP 200. +**A WordPress site describes its own API.** WordPress publishes no OpenAPI, but one call to +`/wp-json/?context=help` lists every route with its arguments and the schema of its answer, the same schema an +`OPTIONS` call returns. `syncWpJson({ root, dir, version })` asks for it and writes `wp-json.json`, without the site's +name, address and links, with a `provenance.json` that keeps the URL it asked, without a user or password; take it from a plain WordPress in Docker, as the CLI serves every +site, and give the WordPress `version`, which the index does not say. `readWpJson(dir)` loads it back and stops on a +changed hash. `wpJsonToOpenApi(index, { namespaces, exclude, site, version })` turns the routes of `namespaces` +(`["wp/v2"]`) into an OpenAPI 3.1 document for `adaptOpenApi`, with its `omissions`. GET reads, DELETE deletes with +its arguments in the query (`force`), and a route that takes POST, PUT and PATCH gets one write, POST, whose +arguments are its JSON body. Ids come from the method and path: `getWpV2Posts`, `postWpV2PostsById`. A collection read +(it takes `page` and `per_page`) answers a list of the route's schema. An array argument in the query becomes one +comma-separated string, which WordPress splits; PHP would keep only the last of a repeated name. The string loses the +array's `enum`, so WordPress, not the CLI, refuses a wrong value in it. The server is +`https://{site}/wp-json` and the sign-in an application password by Basic. A route whose value may hold a slash (a +template's `theme//slug`, a plugin's `dir/file`) fits no path segment and is left out, listed in `omissions` with the +namespaces not offered; a route +that is still a pattern, a second route on one path or an argument with no type stops generation, unless `exclude` +names the route with a reason. WordPress answers a list without its page count in the body, so `pagination: true` +finds no paging for it. + The generated schemas import `@wirecat/cli-base/codegen/runtime` at run time — a few number helpers, not the generator. Numbers are expected from a lossless JSON parser (`lossless-json`): a 64-bit integer comes out as its exact decimal string, and any other integer that does not fit a JS diff --git a/docs/standards/kit-surface.md b/docs/standards/kit-surface.md index 0619dff..4457f43 100644 --- a/docs/standards/kit-surface.md +++ b/docs/standards/kit-surface.md @@ -48,6 +48,7 @@ what it cannot do yet. | Swagger 1.2 (Yandex Disk) | `upgradeToOpenApi3(listing, declarations)`: the resource listing, and each API declaration keyed by its `apis[].path`, fetched from the listing's `basePath` followed by that path | | Google Discovery | `adaptDiscovery(readDiscovery(dir))`, snapshots written by `syncDiscovery` | | GraphQL (Linear) | `adaptGraphql(readGraphql(dir), { url, scalars })`, the introspection result written by `syncGraphql` | +| WordPress's REST index | `adaptOpenApi(wpJsonToOpenApi(readWpJson(dir), { namespaces: ["wp/v2"] }).document)`, the index written by `syncWpJson` | `upgradeToOpenApi3` converts with [swagger-converter](https://github.com/apigee-127/swagger-converter) (1.2 → 2.0) and [@scalar/openapi-upgrader](https://github.com/scalar/scalar/tree/main/packages/openapi-upgrader) (2.0 → 3.0). They are @@ -106,7 +107,7 @@ From the source the generator reads: empty or not in kebab case stops generation; map that operation in `commands`. `segments` renames a path segment or, with `""`, leaves it out: `{ "0-3": "deals", crm: "", objects: "" }`. Without `names` the command is the operation id in kebab case, as before. -- **`permissions`**: `{ group, deletingFlags, shares }`. `group` is a name (`files`) or a function of the operation, for +- **`permissions`**: `{ group, deletingFlags, shares, valueKeys }`. `group` is a name (`files`) or a function of the operation, for example the first word of its `command` (set only with `names`). Each key lands in the manifest as the operation's `permissions`. - `.delete` for every destructive operation (Yandex Disk's `DELETE /trash/resources` empties the whole trash), and for every operation that takes a flag in `deletingFlags`, as a top-level body field (Notion's @@ -114,6 +115,13 @@ From the source the generator reads: key applies when the flag is `true`. A flag no operation takes stops generation. - `.share` for the operation ids in `shares`: a public link opens a file to anyone, which is neither a plain write nor a delete. + - `.` for each of `valueKeys`, `{ key, field, values }`, on every write or delete whose body field or + query parameter `field` lists one of `values` in its `enum`, through a reference or a union too: WordPress + publishes by `status: "publish"`, so `{ key: "publish", field: "status", values: ["publish", "future"] }` gives + `posts.publish` and `pages.publish`. The key applies when the call sends one of those values, in the body or the + query; where the field's default is one of them (a WordPress template), leaving it out publishes too, and the key + always applies. A read that filters by the value gets no key, nor a field of that name without such an enum (a + comment's `status`); a rule no write matches stops generation. Which flags delete is the CLI's call: read the service's documentation, and count an undocumented flag as a delete. A flag counts on every method, a GET included: Yandex Disk's upload link is a GET whose `overwrite` replaces a file. diff --git a/src/codegen/discovery.ts b/src/codegen/discovery.ts index d5b7d17..4de54ac 100644 --- a/src/codegen/discovery.ts +++ b/src/codegen/discovery.ts @@ -6,11 +6,11 @@ * Strict like `adaptOpenApi`: an unknown schema keyword, format or parameter location stops generation. * Effects come from the HTTP verb; a method the verb misjudges is corrected with `generate`'s `overrides`. */ -import { createHash } from "node:crypto" import { mkdirSync, readFileSync, writeFileSync } from "node:fs" import { join } from "node:path" import type { ApiModel, ApiOperation, ApiSchema, Effect, HttpMethod, SchemaNode } from "./model.js" import { CodegenError } from "./pipeline.js" +import { sha256, sortKeys } from "./snapshot.js" type Json = Record @@ -305,20 +305,6 @@ export interface SyncDiscoveryOptions { fetch?: typeof globalThis.fetch } -const sha256 = (bytes: string | Buffer): string => createHash("sha256").update(bytes).digest("hex") - -/** Google serves the same revision with its keys in a different order each time; arrays keep theirs. */ -const sortKeys = (value: unknown): unknown => - Array.isArray(value) - ? value.map(sortKeys) - : object(value) - ? Object.fromEntries( - Object.keys(value) - .sort() - .map((key) => [key, sortKeys(value[key])]), - ) - : value - const NORMALIZATION = "object keys sorted, 2-space JSON; values and array order unchanged" /** diff --git a/src/codegen/graphql.ts b/src/codegen/graphql.ts index c04502e..66df212 100644 --- a/src/codegen/graphql.ts +++ b/src/codegen/graphql.ts @@ -8,11 +8,11 @@ * ends in `Delete` or `Archive` deletes. A Relay connection pages as a `cursor`: `after`, `pageInfo.endCursor`. * SDL is not read: that needs graphql-js, and codegen adds no runtime dependency. */ -import { createHash } from "node:crypto" import { mkdirSync, readFileSync, writeFileSync } from "node:fs" import { join } from "node:path" import type { ApiModel, ApiOperation, ApiSchema, GraphqlBinding, Pagination, SchemaNode } from "./model.js" import { CodegenError } from "./pipeline.js" +import { sha256, sortKeys } from "./snapshot.js" type Json = Record @@ -406,19 +406,6 @@ export interface GraphqlProvenance { normalization: string } -const sha256 = (bytes: string | Buffer): string => createHash("sha256").update(bytes).digest("hex") - -const sortKeys = (value: unknown): unknown => - Array.isArray(value) - ? value.map(sortKeys) - : object(value) - ? Object.fromEntries( - Object.keys(value) - .sort() - .map((key) => [key, sortKeys(value[key])]), - ) - : value - const byName = (list: unknown): unknown => Array.isArray(list) ? [...list].sort((a, b) => String((a as Json)?.name).localeCompare(String((b as Json)?.name))) diff --git a/src/codegen/index.ts b/src/codegen/index.ts index 1322207..e027bee 100644 --- a/src/codegen/index.ts +++ b/src/codegen/index.ts @@ -3,7 +3,7 @@ * manifest and a coverage page. Build-time, apart from the small helpers a CLI reads the generated * files with (`identifier`, `requestSchema`), and format-neutral: it parses no file format and * adds no runtime dependency. `adaptOpenApi` reads an OpenAPI document and `adaptDiscovery` Google Discovery - * documents the consumer has parsed, and `adaptGraphql` a GraphQL introspection result; `upgradeToOpenApi3` brings Swagger 1.2 and 2.0 to OpenAPI 3 through two optional + * documents the consumer has parsed, and `adaptGraphql` a GraphQL introspection result; `wpJsonToOpenApi` turns WordPress's REST index into OpenAPI; `upgradeToOpenApi3` brings Swagger 1.2 and 2.0 to OpenAPI 3 through two optional * peer dependencies. `fakeApi` serves the generated manifest as a strict fake for a CLI's tests, and `signInRequirements` with * `signInPlace` say which sign-in a call needs and where its token goes (Basic included). An adapter from * Postman or anything else lives in the consumer. @@ -111,3 +111,11 @@ export { API_SKILL_GROUPS, API_SKILL_INDEX, type ApiSkillOptions, apiSkillFiles export { upgradeToOpenApi3 } from "./swagger.js" export { typesGenerator } from "./typescript.js" export { type ValibotOptions, valibotGenerator } from "./valibot.js" +export { + readWpJson, + syncWpJson, + type WpJsonOptions, + type WpJsonProvenance, + type WpJsonResult, + wpJsonToOpenApi, +} from "./wp-json.js" diff --git a/src/codegen/manifest.ts b/src/codegen/manifest.ts index 41c5e6a..0cbc7e4 100644 --- a/src/codegen/manifest.ts +++ b/src/codegen/manifest.ts @@ -197,10 +197,12 @@ export const coverageGenerator = const guarded = model.operations.flatMap((operation) => (operation.permissions ?? []).map((permission) => ({ id: operation.id, permission })), ) - const when = ({ body, query }: OperationPermission) => - [...(body ?? []).map((flag) => `body \`${flag}\``), ...(query ?? []).map((flag) => `query \`${flag}\``)].join( - " or ", - ) + const when = ({ body, query, values }: OperationPermission) => + [ + ...(body ?? []).map((flag) => `body \`${flag}\` is true`), + ...(query ?? []).map((flag) => `query \`${flag}\` is true`), + ...Object.entries(values ?? {}).map(([field, listed]) => `\`${field}\` is ${listed.join(" or ")}`), + ].join(" or ") const content = [ `# ${options.title}`, "", @@ -254,7 +256,7 @@ export const coverageGenerator = "|---|---|---|", ...guarded.map(({ id, permission }) => { const flags = when(permission) - return `| \`${id}\` | \`${permission.key}\` | ${flags ? `${flags} is true` : "always"} |` + return `| \`${id}\` | \`${permission.key}\` | ${flags || "always"} |` }), ] : []), diff --git a/src/codegen/model.ts b/src/codegen/model.ts index 24b2e9a..57a54dd 100644 --- a/src/codegen/model.ts +++ b/src/codegen/model.ts @@ -175,13 +175,21 @@ export type Pagination = /** The answer holds the next page's whole URL. */ | { style: "link"; next: string; items?: string } -/** A key a call must pass: always, or, when `body` or `query` is given, only when one of those flags is `true`. */ +/** + * A key a call must pass: always, or, when `body`, `query` or `values` is given, only when one of those flags is `true` + * or one of those fields holds one of its values. + */ export interface OperationPermission { key: string /** Top-level request body fields. */ body?: readonly string[] /** Query parameters. */ query?: readonly string[] + /** + * A top-level body field or query parameter of this name holding one of these values: `{ status: ["publish"] }`. + * Both places count, as a service that merges them (WordPress) publishes from either. + */ + values?: Readonly> } /** The scheme names an operation needs, each with its OAuth scopes; one requirement of the list is enough. */ diff --git a/src/codegen/pipeline.ts b/src/codegen/pipeline.ts index 491ad09..0b0b252 100644 --- a/src/codegen/pipeline.ts +++ b/src/codegen/pipeline.ts @@ -201,10 +201,22 @@ export interface PermissionRule { deletingFlags?: readonly string[] /** Operation ids that make something public, as a share link does: neither a plain write nor a delete. */ shares?: readonly string[] + /** + * A field whose value is the change, not a flag: WordPress publishes by `status: "publish"`. Each gives + * `.` to every write or delete whose body field or query parameter `field` lists one of `values` in its + * `enum`, so a field of the same name that means something else (a comment's `status`) gets no key, nor does a read + * that filters by the value. Where the field's default is one of `values` (a WordPress template), leaving it out + * publishes too, and the key always applies. + */ + valueKeys?: readonly { key: string; field: string; values: readonly string[] }[] } -/** The top-level property names a body may carry, through references, inheritance, unions and subtypes. */ -const bodyFields = (node: SchemaNode, schemas: ReadonlyMap, seen = new Set()): string[] => { +/** The top-level properties a body may carry, through references, inheritance, unions and subtypes. */ +const bodyFields = ( + node: SchemaNode, + schemas: ReadonlyMap, + seen = new Set(), +): [string, SchemaNode][] => { switch (node.type) { case "ref": { const target = schemas.get(node.ref) @@ -216,7 +228,7 @@ const bodyFields = (node: SchemaNode, schemas: ReadonlyMap, s return [...bodyFields(target.schema, schemas, inner), ...subtypes] } case "object": - return Object.keys(node.properties) + return Object.entries(node.properties) case "union": case "allOf": return node.of.flatMap((member) => bodyFields(member, schemas, seen)) @@ -234,10 +246,58 @@ export const applyPermissionRule = (model: ApiModel, rule: PermissionRule): ApiM const fields = new Map( model.operations.map((operation) => [ operation.id, - new Set(operation.requestBody?.schema ? bodyFields(operation.requestBody.schema, schemas) : []), + new Map(operation.requestBody?.schema ? bodyFields(operation.requestBody.schema, schemas) : []), ]), ) - const fieldsOf = (operation: ApiOperation) => fields.get(operation.id) ?? new Set() + const fieldsOf = (operation: ApiOperation) => fields.get(operation.id) ?? new Map() + /** The enums and defaults of a field, through references and every alternative of a union. */ + const valuesIn = ( + node: SchemaNode | undefined, + seen = new Set(), + ): { enums: unknown[]; defaults: unknown[] } => { + if (!node) return { enums: [], defaults: [] } + const own = { + enums: "enum" in node && node.enum ? [...node.enum] : [], + defaults: node.default === undefined ? [] : [node.default], + } + const inner = + node.type === "ref" && !seen.has(node.ref) + ? [valuesIn(schemas.get(node.ref)?.schema, new Set([...seen, node.ref]))] + : node.type === "union" || node.type === "allOf" + ? node.of.map((member) => valuesIn(member, seen)) + : [] + return { + enums: [...own.enums, ...inner.flatMap((one) => one.enums)], + defaults: [...own.defaults, ...inner.flatMap((one) => one.defaults)], + } + } + const valuesOf = (operation: ApiOperation, name: string) => { + const nodes = [ + fieldsOf(operation).get(name), + operation.parameters.find((parameter) => parameter.in === "query" && parameter.name === name)?.schema, + ].map((node) => valuesIn(node)) + return { enums: nodes.flatMap((one) => one.enums), defaults: nodes.flatMap((one) => one.defaults) } + } + const valueKeys = rule.valueKeys ?? [] + // A field whose default is one of the values publishes when the call leaves it out: the key then always applies. + const valued = (operation: ApiOperation): OperationPermission[] => + operation.effect === "read" + ? [] + : valueKeys.flatMap(({ key, field, values }) => { + const { enums, defaults } = valuesOf(operation, field) + const named = values.filter((value) => enums.includes(value)) + if (named.length === 0) return [] + return defaults.some((value) => values.includes(value as string)) + ? [{ key }] + : [{ key, values: { [field]: named } }] + }) + const idle = valueKeys.filter( + ({ key }) => !model.operations.some((operation) => valued(operation).some((one) => one.key === key)), + ) + if (idle.length > 0) + throw new CodegenError( + idle.map(({ field, values }) => `valueKeys: no write lists ${values.join(" or ")} in the enum of "${field}"`), + ) const unused = flags.filter( (flag) => !model.operations.some( @@ -267,6 +327,7 @@ export const applyPermissionRule = (model: ApiModel, rule: PermissionRule): ApiM ...(query.length > 0 ? { query } : {}), }) } + for (const permission of valued(operation)) permissions.push({ ...permission, key: `${group}.${permission.key}` }) return permissions.length > 0 ? { ...operation, permissions } : operation }), } diff --git a/src/codegen/snapshot.ts b/src/codegen/snapshot.ts new file mode 100644 index 0000000..a9b4e36 --- /dev/null +++ b/src/codegen/snapshot.ts @@ -0,0 +1,16 @@ +import { createHash } from "node:crypto" + +/** The hash a snapshot's `provenance.json` keeps, so a hand edit or a changed file stops generation. */ +export const sha256 = (bytes: string | Buffer): string => createHash("sha256").update(bytes).digest("hex") + +/** A service may send the same description with its keys in another order each time; arrays keep theirs. */ +export const sortKeys = (value: unknown): unknown => + Array.isArray(value) + ? value.map(sortKeys) + : value && typeof value === "object" + ? Object.fromEntries( + Object.keys(value) + .sort() + .map((key) => [key, sortKeys((value as Record)[key])]), + ) + : value diff --git a/src/codegen/wp-json.test.ts b/src/codegen/wp-json.test.ts new file mode 100644 index 0000000..8519e76 --- /dev/null +++ b/src/codegen/wp-json.test.ts @@ -0,0 +1,337 @@ +import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs" +import { tmpdir } from "node:os" +import { join } from "node:path" +import { afterEach, describe, expect, it } from "vitest" +import { + type ApiOperation, + adaptOpenApi, + CodegenError, + coverageGenerator, + definitionsGenerator, + fakeApi, + generate, + type ManifestOperation, + manifestGenerator, + readWpJson, + type SchemaNode, + syncWpJson, + typesGenerator, + valibotGenerator, + wpJsonToOpenApi, +} from "./index.js" + +// Cut from WordPress 6.9.4's own index on a plain install (GPL-2.0-or-later, see the LICENSE beside it). +const excerpt = (): { namespaces: string[]; routes: Record> } => + JSON.parse(readFileSync(join(import.meta.dirname, "../../test/fixtures/wp-json/wp-json-excerpt.json"), "utf8")) + +const POSTS = "/wp/v2/posts" +const POST = "/wp/v2/posts/(?P[\\d]+)" +const TEMPLATE = Object.keys(excerpt().routes).find((route) => route.startsWith("/wp/v2/templates/")) as string + +const problems = (run: () => unknown): string[] => { + try { + run() + } catch (error) { + if (error instanceof CodegenError) return [...error.problems] + throw error + } + return [] +} + +const exported = (content: string | undefined, name: string): unknown => { + const start = content?.indexOf(`export const ${name}`) ?? -1 + const text = content?.slice(content.indexOf("= ", start) + 2).split("\n\nexport ")[0] ?? "" + return JSON.parse(text) +} + +const roots: string[] = [] +afterEach(() => { + for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true }) +}) + +describe("wpJsonToOpenApi", () => { + const { document, omissions } = wpJsonToOpenApi(excerpt(), { namespaces: ["wp/v2"], site: "blog.example" }) + const model = adaptOpenApi(document) + const operation = (id: string) => model.operations.find((one) => one.id === id) + + it("names each call by its method and path, and offers one write where WordPress takes POST, PUT and PATCH", () => { + expect(model.operations.map((one) => one.id)).toEqual( + expect.arrayContaining([ + "getWpV2Posts", + "postWpV2Posts", + "getWpV2PostsById", + "postWpV2PostsById", + "deleteWpV2PostsById", + "postWpV2MediaByIdEdit", + "getWpV2BlockTypesByNamespaceByName", + ]), + ) + expect(model.operations.some((one) => one.id.startsWith("putWpV2") || one.id.startsWith("patchWpV2"))).toBe(false) + expect(omissions).toContain(`${POST}: PUT, PATCH left out, as POST does the same`) + expect(operation("deleteWpV2PostsById")?.effect).toBe("destructive") + expect(model.servers).toEqual([{ url: "https://{site}/wp-json", variables: { site: { default: "blog.example" } } }]) + expect(model.securitySchemes).toEqual({ applicationPassword: { type: "http", scheme: "basic" } }) + }) + + it("leaves out other namespaces, the namespace's own index, and a route whose value may hold a slash", () => { + expect(model.operations.some((one) => one.id.includes("Oembed"))).toBe(false) + expect(omissions).toContain("oembed/1.0: not offered, 1 routes") + expect(operation("getWpV2")).toBeUndefined() + expect(model.operations.some((one) => one.id.includes("Templates"))).toBe(false) + expect(omissions).toContain(`${TEMPLATE}: left out, as its value may hold a slash, which no path segment carries`) + }) + + it("puts a write's arguments in its body, a read's and a delete's in the query, and the route's groups in the path", () => { + const create = operation("postWpV2Posts") + expect(create?.parameters).toEqual([]) + expect(create?.requestBody?.schema).toMatchObject({ + type: "object", + properties: { status: { type: "string", enum: ["publish", "future", "draft", "pending", "private"] } }, + }) + const remove = operation("deleteWpV2PostsById") + expect(remove?.parameters.map((one) => [one.in, one.name])).toEqual([ + ["path", "id"], + ["query", "force"], + ]) + expect(operation("postWpV2PostsById")?.parameters).toMatchObject([{ in: "path", name: "id", required: true }]) + }) + + it("sends a list in the query as one comma-separated value, which WordPress splits and PHP does not repeat", () => { + const include = operation("getWpV2Posts")?.parameters.find((one) => one.name === "include") + expect(include?.schema).toMatchObject({ type: "string" }) + expect(include?.schema.description).toContain("comma-separated") + }) + + it("answers a collection read with a list of the route's schema and an item read with one", () => { + expect(operation("getWpV2Posts")?.response?.schema).toEqual({ type: "array", items: { type: "ref", ref: "post" } }) + expect(operation("getWpV2PostsById")?.response?.schema).toEqual({ type: "ref", ref: "post" }) + expect(operation("deleteWpV2PostsById")?.response?.schema).toBeUndefined() + }) + + it("reads WordPress's draft 4: required in both spellings, bool, an untyped object and free keys by pattern", () => { + const edit = operation("postWpV2MediaByIdEdit")?.requestBody?.schema + expect(JSON.stringify(edit)).toContain( + '"required":["flip"]},"type":{"description":"Flip type.","type":"string","enum":["flip"]}},"required":["type","args"]}', + ) + const blockType = model.schemas.find((one) => one.id === "block_type")?.schema as { + properties: Record + } + expect(blockType.properties.block_hooks).toMatchObject({ + type: "object", + additionalProperties: { type: "string", enum: ["before", "after", "first_child", "last_child"] }, + }) + expect(JSON.stringify(model)).not.toContain('"bool"') + }) + + it("stops on a route it cannot read, a second route on one path, an untyped argument and a stale exclusion", () => { + const index = excerpt() + index.routes["/wp/v2/odd(?:x)"] = { namespace: "wp/v2", methods: ["GET"], endpoints: [] } + index.routes["/wp/v2/posts/(?P[0-9]+)"] = { namespace: "wp/v2", methods: ["GET"], endpoints: [] } + index.routes["/wp/v2/unclosed/(?P[\\d]+"] = { namespace: "wp/v2", methods: ["GET"], endpoints: [] } + index.routes["/wp/v2/digits/(?P[\\/\\d]+)"] = { namespace: "wp/v2", methods: ["GET"], endpoints: [] } + index.routes["/wp/v2/untyped"] = { + namespace: "wp/v2", + methods: ["GET"], + endpoints: [{ methods: ["GET"], args: { anything: { default: 1 } } }], + } + expect(problems(() => wpJsonToOpenApi(index, { namespaces: ["wp/v2"], exclude: { "/wp/v2/gone": "r" } }))).toEqual([ + "/wp/v2/odd(?:x): the route is a pattern no path template expresses; exclude it with a reason", + "/wp/v2/posts/(?P[0-9]+): a second route on /wp/v2/posts/{id}; exclude one with a reason", + "/wp/v2/unclosed/(?P[\\d]+: the route is a pattern no path template expresses; exclude it with a reason", + "/wp/v2/untyped GET anything: no type", + 'exclusion "/wp/v2/gone" matches no route — stale, or the route changed', + ]) + const excluded = wpJsonToOpenApi(index, { + namespaces: ["wp/v2"], + exclude: { + "/wp/v2/odd(?:x)": "test", + "/wp/v2/posts/(?P[0-9]+)": "test", + "/wp/v2/untyped": "test", + "/wp/v2/unclosed/(?P[\\d]+": "test", + }, + }) + expect(excluded.omissions).toContain( + "/wp/v2/digits/(?P[\\/\\d]+): left out, as its value may hold a slash, which no path segment carries", + ) + expect(excluded.omissions).toContain("/wp/v2/untyped: excluded — test") + expect(problems(() => wpJsonToOpenApi({}, { namespaces: ["wp/v2"] }))).toEqual([ + "not a WordPress REST index: no routes", + ]) + }) +}) + +describe("the api group of a WordPress CLI from its snapshot", () => { + const model = adaptOpenApi(wpJsonToOpenApi(excerpt(), { namespaces: ["wp/v2"] }).document) + const group = (one: ApiOperation) => (one.binding.kind === "http" ? (one.binding.path.split("/")[3] ?? "wp") : "wp") + const build = (valueKeys: readonly { key: string; field: string; values: readonly string[] }[]) => + generate( + model, + [ + manifestGenerator({ path: "manifest.ts" }), + definitionsGenerator({ path: "definitions.ts" }), + coverageGenerator({ path: "API.md", title: "API", command: (one) => one.command }), + typesGenerator({ path: "types.ts" }), + valibotGenerator({ path: "schemas.ts", typesImport: "./types.js" }), + ], + { banner: [], permissions: { group, valueKeys } }, + ) + const [manifest, definitions, coverage] = build([{ key: "publish", field: "status", values: ["publish", "future"] }]) + const operations = exported(manifest?.content, "operations") as ManifestOperation[] + const permissionsOf = (id: string) => operations.find((one) => one.id === id)?.permissions + + it("needs posts.publish to create or change a post with status publish or future, pages.publish for a page", () => { + expect(permissionsOf("postWpV2Posts")).toEqual([ + { key: "posts.publish", values: { status: ["publish", "future"] } }, + ]) + expect(permissionsOf("postWpV2PostsById")).toEqual([ + { key: "posts.publish", values: { status: ["publish", "future"] } }, + ]) + expect(permissionsOf("postWpV2Pages")).toEqual([ + { key: "pages.publish", values: { status: ["publish", "future"] } }, + ]) + expect(coverage?.content).toContain("| `postWpV2Posts` | `posts.publish` | `status` is publish or future |") + }) + + it("needs the key on every call where leaving the field out publishes, as a menu item's status defaults to publish", () => { + expect(permissionsOf("postWpV2MenuItems")).toEqual([{ key: "menu-items.publish" }]) + expect(coverage?.content).toContain("| `postWpV2MenuItems` | `menu-items.publish` | always |") + }) + + it("finds the values through a reference or a union, and leaves a read that filters by them alone", () => { + const status: SchemaNode = { type: "string", enum: ["publish", "draft"] } + const operationWith = (id: string, effect: "read" | "write", schema: SchemaNode): ApiOperation => ({ + id, + binding: { kind: "http", method: effect === "read" ? "GET" : "POST", path: `/${id}` }, + effect, + tags: [], + parameters: effect === "read" ? [{ name: "status", in: "query", required: false, schema }] : [], + ...(effect === "write" + ? { + requestBody: { + confidence: "contract" as const, + required: true, + schema: { type: "object" as const, properties: { status: schema }, required: [] }, + }, + } + : {}), + source: { location: id }, + }) + const small = { + source: { kind: "openapi" as const }, + schemas: [{ id: "Status", schema: status }], + operations: [ + operationWith("byUnion", "write", { type: "union", of: [{ type: "integer" }, status] }), + operationWith("byRef", "write", { type: "ref", ref: "Status" }), + operationWith("filter", "read", status), + ], + } + const [built] = generate(small, [manifestGenerator({ path: "manifest.ts" })], { + banner: [], + permissions: { group: "posts", valueKeys: [{ key: "publish", field: "status", values: ["publish"] }] }, + }) + const listed = exported(built?.content, "operations") as ManifestOperation[] + const keys = Object.fromEntries(listed.map((one) => [one.id, one.permissions])) + expect(keys).toEqual({ + byUnion: [{ key: "posts.publish", values: { status: ["publish"] } }], + byRef: [{ key: "posts.publish", values: { status: ["publish"] } }], + filter: undefined, + }) + }) + + it("gives no publish key to a field of that name that lists no such value, as a comment's status", () => { + expect(permissionsOf("postWpV2Comments")).toBeUndefined() + expect(permissionsOf("deleteWpV2PostsById")).toEqual([{ key: "posts.delete" }]) + expect(problems(() => build([{ key: "publish", field: "status", values: ["published"] }]))).toEqual([ + 'valueKeys: no write lists published in the enum of "status"', + ]) + }) + + it("serves the generated calls from a fake that checks the application password", async () => { + const fake = fakeApi({ + operations, + definitions: exported(definitions?.content, "definitions") as Record, + baseUrl: "https://blog.example/wp-json", + ...(model.securitySchemes ? { securitySchemes: model.securitySchemes } : {}), + ...(model.security ? { security: model.security } : {}), + token: "editor:abcd efgh", + }) + const authorization = `Basic ${Buffer.from("editor:abcd efgh").toString("base64")}` + const posts = await fake.fetch("https://blog.example/wp-json/wp/v2/posts?per_page=2", { + headers: { authorization }, + }) + expect(posts.status).toBe(200) + expect(Array.isArray(await posts.json())).toBe(true) + const wrong = await fake.fetch("https://blog.example/wp-json/wp/v2/posts", { + headers: { authorization: `Basic ${Buffer.from("editor:nope").toString("base64")}` }, + }) + expect(wrong.status).toBe(401) + }) +}) + +describe("syncWpJson and readWpJson", () => { + it("keeps only the API, not the site or a password in its address, and refuses a snapshot changed by hand", async () => { + const dir = mkdtempSync(join(tmpdir(), "wp-json-")) + roots.push(dir) + const site = { + name: "Owner's blog", + url: "https://owner.example", + namespaces: ["wp/v2"], + routes: { + [POSTS]: { + namespace: "wp/v2", + methods: ["GET"], + endpoints: [{ methods: ["GET"], args: {} }], + schema: { title: "post", type: "object", properties: {}, links: [{ href: "https://owner.example/x" }] }, + _links: { self: [{ href: "https://owner.example/wp-json/wp/v2/posts" }] }, + }, + }, + } + const asked: string[] = [] + const fetch = (async (input: string | URL) => { + asked.push(String(input)) + return Response.json(site) + }) as typeof globalThis.fetch + const provenance = await syncWpJson({ + root: "https://editor:secret@owner.example/wp-json/", + dir, + version: "6.9.4", + fetch, + now: new Date("2026-11-18T00:00:00Z"), + }) + expect(asked).toEqual(["https://owner.example/wp-json/?context=help"]) + expect(provenance).toMatchObject({ + source: "https://owner.example/wp-json/?context=help", + version: "6.9.4", + retrieved_at: "2026-11-18T00:00:00.000Z", + }) + expect(readFileSync(join(dir, "provenance.json"), "utf8")).not.toContain("secret") + const written = readFileSync(join(dir, "wp-json.json"), "utf8") + expect(written).not.toContain("owner") + expect(readWpJson(dir)).toEqual({ + namespaces: ["wp/v2"], + routes: { + [POSTS]: { + endpoints: [{ args: {}, methods: ["GET"] }], + methods: ["GET"], + namespace: "wp/v2", + schema: { properties: {}, title: "post", type: "object" }, + }, + }, + }) + writeFileSync(join(dir, "wp-json.json"), written.replace('"GET"', '"POST"')) + expect(problems(() => readWpJson(dir))).toEqual([`WordPress index hash mismatch: ${join(dir, "wp-json.json")}`]) + }) + + it("names a site that does not answer an index", async () => { + const dir = mkdtempSync(join(tmpdir(), "wp-json-")) + roots.push(dir) + const answer = (body: unknown, status = 200) => + (async () => Response.json(body, { status })) as unknown as typeof globalThis.fetch + await expect( + syncWpJson({ root: "https://x.example/wp-json/", dir, version: "6", fetch: answer({}, 404) }), + ).rejects.toThrow("WordPress index fetch failed: HTTP 404") + await expect( + syncWpJson({ root: "https://x.example/wp-json/", dir, version: "6", fetch: answer({}) }), + ).rejects.toThrow("https://x.example/wp-json/ is not a WordPress REST index") + }) +}) diff --git a/src/codegen/wp-json.ts b/src/codegen/wp-json.ts new file mode 100644 index 0000000..0049595 --- /dev/null +++ b/src/codegen/wp-json.ts @@ -0,0 +1,364 @@ +/** + * WordPress's REST index (`/wp-json/?context=help`), already parsed → an OpenAPI 3.1 document, so `adaptOpenApi` reads + * it like any other. WordPress publishes no OpenAPI: the index lists each route's endpoints with their arguments, and + * with `context=help` also the schema of what the route answers, the same one an `OPTIONS` call returns. One request + * holds the whole API, so `syncWpJson` keeps that one answer with its provenance and `readWpJson` loads it back only + * while its hash still matches. + * + * Strict like `adaptOpenApi`: a route that cannot become a path template, two routes on one path, or an argument with + * no type stops generation unless `exclude` names the route with a reason. + */ +import { mkdirSync, readFileSync, writeFileSync } from "node:fs" +import { join } from "node:path" +import { CodegenError } from "./pipeline.js" +import { sha256, sortKeys } from "./snapshot.js" + +type Json = Record + +const object = (value: unknown): value is Json => !!value && typeof value === "object" && !Array.isArray(value) + +export interface WpJsonOptions { + /** The namespaces the CLI offers, as `wp/v2`; every other route is left out and listed in `omissions`. */ + namespaces: readonly string[] + /** Routes, as the index spells them, left out with the reason. One that matches no route stops generation. */ + exclude?: Readonly> + /** The `site` server variable's default: the host in `https://{site}/wp-json`. */ + site?: string + /** The WordPress version the snapshot came from, as `info.version`. */ + version?: string +} + +export interface WpJsonResult { + /** An OpenAPI 3.1 document for `adaptOpenApi`. */ + document: Json + /** What the document leaves out, one line each, for a reviewer. */ + omissions: string[] +} + +/** WordPress's own, beside JSON Schema: which `context` shows a field, and its spelling of `readOnly`. */ +const DROPPED = new Set(["context", "readonly", "arg_options", "links", "$schema", "patternProperties", "required"]) + +/** WordPress names the boolean type `bool` in a few block attributes. */ +const typeName = (type: unknown): unknown => + type === "bool" ? "boolean" : Array.isArray(type) ? type.map(typeName) : type + +/** + * One JSON Schema draft 4 node, as WordPress writes it, → its OpenAPI 3.1 form: a field's `required: true` joins its + * object's `required` list, a node with `properties` and no type is an object, and a draft 4 `exclusiveMinimum: true` + * goes, keeping `minimum`, which accepts one value more and refuses nothing valid. `patternProperties` (block names to their hooks) becomes the object's + * `additionalProperties`: the keys are free, the values keep their schema. + */ +const schemaOf = (value: unknown, where: string): Json => { + if (!object(value)) throw new CodegenError([`${where}: expected a schema object`]) + const out: Json = {} + for (const [key, field] of Object.entries(value)) { + if (DROPPED.has(key)) continue + if ((key === "exclusiveMinimum" || key === "exclusiveMaximum") && typeof field === "boolean") continue + if (key === "type") out.type = typeName(field) + else if (key === "properties" && object(field)) + out.properties = Object.fromEntries( + Object.entries(field).map(([name, inner]) => [name, schemaOf(inner, `${where}/properties/${name}`)]), + ) + else if (key === "items") out.items = schemaOf(field, `${where}/items`) + else if ((key === "oneOf" || key === "anyOf") && Array.isArray(field)) + // A `required` beside the alternatives names fields each of them holds. + out[key] = field.map((member, index) => + schemaOf( + object(member) && Array.isArray(value.required) && object(member.properties) + ? { + ...member, + required: [...new Set([...(Array.isArray(member.required) ? member.required : []), ...value.required])], + } + : member, + `${where}/${key}/${index}`, + ), + ) + else if (key === "additionalProperties" && object(field)) + out.additionalProperties = schemaOf(field, `${where}/additionalProperties`) + else out[key] = field + } + if (object(value.properties)) { + const required = [ + ...(Array.isArray(value.required) ? value.required.map(String) : []), + ...Object.entries(value.properties) + .filter(([, inner]) => object(inner) && inner.required === true) + .map(([name]) => name), + ] + if (required.length > 0) out.required = [...new Set(required)] + out.type ??= "object" + } + if (object(value.patternProperties) && out.additionalProperties === undefined) { + const members = Object.entries(value.patternProperties).map(([pattern, inner]) => + schemaOf(inner, `${where}/patternProperties/${pattern}`), + ) + out.additionalProperties = members.length === 1 ? members[0] : { anyOf: members } + } + if (out.type === undefined && out.oneOf === undefined && out.anyOf === undefined) + throw new CodegenError([`${where}: no type`]) + return out +} + +/** + * `(?P[\d]+)` → `{id}`, with the group's pattern; `"slash"` when a value may hold one; `undefined` when the rest + * is still a pattern, not a path. + */ +const template = (route: string): { path: string; patterns: Record } | "slash" | undefined => { + const patterns: Record = {} + let path = "" + let at = 0 + while (at < route.length) { + const start = route.indexOf("(?P<", at) + if (start < 0) { + path += route.slice(at) + break + } + path += route.slice(at, start) + const close = route.indexOf(">", start) + const name = route.slice(start + 4, close) + let depth = 1 + let index = close + 1 + let inClass = false + for (; index < route.length && depth > 0; index++) { + const char = route[index] + if (char === "\\") index++ + else if (inClass) inClass = char !== "]" + else if (char === "[") inClass = true + else if (char === "(") depth++ + else if (char === ")") depth-- + } + if (depth > 0) return undefined + patterns[name] = route.slice(close + 1, index - 1) + path += `{${name}}` + at = index + } + if (/[()[\]?*+\\^$|]/.test(path)) return undefined + // A value that may hold a slash, as a template's `theme//slug`, does not fit in one path segment. + const slashed = (pattern: string) => { + try { + const regex = new RegExp(`^(?:${pattern})$`) + return ["a/b", "1/2", "/", "a/", "/a", "a-b/c_d", "1/a"].some((sample) => regex.test(sample)) + } catch { + return true + } + } + if (Object.values(patterns).some(slashed)) return "slash" + return { path, patterns } +} + +/** Collection reads page with `page` and `per_page` and answer a list; every other answer is one item. */ +const isList = (args: Json) => "per_page" in args && "page" in args + +/** + * The OpenAPI document of the routes under `namespaces`. A route offers GET as a read, DELETE as a delete with its + * arguments in the query (`force=true`), and one write: POST where the route takes it, as WordPress takes the same + * call by POST, PUT and PATCH. A write's arguments are its JSON body. An array argument in the query travels as one + * comma-separated value, which WordPress splits, as PHP keeps only the last of a repeated name. + */ +export const wpJsonToOpenApi = (index: unknown, options: WpJsonOptions): WpJsonResult => { + if (!object(index) || !object(index.routes)) throw new CodegenError(["not a WordPress REST index: no routes"]) + const exclude = options.exclude ?? {} + const used = new Set() + const problems: string[] = [] + const omissions: string[] = [] + const paths: Record = {} + const schemas: Record = {} + const left = new Map() + const schemaRef = (route: string, schema: unknown): Json => { + const title = object(schema) && typeof schema.title === "string" ? schema.title : route + const base = title.replace(/[^A-Za-z0-9]+/g, "_") + const converted = schemaOf(schema, `${route} schema`) + let name = base + for (let n = 2; schemas[name] && JSON.stringify(schemas[name]) !== JSON.stringify(converted); n++) + name = `${base}${n}` + schemas[name] = converted + return { $ref: `#/components/schemas/${name}` } + } + + for (const [route, raw] of Object.entries(index.routes)) { + if (!object(raw)) throw new CodegenError([`${route}: not a route`]) + const namespace = String(raw.namespace ?? "") + if (!options.namespaces.includes(namespace)) { + left.set(namespace, (left.get(namespace) ?? 0) + 1) + continue + } + // The namespace's own index: the description, not an operation. + if (route === `/${namespace}`) continue + if (exclude[route] !== undefined) { + used.add(route) + omissions.push(`${route}: excluded — ${exclude[route]}`) + continue + } + const templated = template(route) + if (templated === "slash") { + omissions.push(`${route}: left out, as its value may hold a slash, which no path segment carries`) + continue + } + if (!templated) { + problems.push(`${route}: the route is a pattern no path template expresses; exclude it with a reason`) + continue + } + const { path, patterns } = templated + if (paths[path]) { + problems.push(`${route}: a second route on ${path}; exclude one with a reason`) + continue + } + const item: Json = {} + const endpoints = Array.isArray(raw.endpoints) ? raw.endpoints.filter(object) : [] + try { + for (const endpoint of endpoints) { + const methods = (Array.isArray(endpoint.methods) ? endpoint.methods : []).map(String) + const args = object(endpoint.args) ? endpoint.args : {} + const write = ["POST", "PUT", "PATCH"].find((method) => methods.includes(method)) + const dropped = methods.filter((method) => method !== write && ["PUT", "PATCH"].includes(method)) + if (dropped.length > 0) omissions.push(`${route}: ${dropped.join(", ")} left out, as ${write} does the same`) + for (const method of methods.filter((one) => one === "GET" || one === "DELETE" || one === write)) { + const verb = method.toLowerCase() + if (item[verb]) throw new CodegenError([`${route}: two endpoints answer ${method}`]) + const where = `${route} ${method}` + const pathParameters = Object.entries(patterns).map(([name, pattern]) => ({ + name, + in: "path", + required: true, + schema: object(args[name]) + ? schemaOf(args[name], `${where} ${name}`) + : { type: "string", pattern: `^(?:${pattern})$` }, + })) + const rest = Object.entries(args).filter(([name]) => patterns[name] === undefined) + const operation: Json = { parameters: pathParameters } + if (method === write) { + if (rest.length > 0) + operation.requestBody = { + required: rest.some(([, arg]) => object(arg) && arg.required === true), + content: { + "application/json": { + schema: schemaOf({ type: "object", properties: Object.fromEntries(rest) }, `${where} body`), + }, + }, + } + } else + operation.parameters = [ + ...pathParameters, + ...rest.map(([name, arg]) => { + const schema = schemaOf(arg, `${where} ${name}`) + const list = schema.type === "array" || (Array.isArray(schema.type) && schema.type.includes("array")) + return { + name, + in: "query", + required: object(arg) && arg.required === true, + ...(typeof schema.description === "string" ? { description: schema.description } : {}), + schema: list + ? { type: "string", description: `${schema.description ?? name}; several, comma-separated` } + : schema, + } + }), + ] + if (raw.schema !== undefined && method !== "DELETE") { + const ref = schemaRef(route, raw.schema) + const answer = method === "GET" && isList(args) ? { type: "array", items: ref } : ref + operation.responses = { "200": { description: "OK", content: { "application/json": { schema: answer } } } } + } else operation.responses = { "200": { description: "OK" } } + item[verb] = operation + } + } + } catch (error) { + if (!(error instanceof CodegenError)) throw error + for (const problem of error.problems) problems.push(problem) + continue + } + if (Object.keys(item).length > 0) paths[path] = item + } + for (const [namespace, count] of left) + omissions.push(`${namespace || "routes outside a namespace"}: not offered, ${count} routes`) + const stale = Object.keys(exclude).filter((route) => !used.has(route)) + for (const route of stale) problems.push(`exclusion "${route}" matches no route — stale, or the route changed`) + if (problems.length > 0) throw new CodegenError(problems) + return { + document: { + openapi: "3.1.0", + info: { title: "WordPress REST API", version: options.version ?? "unknown" }, + servers: [{ url: "https://{site}/wp-json", variables: { site: { default: options.site ?? "example.com" } } }], + // An application password, sent as Basic `:`. + components: { schemas, securitySchemes: { applicationPassword: { type: "http", scheme: "basic" } } }, + security: [{ applicationPassword: [] }], + paths, + }, + omissions, + } +} + +/** The snapshot's entry in `provenance.json`. */ +export interface WpJsonProvenance { + source: string + /** The WordPress version it came from; the index does not say it. */ + version: string + /** Of the committed file; `readWpJson` refuses a snapshot that no longer matches it. */ + sha256: string + retrieved_at: string + normalization: string +} + +const FILE = "wp-json.json" + +/** The site's name, address, time zone and links go, the schemas' `links` too: the API is the same from any site. */ +const ROUTE_FIELDS = ["namespace", "methods", "endpoints", "schema"] + +/** + * Asks `root` (`https:///wp-json/`) for its index with every schema and writes `wp-json.json` and + * `provenance.json` to `dir`. Take it from a plain WordPress, as the CLI serves every site: a plugin's routes and + * fields belong to that site. Run by hand, then review the diff: the build never fetches. + */ +export const syncWpJson = async (options: { + root: string + dir: string + version: string + fetch?: typeof globalThis.fetch + now?: Date +}): Promise => { + const fetch = options.fetch ?? globalThis.fetch + const url = new URL(options.root) + // The URL goes into provenance.json; a user or password in it must not. + url.username = "" + url.password = "" + url.searchParams.set("context", "help") + const response = await fetch(url, { signal: AbortSignal.timeout(30_000), redirect: "error" }) + if (!response.ok) throw new Error(`WordPress index fetch failed: HTTP ${response.status}`) + const index: unknown = await response.json() + if (!object(index) || !object(index.routes) || !Array.isArray(index.namespaces)) + throw new Error(`${options.root} is not a WordPress REST index`) + const routes = Object.fromEntries( + Object.entries(index.routes).map(([route, value]) => [ + route, + object(value) + ? Object.fromEntries( + ROUTE_FIELDS.filter((key) => key in value).map((key) => { + const field = value[key] + if (key !== "schema" || !object(field)) return [key, field] + const { links: _, ...schema } = field + return [key, schema] + }), + ) + : value, + ]), + ) + const written = `${JSON.stringify(sortKeys({ namespaces: index.namespaces, routes }), null, 2)}\n` + const provenance: WpJsonProvenance = { + source: url.href, + version: options.version, + sha256: sha256(written), + retrieved_at: (options.now ?? new Date()).toISOString(), + normalization: + "the namespaces and each route's namespace, methods, endpoints and schema (without its links); keys sorted, 2-space JSON", + } + mkdirSync(options.dir, { recursive: true }) + writeFileSync(join(options.dir, FILE), written) + writeFileSync(join(options.dir, "provenance.json"), `${JSON.stringify(provenance, null, 2)}\n`) + return provenance +} + +/** The snapshot `syncWpJson` wrote, parsed. Throws if its hash changed. */ +export const readWpJson = (dir: string): unknown => { + const provenance = JSON.parse(readFileSync(join(dir, "provenance.json"), "utf8")) as { sha256?: string } + const raw = readFileSync(join(dir, FILE)) + if (sha256(raw) !== provenance.sha256) throw new CodegenError([`WordPress index hash mismatch: ${join(dir, FILE)}`]) + return JSON.parse(raw.toString("utf8")) +} diff --git a/test/fixtures/wp-json/LICENSE b/test/fixtures/wp-json/LICENSE new file mode 100644 index 0000000..d9fa3ca --- /dev/null +++ b/test/fixtures/wp-json/LICENSE @@ -0,0 +1,8 @@ +The routes, arguments and schemas in wp-json-excerpt.json are cut from the REST index of WordPress 6.9.4 +(GET /wp-json/?context=help on a plain install, no plugins), taken on 2026-11-18. + +WordPress - Web publishing software +Copyright 2011-2026 by the contributors + +WordPress is released under the GNU General Public License, version 2 or later: +https://wordpress.org/about/license/ and https://www.gnu.org/licenses/old-licenses/gpl-2.0.html diff --git a/test/fixtures/wp-json/wp-json-excerpt.json b/test/fixtures/wp-json/wp-json-excerpt.json new file mode 100644 index 0000000..4d9840e --- /dev/null +++ b/test/fixtures/wp-json/wp-json-excerpt.json @@ -0,0 +1,4510 @@ +{ + "namespaces": ["oembed/1.0", "wp/v2", "wp-site-health/v1", "wp-block-editor/v1", "wp-abilities/v1"], + "routes": { + "/wp/v2": { + "endpoints": [ + { + "args": { + "context": { + "default": "view", + "required": false + }, + "namespace": { + "default": "wp/v2", + "required": false + } + }, + "methods": ["GET"] + } + ], + "methods": ["GET"], + "namespace": "wp/v2" + }, + "/wp/v2/posts": { + "endpoints": [ + { + "allow_batch": { + "v1": true + }, + "args": { + "after": { + "description": "Limit response to posts published after a given ISO8601 compliant date.", + "format": "date-time", + "required": false, + "type": "string" + }, + "author": { + "default": [], + "description": "Limit result set to posts assigned to specific authors.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "author_exclude": { + "default": [], + "description": "Ensure result set excludes posts assigned to specific authors.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "before": { + "description": "Limit response to posts published before a given ISO8601 compliant date.", + "format": "date-time", + "required": false, + "type": "string" + }, + "categories": { + "description": "Limit result set to items with specific terms assigned in the categories taxonomy.", + "oneOf": [ + { + "description": "Match terms with the listed IDs.", + "items": { + "type": "integer" + }, + "title": "Term ID List", + "type": "array" + }, + { + "additionalProperties": false, + "description": "Perform an advanced term query.", + "properties": { + "include_children": { + "default": false, + "description": "Whether to include child terms in the terms limiting the result set.", + "type": "boolean" + }, + "operator": { + "default": "OR", + "description": "Whether items must be assigned all or any of the specified terms.", + "enum": ["AND", "OR"], + "type": "string" + }, + "terms": { + "default": [], + "description": "Term IDs.", + "items": { + "type": "integer" + }, + "type": "array" + } + }, + "title": "Term ID Taxonomy Query", + "type": "object" + } + ], + "required": false, + "type": ["object", "array"] + }, + "categories_exclude": { + "description": "Limit result set to items except those with specific terms assigned in the categories taxonomy.", + "oneOf": [ + { + "description": "Match terms with the listed IDs.", + "items": { + "type": "integer" + }, + "title": "Term ID List", + "type": "array" + }, + { + "additionalProperties": false, + "description": "Perform an advanced term query.", + "properties": { + "include_children": { + "default": false, + "description": "Whether to include child terms in the terms limiting the result set.", + "type": "boolean" + }, + "terms": { + "default": [], + "description": "Term IDs.", + "items": { + "type": "integer" + }, + "type": "array" + } + }, + "title": "Term ID Taxonomy Query", + "type": "object" + } + ], + "required": false, + "type": ["object", "array"] + }, + "context": { + "default": "view", + "description": "Scope under which the request is made; determines fields present in response.", + "enum": ["view", "embed", "edit"], + "required": false, + "type": "string" + }, + "exclude": { + "default": [], + "description": "Ensure result set excludes specific IDs.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "format": { + "description": "Limit result set to items assigned one or more given formats.", + "items": { + "enum": ["standard", "aside", "chat", "gallery", "link", "image", "quote", "status", "video", "audio"], + "type": "string" + }, + "required": false, + "type": "array", + "uniqueItems": true + }, + "ignore_sticky": { + "default": true, + "description": "Whether to ignore sticky posts or not.", + "required": false, + "type": "boolean" + }, + "include": { + "default": [], + "description": "Limit result set to specific IDs.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "modified_after": { + "description": "Limit response to posts modified after a given ISO8601 compliant date.", + "format": "date-time", + "required": false, + "type": "string" + }, + "modified_before": { + "description": "Limit response to posts modified before a given ISO8601 compliant date.", + "format": "date-time", + "required": false, + "type": "string" + }, + "offset": { + "description": "Offset the result set by a specific number of items.", + "required": false, + "type": "integer" + }, + "order": { + "default": "desc", + "description": "Order sort attribute ascending or descending.", + "enum": ["asc", "desc"], + "required": false, + "type": "string" + }, + "orderby": { + "default": "date", + "description": "Sort collection by post attribute.", + "enum": [ + "author", + "date", + "id", + "include", + "modified", + "parent", + "relevance", + "slug", + "include_slugs", + "title" + ], + "required": false, + "type": "string" + }, + "page": { + "default": 1, + "description": "Current page of the collection.", + "minimum": 1, + "required": false, + "type": "integer" + }, + "per_page": { + "default": 10, + "description": "Maximum number of items to be returned in result set.", + "maximum": 100, + "minimum": 1, + "required": false, + "type": "integer" + }, + "search": { + "description": "Limit results to those matching a string.", + "required": false, + "type": "string" + }, + "search_columns": { + "default": [], + "description": "Array of column names to be searched.", + "items": { + "enum": ["post_title", "post_content", "post_excerpt"], + "type": "string" + }, + "required": false, + "type": "array" + }, + "search_semantics": { + "description": "How to interpret the search input.", + "enum": ["exact"], + "required": false, + "type": "string" + }, + "slug": { + "description": "Limit result set to posts with one or more specific slugs.", + "items": { + "type": "string" + }, + "required": false, + "type": "array" + }, + "status": { + "default": "publish", + "description": "Limit result set to posts assigned one or more statuses.", + "items": { + "enum": [ + "publish", + "future", + "draft", + "pending", + "private", + "trash", + "auto-draft", + "inherit", + "request-pending", + "request-confirmed", + "request-failed", + "request-completed", + "any" + ], + "type": "string" + }, + "required": false, + "type": "array" + }, + "sticky": { + "description": "Limit result set to items that are sticky.", + "required": false, + "type": "boolean" + }, + "tags": { + "description": "Limit result set to items with specific terms assigned in the tags taxonomy.", + "oneOf": [ + { + "description": "Match terms with the listed IDs.", + "items": { + "type": "integer" + }, + "title": "Term ID List", + "type": "array" + }, + { + "additionalProperties": false, + "description": "Perform an advanced term query.", + "properties": { + "operator": { + "default": "OR", + "description": "Whether items must be assigned all or any of the specified terms.", + "enum": ["AND", "OR"], + "type": "string" + }, + "terms": { + "default": [], + "description": "Term IDs.", + "items": { + "type": "integer" + }, + "type": "array" + } + }, + "title": "Term ID Taxonomy Query", + "type": "object" + } + ], + "required": false, + "type": ["object", "array"] + }, + "tags_exclude": { + "description": "Limit result set to items except those with specific terms assigned in the tags taxonomy.", + "oneOf": [ + { + "description": "Match terms with the listed IDs.", + "items": { + "type": "integer" + }, + "title": "Term ID List", + "type": "array" + }, + { + "additionalProperties": false, + "description": "Perform an advanced term query.", + "properties": { + "terms": { + "default": [], + "description": "Term IDs.", + "items": { + "type": "integer" + }, + "type": "array" + } + }, + "title": "Term ID Taxonomy Query", + "type": "object" + } + ], + "required": false, + "type": ["object", "array"] + }, + "tax_relation": { + "description": "Limit result set based on relationship between multiple taxonomies.", + "enum": ["AND", "OR"], + "required": false, + "type": "string" + } + }, + "methods": ["GET"] + }, + { + "allow_batch": { + "v1": true + }, + "args": { + "author": { + "description": "The ID for the author of the post.", + "required": false, + "type": "integer" + }, + "categories": { + "description": "The terms assigned to the post in the category taxonomy.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "comment_status": { + "description": "Whether or not comments are open on the post.", + "enum": ["open", "closed"], + "required": false, + "type": "string" + }, + "content": { + "description": "The content for the post.", + "properties": { + "block_version": { + "context": ["edit"], + "description": "Version of the content block format used by the post.", + "readonly": true, + "type": "integer" + }, + "protected": { + "context": ["view", "edit", "embed"], + "description": "Whether the content is protected with a password.", + "readonly": true, + "type": "boolean" + }, + "raw": { + "context": ["edit"], + "description": "Content for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit"], + "description": "HTML content for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "date": { + "description": "The date the post was published, in the site's timezone.", + "format": "date-time", + "required": false, + "type": ["string", "null"] + }, + "date_gmt": { + "description": "The date the post was published, as GMT.", + "format": "date-time", + "required": false, + "type": ["string", "null"] + }, + "excerpt": { + "description": "The excerpt for the post.", + "properties": { + "protected": { + "context": ["view", "edit", "embed"], + "description": "Whether the excerpt is protected with a password.", + "readonly": true, + "type": "boolean" + }, + "raw": { + "context": ["edit"], + "description": "Excerpt for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML excerpt for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "featured_media": { + "description": "The ID of the featured media for the post.", + "required": false, + "type": "integer" + }, + "format": { + "description": "The format for the post.", + "enum": ["standard", "aside", "chat", "gallery", "link", "image", "quote", "status", "video", "audio"], + "required": false, + "type": "string" + }, + "meta": { + "description": "Meta fields.", + "properties": { + "footnotes": { + "default": "", + "description": "", + "title": "", + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "password": { + "description": "A password to protect access to the content and excerpt.", + "required": false, + "type": "string" + }, + "ping_status": { + "description": "Whether or not the post can be pinged.", + "enum": ["open", "closed"], + "required": false, + "type": "string" + }, + "slug": { + "description": "An alphanumeric identifier for the post unique to its type.", + "required": false, + "type": "string" + }, + "status": { + "description": "A named status for the post.", + "enum": ["publish", "future", "draft", "pending", "private"], + "required": false, + "type": "string" + }, + "sticky": { + "description": "Whether or not the post should be treated as sticky.", + "required": false, + "type": "boolean" + }, + "tags": { + "description": "The terms assigned to the post in the post_tag taxonomy.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "template": { + "description": "The theme file to use to display the post.", + "required": false, + "type": "string" + }, + "title": { + "description": "The title for the post.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Title for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML title for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + } + }, + "methods": ["POST"] + } + ], + "methods": ["GET", "POST"], + "namespace": "wp/v2", + "schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "properties": { + "author": { + "context": ["view", "edit", "embed"], + "description": "The ID for the author of the post.", + "type": "integer" + }, + "categories": { + "context": ["view", "edit"], + "description": "The terms assigned to the post in the category taxonomy.", + "items": { + "type": "integer" + }, + "type": "array" + }, + "class_list": { + "context": ["view", "edit"], + "description": "An array of the class names for the post container element.", + "items": { + "type": "string" + }, + "readonly": true, + "type": "array" + }, + "comment_status": { + "context": ["view", "edit"], + "description": "Whether or not comments are open on the post.", + "enum": ["open", "closed"], + "type": "string" + }, + "content": { + "context": ["view", "edit"], + "description": "The content for the post.", + "properties": { + "block_version": { + "context": ["edit"], + "description": "Version of the content block format used by the post.", + "readonly": true, + "type": "integer" + }, + "protected": { + "context": ["view", "edit", "embed"], + "description": "Whether the content is protected with a password.", + "readonly": true, + "type": "boolean" + }, + "raw": { + "context": ["edit"], + "description": "Content for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit"], + "description": "HTML content for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "type": "object" + }, + "date": { + "context": ["view", "edit", "embed"], + "description": "The date the post was published, in the site's timezone.", + "format": "date-time", + "type": ["string", "null"] + }, + "date_gmt": { + "context": ["view", "edit"], + "description": "The date the post was published, as GMT.", + "format": "date-time", + "type": ["string", "null"] + }, + "excerpt": { + "context": ["view", "edit", "embed"], + "description": "The excerpt for the post.", + "properties": { + "protected": { + "context": ["view", "edit", "embed"], + "description": "Whether the excerpt is protected with a password.", + "readonly": true, + "type": "boolean" + }, + "raw": { + "context": ["edit"], + "description": "Excerpt for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML excerpt for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "type": "object" + }, + "featured_media": { + "context": ["view", "edit", "embed"], + "description": "The ID of the featured media for the post.", + "type": "integer" + }, + "format": { + "context": ["view", "edit"], + "description": "The format for the post.", + "enum": ["standard", "aside", "chat", "gallery", "link", "image", "quote", "status", "video", "audio"], + "type": "string" + }, + "generated_slug": { + "context": ["edit"], + "description": "Slug automatically generated from the post title.", + "readonly": true, + "type": "string" + }, + "guid": { + "context": ["view", "edit"], + "description": "The globally unique identifier for the post.", + "properties": { + "raw": { + "context": ["edit"], + "description": "GUID for the post, as it exists in the database.", + "readonly": true, + "type": "string" + }, + "rendered": { + "context": ["view", "edit"], + "description": "GUID for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "readonly": true, + "type": "object" + }, + "id": { + "context": ["view", "edit", "embed"], + "description": "Unique identifier for the post.", + "readonly": true, + "type": "integer" + }, + "link": { + "context": ["view", "edit", "embed"], + "description": "URL to the post.", + "format": "uri", + "readonly": true, + "type": "string" + }, + "meta": { + "context": ["view", "edit"], + "description": "Meta fields.", + "properties": { + "footnotes": { + "default": "", + "description": "", + "title": "", + "type": "string" + } + }, + "type": "object" + }, + "modified": { + "context": ["view", "edit"], + "description": "The date the post was last modified, in the site's timezone.", + "format": "date-time", + "readonly": true, + "type": "string" + }, + "modified_gmt": { + "context": ["view", "edit"], + "description": "The date the post was last modified, as GMT.", + "format": "date-time", + "readonly": true, + "type": "string" + }, + "password": { + "context": ["edit"], + "description": "A password to protect access to the content and excerpt.", + "type": "string" + }, + "permalink_template": { + "context": ["edit"], + "description": "Permalink template for the post.", + "readonly": true, + "type": "string" + }, + "ping_status": { + "context": ["view", "edit"], + "description": "Whether or not the post can be pinged.", + "enum": ["open", "closed"], + "type": "string" + }, + "slug": { + "context": ["view", "edit", "embed"], + "description": "An alphanumeric identifier for the post unique to its type.", + "type": "string" + }, + "status": { + "context": ["view", "edit"], + "description": "A named status for the post.", + "enum": ["publish", "future", "draft", "pending", "private"], + "type": "string" + }, + "sticky": { + "context": ["view", "edit"], + "description": "Whether or not the post should be treated as sticky.", + "type": "boolean" + }, + "tags": { + "context": ["view", "edit"], + "description": "The terms assigned to the post in the post_tag taxonomy.", + "items": { + "type": "integer" + }, + "type": "array" + }, + "template": { + "context": ["view", "edit"], + "description": "The theme file to use to display the post.", + "type": "string" + }, + "title": { + "context": ["view", "edit", "embed"], + "description": "The title for the post.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Title for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML title for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "type": "object" + }, + "type": { + "context": ["view", "edit", "embed"], + "description": "Type of post.", + "readonly": true, + "type": "string" + } + }, + "title": "post", + "type": "object" + } + }, + "/wp/v2/posts/(?P[\\d]+)": { + "endpoints": [ + { + "allow_batch": { + "v1": true + }, + "args": { + "context": { + "default": "view", + "description": "Scope under which the request is made; determines fields present in response.", + "enum": ["view", "embed", "edit"], + "required": false, + "type": "string" + }, + "excerpt_length": { + "description": "Override the default excerpt length.", + "required": false, + "type": "integer" + }, + "id": { + "description": "Unique identifier for the post.", + "required": false, + "type": "integer" + }, + "password": { + "description": "The password for the post if it is password protected.", + "required": false, + "type": "string" + } + }, + "methods": ["GET"] + }, + { + "allow_batch": { + "v1": true + }, + "args": { + "author": { + "description": "The ID for the author of the post.", + "required": false, + "type": "integer" + }, + "categories": { + "description": "The terms assigned to the post in the category taxonomy.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "comment_status": { + "description": "Whether or not comments are open on the post.", + "enum": ["open", "closed"], + "required": false, + "type": "string" + }, + "content": { + "description": "The content for the post.", + "properties": { + "block_version": { + "context": ["edit"], + "description": "Version of the content block format used by the post.", + "readonly": true, + "type": "integer" + }, + "protected": { + "context": ["view", "edit", "embed"], + "description": "Whether the content is protected with a password.", + "readonly": true, + "type": "boolean" + }, + "raw": { + "context": ["edit"], + "description": "Content for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit"], + "description": "HTML content for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "date": { + "description": "The date the post was published, in the site's timezone.", + "format": "date-time", + "required": false, + "type": ["string", "null"] + }, + "date_gmt": { + "description": "The date the post was published, as GMT.", + "format": "date-time", + "required": false, + "type": ["string", "null"] + }, + "excerpt": { + "description": "The excerpt for the post.", + "properties": { + "protected": { + "context": ["view", "edit", "embed"], + "description": "Whether the excerpt is protected with a password.", + "readonly": true, + "type": "boolean" + }, + "raw": { + "context": ["edit"], + "description": "Excerpt for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML excerpt for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "featured_media": { + "description": "The ID of the featured media for the post.", + "required": false, + "type": "integer" + }, + "format": { + "description": "The format for the post.", + "enum": ["standard", "aside", "chat", "gallery", "link", "image", "quote", "status", "video", "audio"], + "required": false, + "type": "string" + }, + "id": { + "description": "Unique identifier for the post.", + "required": false, + "type": "integer" + }, + "meta": { + "description": "Meta fields.", + "properties": { + "footnotes": { + "default": "", + "description": "", + "title": "", + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "password": { + "description": "A password to protect access to the content and excerpt.", + "required": false, + "type": "string" + }, + "ping_status": { + "description": "Whether or not the post can be pinged.", + "enum": ["open", "closed"], + "required": false, + "type": "string" + }, + "slug": { + "description": "An alphanumeric identifier for the post unique to its type.", + "required": false, + "type": "string" + }, + "status": { + "description": "A named status for the post.", + "enum": ["publish", "future", "draft", "pending", "private"], + "required": false, + "type": "string" + }, + "sticky": { + "description": "Whether or not the post should be treated as sticky.", + "required": false, + "type": "boolean" + }, + "tags": { + "description": "The terms assigned to the post in the post_tag taxonomy.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "template": { + "description": "The theme file to use to display the post.", + "required": false, + "type": "string" + }, + "title": { + "description": "The title for the post.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Title for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML title for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + } + }, + "methods": ["POST", "PUT", "PATCH"] + }, + { + "allow_batch": { + "v1": true + }, + "args": { + "force": { + "default": false, + "description": "Whether to bypass Trash and force deletion.", + "required": false, + "type": "boolean" + }, + "id": { + "description": "Unique identifier for the post.", + "required": false, + "type": "integer" + } + }, + "methods": ["DELETE"] + } + ], + "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"], + "namespace": "wp/v2", + "schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "properties": { + "author": { + "context": ["view", "edit", "embed"], + "description": "The ID for the author of the post.", + "type": "integer" + }, + "categories": { + "context": ["view", "edit"], + "description": "The terms assigned to the post in the category taxonomy.", + "items": { + "type": "integer" + }, + "type": "array" + }, + "class_list": { + "context": ["view", "edit"], + "description": "An array of the class names for the post container element.", + "items": { + "type": "string" + }, + "readonly": true, + "type": "array" + }, + "comment_status": { + "context": ["view", "edit"], + "description": "Whether or not comments are open on the post.", + "enum": ["open", "closed"], + "type": "string" + }, + "content": { + "context": ["view", "edit"], + "description": "The content for the post.", + "properties": { + "block_version": { + "context": ["edit"], + "description": "Version of the content block format used by the post.", + "readonly": true, + "type": "integer" + }, + "protected": { + "context": ["view", "edit", "embed"], + "description": "Whether the content is protected with a password.", + "readonly": true, + "type": "boolean" + }, + "raw": { + "context": ["edit"], + "description": "Content for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit"], + "description": "HTML content for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "type": "object" + }, + "date": { + "context": ["view", "edit", "embed"], + "description": "The date the post was published, in the site's timezone.", + "format": "date-time", + "type": ["string", "null"] + }, + "date_gmt": { + "context": ["view", "edit"], + "description": "The date the post was published, as GMT.", + "format": "date-time", + "type": ["string", "null"] + }, + "excerpt": { + "context": ["view", "edit", "embed"], + "description": "The excerpt for the post.", + "properties": { + "protected": { + "context": ["view", "edit", "embed"], + "description": "Whether the excerpt is protected with a password.", + "readonly": true, + "type": "boolean" + }, + "raw": { + "context": ["edit"], + "description": "Excerpt for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML excerpt for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "type": "object" + }, + "featured_media": { + "context": ["view", "edit", "embed"], + "description": "The ID of the featured media for the post.", + "type": "integer" + }, + "format": { + "context": ["view", "edit"], + "description": "The format for the post.", + "enum": ["standard", "aside", "chat", "gallery", "link", "image", "quote", "status", "video", "audio"], + "type": "string" + }, + "generated_slug": { + "context": ["edit"], + "description": "Slug automatically generated from the post title.", + "readonly": true, + "type": "string" + }, + "guid": { + "context": ["view", "edit"], + "description": "The globally unique identifier for the post.", + "properties": { + "raw": { + "context": ["edit"], + "description": "GUID for the post, as it exists in the database.", + "readonly": true, + "type": "string" + }, + "rendered": { + "context": ["view", "edit"], + "description": "GUID for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "readonly": true, + "type": "object" + }, + "id": { + "context": ["view", "edit", "embed"], + "description": "Unique identifier for the post.", + "readonly": true, + "type": "integer" + }, + "link": { + "context": ["view", "edit", "embed"], + "description": "URL to the post.", + "format": "uri", + "readonly": true, + "type": "string" + }, + "meta": { + "context": ["view", "edit"], + "description": "Meta fields.", + "properties": { + "footnotes": { + "default": "", + "description": "", + "title": "", + "type": "string" + } + }, + "type": "object" + }, + "modified": { + "context": ["view", "edit"], + "description": "The date the post was last modified, in the site's timezone.", + "format": "date-time", + "readonly": true, + "type": "string" + }, + "modified_gmt": { + "context": ["view", "edit"], + "description": "The date the post was last modified, as GMT.", + "format": "date-time", + "readonly": true, + "type": "string" + }, + "password": { + "context": ["edit"], + "description": "A password to protect access to the content and excerpt.", + "type": "string" + }, + "permalink_template": { + "context": ["edit"], + "description": "Permalink template for the post.", + "readonly": true, + "type": "string" + }, + "ping_status": { + "context": ["view", "edit"], + "description": "Whether or not the post can be pinged.", + "enum": ["open", "closed"], + "type": "string" + }, + "slug": { + "context": ["view", "edit", "embed"], + "description": "An alphanumeric identifier for the post unique to its type.", + "type": "string" + }, + "status": { + "context": ["view", "edit"], + "description": "A named status for the post.", + "enum": ["publish", "future", "draft", "pending", "private"], + "type": "string" + }, + "sticky": { + "context": ["view", "edit"], + "description": "Whether or not the post should be treated as sticky.", + "type": "boolean" + }, + "tags": { + "context": ["view", "edit"], + "description": "The terms assigned to the post in the post_tag taxonomy.", + "items": { + "type": "integer" + }, + "type": "array" + }, + "template": { + "context": ["view", "edit"], + "description": "The theme file to use to display the post.", + "type": "string" + }, + "title": { + "context": ["view", "edit", "embed"], + "description": "The title for the post.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Title for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML title for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "type": "object" + }, + "type": { + "context": ["view", "edit", "embed"], + "description": "Type of post.", + "readonly": true, + "type": "string" + } + }, + "title": "post", + "type": "object" + } + }, + "/wp/v2/pages": { + "endpoints": [ + { + "allow_batch": { + "v1": true + }, + "args": { + "after": { + "description": "Limit response to posts published after a given ISO8601 compliant date.", + "format": "date-time", + "required": false, + "type": "string" + }, + "author": { + "default": [], + "description": "Limit result set to posts assigned to specific authors.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "author_exclude": { + "default": [], + "description": "Ensure result set excludes posts assigned to specific authors.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "before": { + "description": "Limit response to posts published before a given ISO8601 compliant date.", + "format": "date-time", + "required": false, + "type": "string" + }, + "context": { + "default": "view", + "description": "Scope under which the request is made; determines fields present in response.", + "enum": ["view", "embed", "edit"], + "required": false, + "type": "string" + }, + "exclude": { + "default": [], + "description": "Ensure result set excludes specific IDs.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "include": { + "default": [], + "description": "Limit result set to specific IDs.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "menu_order": { + "description": "Limit result set to posts with a specific menu_order value.", + "required": false, + "type": "integer" + }, + "modified_after": { + "description": "Limit response to posts modified after a given ISO8601 compliant date.", + "format": "date-time", + "required": false, + "type": "string" + }, + "modified_before": { + "description": "Limit response to posts modified before a given ISO8601 compliant date.", + "format": "date-time", + "required": false, + "type": "string" + }, + "offset": { + "description": "Offset the result set by a specific number of items.", + "required": false, + "type": "integer" + }, + "order": { + "default": "desc", + "description": "Order sort attribute ascending or descending.", + "enum": ["asc", "desc"], + "required": false, + "type": "string" + }, + "orderby": { + "default": "date", + "description": "Sort collection by post attribute.", + "enum": [ + "author", + "date", + "id", + "include", + "modified", + "parent", + "relevance", + "slug", + "include_slugs", + "title", + "menu_order" + ], + "required": false, + "type": "string" + }, + "page": { + "default": 1, + "description": "Current page of the collection.", + "minimum": 1, + "required": false, + "type": "integer" + }, + "parent": { + "default": [], + "description": "Limit result set to items with particular parent IDs.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "parent_exclude": { + "default": [], + "description": "Limit result set to all items except those of a particular parent ID.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "per_page": { + "default": 10, + "description": "Maximum number of items to be returned in result set.", + "maximum": 100, + "minimum": 1, + "required": false, + "type": "integer" + }, + "search": { + "description": "Limit results to those matching a string.", + "required": false, + "type": "string" + }, + "search_columns": { + "default": [], + "description": "Array of column names to be searched.", + "items": { + "enum": ["post_title", "post_content", "post_excerpt"], + "type": "string" + }, + "required": false, + "type": "array" + }, + "search_semantics": { + "description": "How to interpret the search input.", + "enum": ["exact"], + "required": false, + "type": "string" + }, + "slug": { + "description": "Limit result set to posts with one or more specific slugs.", + "items": { + "type": "string" + }, + "required": false, + "type": "array" + }, + "status": { + "default": "publish", + "description": "Limit result set to posts assigned one or more statuses.", + "items": { + "enum": [ + "publish", + "future", + "draft", + "pending", + "private", + "trash", + "auto-draft", + "inherit", + "request-pending", + "request-confirmed", + "request-failed", + "request-completed", + "any" + ], + "type": "string" + }, + "required": false, + "type": "array" + } + }, + "methods": ["GET"] + }, + { + "allow_batch": { + "v1": true + }, + "args": { + "author": { + "description": "The ID for the author of the post.", + "required": false, + "type": "integer" + }, + "comment_status": { + "description": "Whether or not comments are open on the post.", + "enum": ["open", "closed"], + "required": false, + "type": "string" + }, + "content": { + "description": "The content for the post.", + "properties": { + "block_version": { + "context": ["edit"], + "description": "Version of the content block format used by the post.", + "readonly": true, + "type": "integer" + }, + "protected": { + "context": ["view", "edit", "embed"], + "description": "Whether the content is protected with a password.", + "readonly": true, + "type": "boolean" + }, + "raw": { + "context": ["edit"], + "description": "Content for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit"], + "description": "HTML content for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "date": { + "description": "The date the post was published, in the site's timezone.", + "format": "date-time", + "required": false, + "type": ["string", "null"] + }, + "date_gmt": { + "description": "The date the post was published, as GMT.", + "format": "date-time", + "required": false, + "type": ["string", "null"] + }, + "excerpt": { + "description": "The excerpt for the post.", + "properties": { + "protected": { + "context": ["view", "edit", "embed"], + "description": "Whether the excerpt is protected with a password.", + "readonly": true, + "type": "boolean" + }, + "raw": { + "context": ["edit"], + "description": "Excerpt for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML excerpt for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "featured_media": { + "description": "The ID of the featured media for the post.", + "required": false, + "type": "integer" + }, + "menu_order": { + "description": "The order of the post in relation to other posts.", + "required": false, + "type": "integer" + }, + "meta": { + "description": "Meta fields.", + "properties": { + "footnotes": { + "default": "", + "description": "", + "title": "", + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "parent": { + "description": "The ID for the parent of the post.", + "required": false, + "type": "integer" + }, + "password": { + "description": "A password to protect access to the content and excerpt.", + "required": false, + "type": "string" + }, + "ping_status": { + "description": "Whether or not the post can be pinged.", + "enum": ["open", "closed"], + "required": false, + "type": "string" + }, + "slug": { + "description": "An alphanumeric identifier for the post unique to its type.", + "required": false, + "type": "string" + }, + "status": { + "description": "A named status for the post.", + "enum": ["publish", "future", "draft", "pending", "private"], + "required": false, + "type": "string" + }, + "template": { + "description": "The theme file to use to display the post.", + "required": false, + "type": "string" + }, + "title": { + "description": "The title for the post.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Title for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML title for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + } + }, + "methods": ["POST"] + } + ], + "methods": ["GET", "POST"], + "namespace": "wp/v2", + "schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "properties": { + "author": { + "context": ["view", "edit", "embed"], + "description": "The ID for the author of the post.", + "type": "integer" + }, + "class_list": { + "context": ["view", "edit"], + "description": "An array of the class names for the post container element.", + "items": { + "type": "string" + }, + "readonly": true, + "type": "array" + }, + "comment_status": { + "context": ["view", "edit"], + "description": "Whether or not comments are open on the post.", + "enum": ["open", "closed"], + "type": "string" + }, + "content": { + "context": ["view", "edit"], + "description": "The content for the post.", + "properties": { + "block_version": { + "context": ["edit"], + "description": "Version of the content block format used by the post.", + "readonly": true, + "type": "integer" + }, + "protected": { + "context": ["view", "edit", "embed"], + "description": "Whether the content is protected with a password.", + "readonly": true, + "type": "boolean" + }, + "raw": { + "context": ["edit"], + "description": "Content for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit"], + "description": "HTML content for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "type": "object" + }, + "date": { + "context": ["view", "edit", "embed"], + "description": "The date the post was published, in the site's timezone.", + "format": "date-time", + "type": ["string", "null"] + }, + "date_gmt": { + "context": ["view", "edit"], + "description": "The date the post was published, as GMT.", + "format": "date-time", + "type": ["string", "null"] + }, + "excerpt": { + "context": ["view", "edit", "embed"], + "description": "The excerpt for the post.", + "properties": { + "protected": { + "context": ["view", "edit", "embed"], + "description": "Whether the excerpt is protected with a password.", + "readonly": true, + "type": "boolean" + }, + "raw": { + "context": ["edit"], + "description": "Excerpt for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML excerpt for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "type": "object" + }, + "featured_media": { + "context": ["view", "edit", "embed"], + "description": "The ID of the featured media for the post.", + "type": "integer" + }, + "generated_slug": { + "context": ["edit"], + "description": "Slug automatically generated from the post title.", + "readonly": true, + "type": "string" + }, + "guid": { + "context": ["view", "edit"], + "description": "The globally unique identifier for the post.", + "properties": { + "raw": { + "context": ["edit"], + "description": "GUID for the post, as it exists in the database.", + "readonly": true, + "type": "string" + }, + "rendered": { + "context": ["view", "edit"], + "description": "GUID for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "readonly": true, + "type": "object" + }, + "id": { + "context": ["view", "edit", "embed"], + "description": "Unique identifier for the post.", + "readonly": true, + "type": "integer" + }, + "link": { + "context": ["view", "edit", "embed"], + "description": "URL to the post.", + "format": "uri", + "readonly": true, + "type": "string" + }, + "menu_order": { + "context": ["view", "edit"], + "description": "The order of the post in relation to other posts.", + "type": "integer" + }, + "meta": { + "context": ["view", "edit"], + "description": "Meta fields.", + "properties": { + "footnotes": { + "default": "", + "description": "", + "title": "", + "type": "string" + } + }, + "type": "object" + }, + "modified": { + "context": ["view", "edit"], + "description": "The date the post was last modified, in the site's timezone.", + "format": "date-time", + "readonly": true, + "type": "string" + }, + "modified_gmt": { + "context": ["view", "edit"], + "description": "The date the post was last modified, as GMT.", + "format": "date-time", + "readonly": true, + "type": "string" + }, + "parent": { + "context": ["view", "edit"], + "description": "The ID for the parent of the post.", + "type": "integer" + }, + "password": { + "context": ["edit"], + "description": "A password to protect access to the content and excerpt.", + "type": "string" + }, + "permalink_template": { + "context": ["edit"], + "description": "Permalink template for the post.", + "readonly": true, + "type": "string" + }, + "ping_status": { + "context": ["view", "edit"], + "description": "Whether or not the post can be pinged.", + "enum": ["open", "closed"], + "type": "string" + }, + "slug": { + "context": ["view", "edit", "embed"], + "description": "An alphanumeric identifier for the post unique to its type.", + "type": "string" + }, + "status": { + "context": ["view", "edit"], + "description": "A named status for the post.", + "enum": ["publish", "future", "draft", "pending", "private"], + "type": "string" + }, + "template": { + "context": ["view", "edit"], + "description": "The theme file to use to display the post.", + "type": "string" + }, + "title": { + "context": ["view", "edit", "embed"], + "description": "The title for the post.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Title for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML title for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "type": "object" + }, + "type": { + "context": ["view", "edit", "embed"], + "description": "Type of post.", + "readonly": true, + "type": "string" + } + }, + "title": "page", + "type": "object" + } + }, + "/wp/v2/pages/(?P[\\d]+)": { + "endpoints": [ + { + "allow_batch": { + "v1": true + }, + "args": { + "context": { + "default": "view", + "description": "Scope under which the request is made; determines fields present in response.", + "enum": ["view", "embed", "edit"], + "required": false, + "type": "string" + }, + "excerpt_length": { + "description": "Override the default excerpt length.", + "required": false, + "type": "integer" + }, + "id": { + "description": "Unique identifier for the post.", + "required": false, + "type": "integer" + }, + "password": { + "description": "The password for the post if it is password protected.", + "required": false, + "type": "string" + } + }, + "methods": ["GET"] + }, + { + "allow_batch": { + "v1": true + }, + "args": { + "author": { + "description": "The ID for the author of the post.", + "required": false, + "type": "integer" + }, + "comment_status": { + "description": "Whether or not comments are open on the post.", + "enum": ["open", "closed"], + "required": false, + "type": "string" + }, + "content": { + "description": "The content for the post.", + "properties": { + "block_version": { + "context": ["edit"], + "description": "Version of the content block format used by the post.", + "readonly": true, + "type": "integer" + }, + "protected": { + "context": ["view", "edit", "embed"], + "description": "Whether the content is protected with a password.", + "readonly": true, + "type": "boolean" + }, + "raw": { + "context": ["edit"], + "description": "Content for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit"], + "description": "HTML content for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "date": { + "description": "The date the post was published, in the site's timezone.", + "format": "date-time", + "required": false, + "type": ["string", "null"] + }, + "date_gmt": { + "description": "The date the post was published, as GMT.", + "format": "date-time", + "required": false, + "type": ["string", "null"] + }, + "excerpt": { + "description": "The excerpt for the post.", + "properties": { + "protected": { + "context": ["view", "edit", "embed"], + "description": "Whether the excerpt is protected with a password.", + "readonly": true, + "type": "boolean" + }, + "raw": { + "context": ["edit"], + "description": "Excerpt for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML excerpt for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "featured_media": { + "description": "The ID of the featured media for the post.", + "required": false, + "type": "integer" + }, + "id": { + "description": "Unique identifier for the post.", + "required": false, + "type": "integer" + }, + "menu_order": { + "description": "The order of the post in relation to other posts.", + "required": false, + "type": "integer" + }, + "meta": { + "description": "Meta fields.", + "properties": { + "footnotes": { + "default": "", + "description": "", + "title": "", + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "parent": { + "description": "The ID for the parent of the post.", + "required": false, + "type": "integer" + }, + "password": { + "description": "A password to protect access to the content and excerpt.", + "required": false, + "type": "string" + }, + "ping_status": { + "description": "Whether or not the post can be pinged.", + "enum": ["open", "closed"], + "required": false, + "type": "string" + }, + "slug": { + "description": "An alphanumeric identifier for the post unique to its type.", + "required": false, + "type": "string" + }, + "status": { + "description": "A named status for the post.", + "enum": ["publish", "future", "draft", "pending", "private"], + "required": false, + "type": "string" + }, + "template": { + "description": "The theme file to use to display the post.", + "required": false, + "type": "string" + }, + "title": { + "description": "The title for the post.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Title for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML title for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + } + }, + "methods": ["POST", "PUT", "PATCH"] + }, + { + "allow_batch": { + "v1": true + }, + "args": { + "force": { + "default": false, + "description": "Whether to bypass Trash and force deletion.", + "required": false, + "type": "boolean" + }, + "id": { + "description": "Unique identifier for the post.", + "required": false, + "type": "integer" + } + }, + "methods": ["DELETE"] + } + ], + "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"], + "namespace": "wp/v2", + "schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "properties": { + "author": { + "context": ["view", "edit", "embed"], + "description": "The ID for the author of the post.", + "type": "integer" + }, + "class_list": { + "context": ["view", "edit"], + "description": "An array of the class names for the post container element.", + "items": { + "type": "string" + }, + "readonly": true, + "type": "array" + }, + "comment_status": { + "context": ["view", "edit"], + "description": "Whether or not comments are open on the post.", + "enum": ["open", "closed"], + "type": "string" + }, + "content": { + "context": ["view", "edit"], + "description": "The content for the post.", + "properties": { + "block_version": { + "context": ["edit"], + "description": "Version of the content block format used by the post.", + "readonly": true, + "type": "integer" + }, + "protected": { + "context": ["view", "edit", "embed"], + "description": "Whether the content is protected with a password.", + "readonly": true, + "type": "boolean" + }, + "raw": { + "context": ["edit"], + "description": "Content for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit"], + "description": "HTML content for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "type": "object" + }, + "date": { + "context": ["view", "edit", "embed"], + "description": "The date the post was published, in the site's timezone.", + "format": "date-time", + "type": ["string", "null"] + }, + "date_gmt": { + "context": ["view", "edit"], + "description": "The date the post was published, as GMT.", + "format": "date-time", + "type": ["string", "null"] + }, + "excerpt": { + "context": ["view", "edit", "embed"], + "description": "The excerpt for the post.", + "properties": { + "protected": { + "context": ["view", "edit", "embed"], + "description": "Whether the excerpt is protected with a password.", + "readonly": true, + "type": "boolean" + }, + "raw": { + "context": ["edit"], + "description": "Excerpt for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML excerpt for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "type": "object" + }, + "featured_media": { + "context": ["view", "edit", "embed"], + "description": "The ID of the featured media for the post.", + "type": "integer" + }, + "generated_slug": { + "context": ["edit"], + "description": "Slug automatically generated from the post title.", + "readonly": true, + "type": "string" + }, + "guid": { + "context": ["view", "edit"], + "description": "The globally unique identifier for the post.", + "properties": { + "raw": { + "context": ["edit"], + "description": "GUID for the post, as it exists in the database.", + "readonly": true, + "type": "string" + }, + "rendered": { + "context": ["view", "edit"], + "description": "GUID for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "readonly": true, + "type": "object" + }, + "id": { + "context": ["view", "edit", "embed"], + "description": "Unique identifier for the post.", + "readonly": true, + "type": "integer" + }, + "link": { + "context": ["view", "edit", "embed"], + "description": "URL to the post.", + "format": "uri", + "readonly": true, + "type": "string" + }, + "menu_order": { + "context": ["view", "edit"], + "description": "The order of the post in relation to other posts.", + "type": "integer" + }, + "meta": { + "context": ["view", "edit"], + "description": "Meta fields.", + "properties": { + "footnotes": { + "default": "", + "description": "", + "title": "", + "type": "string" + } + }, + "type": "object" + }, + "modified": { + "context": ["view", "edit"], + "description": "The date the post was last modified, in the site's timezone.", + "format": "date-time", + "readonly": true, + "type": "string" + }, + "modified_gmt": { + "context": ["view", "edit"], + "description": "The date the post was last modified, as GMT.", + "format": "date-time", + "readonly": true, + "type": "string" + }, + "parent": { + "context": ["view", "edit"], + "description": "The ID for the parent of the post.", + "type": "integer" + }, + "password": { + "context": ["edit"], + "description": "A password to protect access to the content and excerpt.", + "type": "string" + }, + "permalink_template": { + "context": ["edit"], + "description": "Permalink template for the post.", + "readonly": true, + "type": "string" + }, + "ping_status": { + "context": ["view", "edit"], + "description": "Whether or not the post can be pinged.", + "enum": ["open", "closed"], + "type": "string" + }, + "slug": { + "context": ["view", "edit", "embed"], + "description": "An alphanumeric identifier for the post unique to its type.", + "type": "string" + }, + "status": { + "context": ["view", "edit"], + "description": "A named status for the post.", + "enum": ["publish", "future", "draft", "pending", "private"], + "type": "string" + }, + "template": { + "context": ["view", "edit"], + "description": "The theme file to use to display the post.", + "type": "string" + }, + "title": { + "context": ["view", "edit", "embed"], + "description": "The title for the post.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Title for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML title for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "type": "object" + }, + "type": { + "context": ["view", "edit", "embed"], + "description": "Type of post.", + "readonly": true, + "type": "string" + } + }, + "title": "page", + "type": "object" + } + }, + "/wp/v2/comments": { + "endpoints": [ + { + "args": { + "after": { + "description": "Limit response to comments published after a given ISO8601 compliant date.", + "format": "date-time", + "required": false, + "type": "string" + }, + "author": { + "description": "Limit result set to comments assigned to specific user IDs. Requires authorization.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "author_email": { + "default": null, + "description": "Limit result set to that from a specific author email. Requires authorization.", + "format": "email", + "required": false, + "type": "string" + }, + "author_exclude": { + "description": "Ensure result set excludes comments assigned to specific user IDs. Requires authorization.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "before": { + "description": "Limit response to comments published before a given ISO8601 compliant date.", + "format": "date-time", + "required": false, + "type": "string" + }, + "context": { + "default": "view", + "description": "Scope under which the request is made; determines fields present in response.", + "enum": ["view", "embed", "edit"], + "required": false, + "type": "string" + }, + "exclude": { + "default": [], + "description": "Ensure result set excludes specific IDs.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "include": { + "default": [], + "description": "Limit result set to specific IDs.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "offset": { + "description": "Offset the result set by a specific number of items.", + "required": false, + "type": "integer" + }, + "order": { + "default": "desc", + "description": "Order sort attribute ascending or descending.", + "enum": ["asc", "desc"], + "required": false, + "type": "string" + }, + "orderby": { + "default": "date_gmt", + "description": "Sort collection by comment attribute.", + "enum": ["date", "date_gmt", "id", "include", "post", "parent", "type"], + "required": false, + "type": "string" + }, + "page": { + "default": 1, + "description": "Current page of the collection.", + "minimum": 1, + "required": false, + "type": "integer" + }, + "parent": { + "default": [], + "description": "Limit result set to comments of specific parent IDs.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "parent_exclude": { + "default": [], + "description": "Ensure result set excludes specific parent IDs.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "password": { + "description": "The password for the post if it is password protected.", + "required": false, + "type": "string" + }, + "per_page": { + "default": 10, + "description": "Maximum number of items to be returned in result set.", + "maximum": 100, + "minimum": 1, + "required": false, + "type": "integer" + }, + "post": { + "default": [], + "description": "Limit result set to comments assigned to specific post IDs.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "search": { + "description": "Limit results to those matching a string.", + "required": false, + "type": "string" + }, + "status": { + "default": "approve", + "description": "Limit result set to comments assigned a specific status. Requires authorization.", + "required": false, + "type": "string" + }, + "type": { + "default": "comment", + "description": "Limit result set to comments assigned a specific type. Requires authorization.", + "required": false, + "type": "string" + } + }, + "methods": ["GET"] + }, + { + "args": { + "author": { + "description": "The ID of the user object, if author was a user.", + "required": false, + "type": "integer" + }, + "author_email": { + "description": "Email address for the comment author.", + "format": "email", + "required": false, + "type": "string" + }, + "author_ip": { + "description": "IP address for the comment author.", + "format": "ip", + "required": false, + "type": "string" + }, + "author_name": { + "description": "Display name for the comment author.", + "required": false, + "type": "string" + }, + "author_url": { + "description": "URL for the comment author.", + "format": "uri", + "required": false, + "type": "string" + }, + "author_user_agent": { + "description": "User agent for the comment author.", + "required": false, + "type": "string" + }, + "content": { + "description": "The content for the comment.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Content for the comment, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML content for the comment, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "date": { + "description": "The date the comment was published, in the site's timezone.", + "format": "date-time", + "required": false, + "type": "string" + }, + "date_gmt": { + "description": "The date the comment was published, as GMT.", + "format": "date-time", + "required": false, + "type": "string" + }, + "meta": { + "description": "Meta fields.", + "properties": { + "_wp_note_status": { + "default": "", + "description": "Note resolution status", + "enum": ["resolved", "reopen"], + "title": "", + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "parent": { + "default": 0, + "description": "The ID for the parent of the comment.", + "required": false, + "type": "integer" + }, + "post": { + "default": 0, + "description": "The ID of the associated post object.", + "required": false, + "type": "integer" + }, + "status": { + "description": "State of the comment.", + "required": false, + "type": "string" + } + }, + "methods": ["POST"] + } + ], + "methods": ["GET", "POST"], + "namespace": "wp/v2", + "schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "properties": { + "author": { + "context": ["view", "edit", "embed"], + "description": "The ID of the user object, if author was a user.", + "type": "integer" + }, + "author_avatar_urls": { + "context": ["view", "edit", "embed"], + "description": "Avatar URLs for the comment author.", + "properties": { + "24": { + "context": ["embed", "view", "edit"], + "description": "Avatar URL with image size of 24 pixels.", + "format": "uri", + "type": "string" + }, + "48": { + "context": ["embed", "view", "edit"], + "description": "Avatar URL with image size of 48 pixels.", + "format": "uri", + "type": "string" + }, + "96": { + "context": ["embed", "view", "edit"], + "description": "Avatar URL with image size of 96 pixels.", + "format": "uri", + "type": "string" + } + }, + "readonly": true, + "type": "object" + }, + "author_email": { + "context": ["edit"], + "description": "Email address for the comment author.", + "format": "email", + "type": "string" + }, + "author_ip": { + "context": ["edit"], + "description": "IP address for the comment author.", + "format": "ip", + "type": "string" + }, + "author_name": { + "context": ["view", "edit", "embed"], + "description": "Display name for the comment author.", + "type": "string" + }, + "author_url": { + "context": ["view", "edit", "embed"], + "description": "URL for the comment author.", + "format": "uri", + "type": "string" + }, + "author_user_agent": { + "context": ["edit"], + "description": "User agent for the comment author.", + "type": "string" + }, + "content": { + "context": ["view", "edit", "embed"], + "description": "The content for the comment.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Content for the comment, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML content for the comment, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "type": "object" + }, + "date": { + "context": ["view", "edit", "embed"], + "description": "The date the comment was published, in the site's timezone.", + "format": "date-time", + "type": "string" + }, + "date_gmt": { + "context": ["view", "edit"], + "description": "The date the comment was published, as GMT.", + "format": "date-time", + "type": "string" + }, + "id": { + "context": ["view", "edit", "embed"], + "description": "Unique identifier for the comment.", + "readonly": true, + "type": "integer" + }, + "link": { + "context": ["view", "edit", "embed"], + "description": "URL to the comment.", + "format": "uri", + "readonly": true, + "type": "string" + }, + "meta": { + "context": ["view", "edit"], + "description": "Meta fields.", + "properties": { + "_wp_note_status": { + "default": "", + "description": "Note resolution status", + "enum": ["resolved", "reopen"], + "title": "", + "type": "string" + } + }, + "type": "object" + }, + "parent": { + "context": ["view", "edit", "embed"], + "default": 0, + "description": "The ID for the parent of the comment.", + "type": "integer" + }, + "post": { + "context": ["view", "edit"], + "default": 0, + "description": "The ID of the associated post object.", + "type": "integer" + }, + "status": { + "context": ["view", "edit"], + "description": "State of the comment.", + "type": "string" + }, + "type": { + "context": ["view", "edit", "embed"], + "default": "comment", + "description": "Type of the comment.", + "readonly": true, + "type": "string" + } + }, + "title": "comment", + "type": "object" + } + }, + "/wp/v2/comments/(?P[\\d]+)": { + "endpoints": [ + { + "args": { + "context": { + "default": "view", + "description": "Scope under which the request is made; determines fields present in response.", + "enum": ["view", "embed", "edit"], + "required": false, + "type": "string" + }, + "id": { + "description": "Unique identifier for the comment.", + "required": false, + "type": "integer" + }, + "password": { + "description": "The password for the parent post of the comment (if the post is password protected).", + "required": false, + "type": "string" + } + }, + "methods": ["GET"] + }, + { + "args": { + "author": { + "description": "The ID of the user object, if author was a user.", + "required": false, + "type": "integer" + }, + "author_email": { + "description": "Email address for the comment author.", + "format": "email", + "required": false, + "type": "string" + }, + "author_ip": { + "description": "IP address for the comment author.", + "format": "ip", + "required": false, + "type": "string" + }, + "author_name": { + "description": "Display name for the comment author.", + "required": false, + "type": "string" + }, + "author_url": { + "description": "URL for the comment author.", + "format": "uri", + "required": false, + "type": "string" + }, + "author_user_agent": { + "description": "User agent for the comment author.", + "required": false, + "type": "string" + }, + "content": { + "description": "The content for the comment.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Content for the comment, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML content for the comment, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "date": { + "description": "The date the comment was published, in the site's timezone.", + "format": "date-time", + "required": false, + "type": "string" + }, + "date_gmt": { + "description": "The date the comment was published, as GMT.", + "format": "date-time", + "required": false, + "type": "string" + }, + "id": { + "description": "Unique identifier for the comment.", + "required": false, + "type": "integer" + }, + "meta": { + "description": "Meta fields.", + "properties": { + "_wp_note_status": { + "default": "", + "description": "Note resolution status", + "enum": ["resolved", "reopen"], + "title": "", + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "parent": { + "description": "The ID for the parent of the comment.", + "required": false, + "type": "integer" + }, + "post": { + "description": "The ID of the associated post object.", + "required": false, + "type": "integer" + }, + "status": { + "description": "State of the comment.", + "required": false, + "type": "string" + } + }, + "methods": ["POST", "PUT", "PATCH"] + }, + { + "args": { + "force": { + "default": false, + "description": "Whether to bypass Trash and force deletion.", + "required": false, + "type": "boolean" + }, + "id": { + "description": "Unique identifier for the comment.", + "required": false, + "type": "integer" + }, + "password": { + "description": "The password for the parent post of the comment (if the post is password protected).", + "required": false, + "type": "string" + } + }, + "methods": ["DELETE"] + } + ], + "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"], + "namespace": "wp/v2", + "schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "properties": { + "author": { + "context": ["view", "edit", "embed"], + "description": "The ID of the user object, if author was a user.", + "type": "integer" + }, + "author_avatar_urls": { + "context": ["view", "edit", "embed"], + "description": "Avatar URLs for the comment author.", + "properties": { + "24": { + "context": ["embed", "view", "edit"], + "description": "Avatar URL with image size of 24 pixels.", + "format": "uri", + "type": "string" + }, + "48": { + "context": ["embed", "view", "edit"], + "description": "Avatar URL with image size of 48 pixels.", + "format": "uri", + "type": "string" + }, + "96": { + "context": ["embed", "view", "edit"], + "description": "Avatar URL with image size of 96 pixels.", + "format": "uri", + "type": "string" + } + }, + "readonly": true, + "type": "object" + }, + "author_email": { + "context": ["edit"], + "description": "Email address for the comment author.", + "format": "email", + "type": "string" + }, + "author_ip": { + "context": ["edit"], + "description": "IP address for the comment author.", + "format": "ip", + "type": "string" + }, + "author_name": { + "context": ["view", "edit", "embed"], + "description": "Display name for the comment author.", + "type": "string" + }, + "author_url": { + "context": ["view", "edit", "embed"], + "description": "URL for the comment author.", + "format": "uri", + "type": "string" + }, + "author_user_agent": { + "context": ["edit"], + "description": "User agent for the comment author.", + "type": "string" + }, + "content": { + "context": ["view", "edit", "embed"], + "description": "The content for the comment.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Content for the comment, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML content for the comment, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "type": "object" + }, + "date": { + "context": ["view", "edit", "embed"], + "description": "The date the comment was published, in the site's timezone.", + "format": "date-time", + "type": "string" + }, + "date_gmt": { + "context": ["view", "edit"], + "description": "The date the comment was published, as GMT.", + "format": "date-time", + "type": "string" + }, + "id": { + "context": ["view", "edit", "embed"], + "description": "Unique identifier for the comment.", + "readonly": true, + "type": "integer" + }, + "link": { + "context": ["view", "edit", "embed"], + "description": "URL to the comment.", + "format": "uri", + "readonly": true, + "type": "string" + }, + "meta": { + "context": ["view", "edit"], + "description": "Meta fields.", + "properties": { + "_wp_note_status": { + "default": "", + "description": "Note resolution status", + "enum": ["resolved", "reopen"], + "title": "", + "type": "string" + } + }, + "type": "object" + }, + "parent": { + "context": ["view", "edit", "embed"], + "default": 0, + "description": "The ID for the parent of the comment.", + "type": "integer" + }, + "post": { + "context": ["view", "edit"], + "default": 0, + "description": "The ID of the associated post object.", + "type": "integer" + }, + "status": { + "context": ["view", "edit"], + "description": "State of the comment.", + "type": "string" + }, + "type": { + "context": ["view", "edit", "embed"], + "default": "comment", + "description": "Type of the comment.", + "readonly": true, + "type": "string" + } + }, + "title": "comment", + "type": "object" + } + }, + "/wp/v2/media/(?P[\\d]+)/edit": { + "endpoints": [ + { + "args": { + "alt_text": { + "description": "Alternative text to display when attachment is not displayed.", + "required": false, + "type": "string" + }, + "caption": { + "description": "The attachment caption.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Caption for the attachment, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML caption for the attachment, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "description": { + "description": "The attachment description.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Description for the attachment, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit"], + "description": "HTML description for the attachment, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "height": { + "description": "As a percentage of the image, the height to crop the image to. DEPRECATED: Use `modifiers` instead.", + "maximum": 100, + "minimum": 0, + "required": false, + "type": "number" + }, + "modifiers": { + "description": "Array of image edits.", + "items": { + "description": "Image edit.", + "oneOf": [ + { + "properties": { + "args": { + "description": "Flip arguments.", + "properties": { + "flip": { + "description": "Flip direction.", + "properties": { + "horizontal": { + "description": "Whether to flip in the horizontal direction.", + "type": "boolean" + }, + "vertical": { + "description": "Whether to flip in the vertical direction.", + "type": "boolean" + } + }, + "required": ["horizontal", "vertical"], + "type": "object" + } + }, + "required": ["flip"], + "type": "object" + }, + "type": { + "description": "Flip type.", + "enum": ["flip"], + "type": "string" + } + }, + "title": "Flip" + }, + { + "properties": { + "args": { + "description": "Rotation arguments.", + "properties": { + "angle": { + "description": "Angle to rotate clockwise in degrees.", + "type": "number" + } + }, + "required": ["angle"], + "type": "object" + }, + "type": { + "description": "Rotation type.", + "enum": ["rotate"], + "type": "string" + } + }, + "title": "Rotation" + }, + { + "properties": { + "args": { + "description": "Crop arguments.", + "properties": { + "height": { + "description": "Height of the crop as a percentage of the image height.", + "type": "number" + }, + "left": { + "description": "Horizontal position from the left to begin the crop as a percentage of the image width.", + "type": "number" + }, + "top": { + "description": "Vertical position from the top to begin the crop as a percentage of the image height.", + "type": "number" + }, + "width": { + "description": "Width of the crop as a percentage of the image width.", + "type": "number" + } + }, + "required": ["left", "top", "width", "height"], + "type": "object" + }, + "type": { + "description": "Crop type.", + "enum": ["crop"], + "type": "string" + } + }, + "title": "Crop" + } + ], + "required": ["type", "args"], + "type": "object" + }, + "minItems": 1, + "required": false, + "type": "array" + }, + "post": { + "description": "The ID for the associated post of the attachment.", + "required": false, + "type": "integer" + }, + "rotation": { + "description": "The amount to rotate the image clockwise in degrees. DEPRECATED: Use `modifiers` instead.", + "exclusiveMaximum": true, + "exclusiveMinimum": true, + "maximum": 360, + "minimum": 0, + "required": false, + "type": "integer" + }, + "src": { + "description": "URL to the edited image file.", + "format": "uri", + "required": true, + "type": "string" + }, + "title": { + "description": "The title for the post.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Title for the post, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML title for the post, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": "object" + }, + "width": { + "description": "As a percentage of the image, the width to crop the image to. DEPRECATED: Use `modifiers` instead.", + "maximum": 100, + "minimum": 0, + "required": false, + "type": "number" + }, + "x": { + "description": "As a percentage of the image, the x position to start the crop from. DEPRECATED: Use `modifiers` instead.", + "maximum": 100, + "minimum": 0, + "required": false, + "type": "number" + }, + "y": { + "description": "As a percentage of the image, the y position to start the crop from. DEPRECATED: Use `modifiers` instead.", + "maximum": 100, + "minimum": 0, + "required": false, + "type": "number" + } + }, + "methods": ["POST"] + } + ], + "methods": ["POST"], + "namespace": "wp/v2" + }, + "/wp/v2/block-types/(?P[a-zA-Z0-9_-]+)/(?P[a-zA-Z0-9_-]+)": { + "endpoints": [ + { + "args": { + "context": { + "default": "view", + "description": "Scope under which the request is made; determines fields present in response.", + "enum": ["view", "embed", "edit"], + "required": false, + "type": "string" + }, + "name": { + "description": "Block name.", + "required": false, + "type": "string" + }, + "namespace": { + "description": "Block namespace.", + "required": false, + "type": "string" + } + }, + "methods": ["GET"] + } + ], + "methods": ["GET"], + "namespace": "wp/v2", + "schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "properties": { + "allowed_blocks": { + "context": ["embed", "view", "edit"], + "default": null, + "description": "Allowed child block types.", + "items": { + "pattern": "^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$", + "type": "string" + }, + "readonly": true, + "type": ["array", "null"] + }, + "ancestor": { + "context": ["embed", "view", "edit"], + "default": null, + "description": "Ancestor blocks.", + "items": { + "pattern": "^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$", + "type": "string" + }, + "readonly": true, + "type": ["array", "null"] + }, + "api_version": { + "context": ["embed", "view", "edit"], + "default": 1, + "description": "Version of block API.", + "readonly": true, + "type": "integer" + }, + "attributes": { + "additionalProperties": { + "type": "object" + }, + "context": ["embed", "view", "edit"], + "default": null, + "description": "Block attributes.", + "properties": [], + "readonly": true, + "type": ["object", "null"] + }, + "block_hooks": { + "context": ["embed", "view", "edit"], + "default": [], + "description": "This block is automatically inserted near any occurrence of the block types used as keys of this map, into a relative position given by the corresponding value.", + "patternProperties": { + "^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$": { + "enum": ["before", "after", "first_child", "last_child"], + "type": "string" + } + }, + "readonly": true, + "type": "object" + }, + "category": { + "context": ["embed", "view", "edit"], + "default": null, + "description": "Block category.", + "readonly": true, + "type": ["string", "null"] + }, + "description": { + "context": ["embed", "view", "edit"], + "default": "", + "description": "Description of block type.", + "readonly": true, + "type": "string" + }, + "editor_script": { + "context": ["embed", "view", "edit"], + "default": null, + "description": "Editor script handle. DEPRECATED: Use `editor_script_handles` instead.", + "readonly": true, + "type": ["string", "null"] + }, + "editor_script_handles": { + "context": ["embed", "view", "edit"], + "default": [], + "description": "Editor script handles.", + "items": { + "type": "string" + }, + "readonly": true, + "type": ["array"] + }, + "editor_style": { + "context": ["embed", "view", "edit"], + "default": null, + "description": "Editor style handle. DEPRECATED: Use `editor_style_handles` instead.", + "readonly": true, + "type": ["string", "null"] + }, + "editor_style_handles": { + "context": ["embed", "view", "edit"], + "default": [], + "description": "Editor style handles.", + "items": { + "type": "string" + }, + "readonly": true, + "type": ["array"] + }, + "example": { + "context": ["embed", "view", "edit"], + "default": null, + "description": "Block example.", + "properties": { + "attributes": { + "description": "The attributes used in the example.", + "type": "object" + }, + "innerBlocks": { + "description": "The list of inner blocks used in the example.", + "items": { + "properties": { + "attributes": { + "description": "The attributes of the inner block.", + "type": "object" + }, + "innerBlocks": { + "description": "A list of the inner block's own inner blocks. This is a recursive definition following the parent innerBlocks schema.", + "type": "array" + }, + "name": { + "description": "The name of the inner block.", + "pattern": "^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$", + "required": true, + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + } + }, + "readonly": true, + "type": ["object", "null"] + }, + "icon": { + "context": ["embed", "view", "edit"], + "default": null, + "description": "Icon of block type.", + "readonly": true, + "type": ["string", "null"] + }, + "is_dynamic": { + "context": ["embed", "view", "edit"], + "default": false, + "description": "Is the block dynamically rendered.", + "readonly": true, + "type": "boolean" + }, + "keywords": { + "context": ["embed", "view", "edit"], + "default": [], + "description": "Block keywords.", + "items": { + "type": "string" + }, + "readonly": true, + "type": "array" + }, + "name": { + "context": ["embed", "view", "edit"], + "description": "Unique name identifying the block type.", + "pattern": "^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$", + "readonly": true, + "required": true, + "type": "string" + }, + "parent": { + "context": ["embed", "view", "edit"], + "default": null, + "description": "Parent blocks.", + "items": { + "pattern": "^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$", + "type": "string" + }, + "readonly": true, + "type": ["array", "null"] + }, + "provides_context": { + "additionalProperties": { + "type": "string" + }, + "context": ["embed", "view", "edit"], + "default": [], + "description": "Context provided by blocks of this type.", + "properties": [], + "readonly": true, + "type": "object" + }, + "script": { + "context": ["embed", "view", "edit"], + "default": null, + "description": "Public facing and editor script handle. DEPRECATED: Use `script_handles` instead.", + "readonly": true, + "type": ["string", "null"] + }, + "script_handles": { + "context": ["embed", "view", "edit"], + "default": [], + "description": "Public facing and editor script handles.", + "items": { + "type": "string" + }, + "readonly": true, + "type": ["array"] + }, + "selectors": { + "context": ["embed", "view", "edit"], + "default": [], + "description": "Custom CSS selectors.", + "properties": [], + "readonly": true, + "type": "object" + }, + "style": { + "context": ["embed", "view", "edit"], + "default": null, + "description": "Public facing and editor style handle. DEPRECATED: Use `style_handles` instead.", + "readonly": true, + "type": ["string", "null"] + }, + "style_handles": { + "context": ["embed", "view", "edit"], + "default": [], + "description": "Public facing and editor style handles.", + "items": { + "type": "string" + }, + "readonly": true, + "type": ["array"] + }, + "styles": { + "context": ["embed", "view", "edit"], + "default": [], + "description": "Block style variations.", + "items": { + "properties": { + "inline_style": { + "description": "Inline CSS code that registers the CSS class required for the style.", + "type": "string" + }, + "label": { + "description": "The human-readable label for the style.", + "type": "string" + }, + "name": { + "description": "Unique name identifying the style.", + "required": true, + "type": "string" + }, + "style_handle": { + "description": "Contains the handle that defines the block style.", + "type": "string" + } + }, + "type": "object" + }, + "readonly": true, + "type": "array" + }, + "supports": { + "context": ["embed", "view", "edit"], + "default": [], + "description": "Block supports.", + "properties": [], + "readonly": true, + "type": "object" + }, + "textdomain": { + "context": ["embed", "view", "edit"], + "default": null, + "description": "Public text domain.", + "readonly": true, + "type": ["string", "null"] + }, + "title": { + "context": ["embed", "view", "edit"], + "default": "", + "description": "Title of block type.", + "readonly": true, + "type": "string" + }, + "uses_context": { + "context": ["embed", "view", "edit"], + "default": [], + "description": "Context values inherited by blocks of this type.", + "items": { + "type": "string" + }, + "readonly": true, + "type": "array" + }, + "variations": { + "context": ["embed", "view", "edit"], + "default": null, + "description": "Block variations.", + "items": { + "properties": { + "attributes": { + "description": "The initial values for attributes.", + "type": "object" + }, + "category": { + "context": ["embed", "view", "edit"], + "default": null, + "description": "Block category.", + "readonly": true, + "type": ["string", "null"] + }, + "description": { + "description": "A detailed variation description.", + "required": false, + "type": "string" + }, + "example": { + "context": ["embed", "view", "edit"], + "default": null, + "description": "Block example.", + "properties": { + "attributes": { + "description": "The attributes used in the example.", + "type": "object" + }, + "innerBlocks": { + "description": "The list of inner blocks used in the example.", + "items": { + "properties": { + "attributes": { + "description": "The attributes of the inner block.", + "type": "object" + }, + "innerBlocks": { + "description": "A list of the inner block's own inner blocks. This is a recursive definition following the parent innerBlocks schema.", + "type": "array" + }, + "name": { + "description": "The name of the inner block.", + "pattern": "^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$", + "required": true, + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + } + }, + "readonly": true, + "type": ["object", "null"] + }, + "icon": { + "context": ["embed", "view", "edit"], + "default": null, + "description": "Icon of block type.", + "readonly": true, + "type": ["string", "null"] + }, + "innerBlocks": { + "description": "The list of inner blocks used in the example.", + "items": { + "properties": { + "attributes": { + "description": "The attributes of the inner block.", + "type": "object" + }, + "innerBlocks": { + "description": "A list of the inner block's own inner blocks. This is a recursive definition following the parent innerBlocks schema.", + "type": "array" + }, + "name": { + "description": "The name of the inner block.", + "pattern": "^[a-z][a-z0-9-]*/[a-z][a-z0-9-]*$", + "required": true, + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + }, + "isDefault": { + "default": false, + "description": "Indicates whether the current variation is the default one.", + "required": false, + "type": "boolean" + }, + "keywords": { + "context": ["embed", "view", "edit"], + "default": [], + "description": "Block keywords.", + "items": { + "type": "string" + }, + "readonly": true, + "type": "array" + }, + "name": { + "description": "The unique and machine-readable name.", + "required": true, + "type": "string" + }, + "scope": { + "default": null, + "description": "The list of scopes where the variation is applicable. When not provided, it assumes all available scopes.", + "items": { + "enum": ["block", "inserter", "transform"], + "type": "string" + }, + "readonly": true, + "type": ["array", "null"] + }, + "title": { + "description": "A human-readable variation title.", + "required": true, + "type": "string" + } + }, + "type": "object" + }, + "readonly": true, + "type": "array" + }, + "view_script": { + "context": ["embed", "view", "edit"], + "default": null, + "description": "Public facing script handle. DEPRECATED: Use `view_script_handles` instead.", + "readonly": true, + "type": ["string", "null"] + }, + "view_script_handles": { + "context": ["embed", "view", "edit"], + "default": [], + "description": "Public facing script handles.", + "items": { + "type": "string" + }, + "readonly": true, + "type": ["array"] + }, + "view_script_module_ids": { + "context": ["embed", "view", "edit"], + "default": [], + "description": "Public facing script module IDs.", + "items": { + "type": "string" + }, + "readonly": true, + "type": ["array"] + }, + "view_style_handles": { + "context": ["embed", "view", "edit"], + "default": [], + "description": "Public facing style handles.", + "items": { + "type": "string" + }, + "readonly": true, + "type": ["array"] + } + }, + "title": "block-type", + "type": "object" + } + }, + "/wp/v2/templates/(?P([^\\/:<>\\*\\?\"\\|]+(?:\\/[^\\/:<>\\*\\?\"\\|]+)?)[\\/\\w%-]+)": { + "endpoints": [ + { + "args": { + "context": { + "default": "view", + "description": "Scope under which the request is made; determines fields present in response.", + "enum": ["view", "embed", "edit"], + "required": false, + "type": "string" + }, + "id": { + "description": "The id of a template", + "required": false, + "type": "string" + } + }, + "methods": ["GET"] + }, + { + "args": { + "author": { + "description": "The ID for the author of the template.", + "required": false, + "type": "integer" + }, + "content": { + "description": "Content of template.", + "properties": { + "block_version": { + "context": ["edit"], + "description": "Version of the content block format used by the template.", + "readonly": true, + "type": "integer" + }, + "raw": { + "context": ["view", "edit"], + "description": "Content for the template, as it exists in the database.", + "type": "string" + } + }, + "required": false, + "type": ["object", "string"] + }, + "description": { + "description": "Description of template.", + "required": false, + "type": "string" + }, + "id": { + "description": "The id of a template", + "required": false, + "type": "string" + }, + "slug": { + "description": "Unique slug identifying the template.", + "minLength": 1, + "pattern": "[a-zA-Z0-9_\\%-]+", + "required": false, + "type": "string" + }, + "status": { + "description": "Status of template.", + "enum": ["publish", "future", "draft", "pending", "private"], + "required": false, + "type": "string" + }, + "theme": { + "description": "Theme identifier for the template.", + "required": false, + "type": "string" + }, + "title": { + "description": "Title of template.", + "properties": { + "raw": { + "context": ["view", "edit", "embed"], + "description": "Title for the template, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML title for the template, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": ["object", "string"] + }, + "type": { + "description": "Type of template.", + "required": false, + "type": "string" + } + }, + "methods": ["POST", "PUT", "PATCH"] + }, + { + "args": { + "force": { + "default": false, + "description": "Whether to bypass Trash and force deletion.", + "required": false, + "type": "boolean" + }, + "id": { + "description": "The id of a template", + "required": false, + "type": "string" + } + }, + "methods": ["DELETE"] + } + ], + "methods": ["GET", "POST", "PUT", "PATCH", "DELETE"], + "namespace": "wp/v2", + "schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "properties": { + "author": { + "context": ["view", "edit", "embed"], + "description": "The ID for the author of the template.", + "type": "integer" + }, + "author_text": { + "context": ["view", "edit", "embed"], + "description": "Human readable text for the author.", + "readonly": true, + "type": "string" + }, + "content": { + "context": ["embed", "view", "edit"], + "default": "", + "description": "Content of template.", + "properties": { + "block_version": { + "context": ["edit"], + "description": "Version of the content block format used by the template.", + "readonly": true, + "type": "integer" + }, + "raw": { + "context": ["view", "edit"], + "description": "Content for the template, as it exists in the database.", + "type": "string" + } + }, + "type": ["object", "string"] + }, + "description": { + "context": ["embed", "view", "edit"], + "default": "", + "description": "Description of template.", + "type": "string" + }, + "has_theme_file": { + "context": ["embed", "view", "edit"], + "description": "Theme file exists.", + "readonly": true, + "type": "bool" + }, + "id": { + "context": ["embed", "view", "edit"], + "description": "ID of template.", + "readonly": true, + "type": "string" + }, + "is_custom": { + "context": ["embed", "view", "edit"], + "description": "Whether a template is a custom template.", + "readonly": true, + "type": "bool" + }, + "modified": { + "context": ["view", "edit"], + "description": "The date the template was last modified, in the site's timezone.", + "format": "date-time", + "readonly": true, + "type": "string" + }, + "origin": { + "context": ["embed", "view", "edit"], + "description": "Source of a customized template", + "readonly": true, + "type": "string" + }, + "original_source": { + "context": ["view", "edit", "embed"], + "description": "Where the template originally comes from e.g. 'theme'", + "enum": ["theme", "plugin", "site", "user"], + "readonly": true, + "type": "string" + }, + "plugin": { + "context": ["view", "edit", "embed"], + "description": "Plugin that registered the template.", + "readonly": true, + "type": "string" + }, + "slug": { + "context": ["embed", "view", "edit"], + "description": "Unique slug identifying the template.", + "minLength": 1, + "pattern": "[a-zA-Z0-9_\\%-]+", + "required": true, + "type": "string" + }, + "source": { + "context": ["embed", "view", "edit"], + "description": "Source of template", + "readonly": true, + "type": "string" + }, + "status": { + "context": ["embed", "view", "edit"], + "default": "publish", + "description": "Status of template.", + "enum": ["publish", "future", "draft", "pending", "private"], + "type": "string" + }, + "theme": { + "context": ["embed", "view", "edit"], + "description": "Theme identifier for the template.", + "type": "string" + }, + "title": { + "context": ["embed", "view", "edit"], + "default": "", + "description": "Title of template.", + "properties": { + "raw": { + "context": ["view", "edit", "embed"], + "description": "Title for the template, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML title for the template, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "type": ["object", "string"] + }, + "type": { + "context": ["embed", "view", "edit"], + "description": "Type of template.", + "type": "string" + }, + "wp_id": { + "context": ["embed", "view", "edit"], + "description": "Post ID.", + "readonly": true, + "type": "integer" + } + }, + "title": "wp_template", + "type": "object" + } + }, + "/oembed/1.0/embed": { + "endpoints": [ + { + "args": { + "format": { + "default": "json", + "required": false + }, + "maxwidth": { + "default": 600, + "required": false + }, + "url": { + "description": "The URL of the resource for which to fetch oEmbed data.", + "format": "uri", + "required": true, + "type": "string" + } + }, + "methods": ["GET"] + } + ], + "methods": ["GET"], + "namespace": "oembed/1.0" + }, + "/wp/v2/menu-items": { + "endpoints": [ + { + "allow_batch": { + "v1": true + }, + "args": { + "after": { + "description": "Limit response to posts published after a given ISO8601 compliant date.", + "format": "date-time", + "required": false, + "type": "string" + }, + "before": { + "description": "Limit response to posts published before a given ISO8601 compliant date.", + "format": "date-time", + "required": false, + "type": "string" + }, + "context": { + "default": "view", + "description": "Scope under which the request is made; determines fields present in response.", + "enum": ["view", "embed", "edit"], + "required": false, + "type": "string" + }, + "exclude": { + "default": [], + "description": "Ensure result set excludes specific IDs.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "include": { + "default": [], + "description": "Limit result set to specific IDs.", + "items": { + "type": "integer" + }, + "required": false, + "type": "array" + }, + "menu_order": { + "description": "Limit result set to posts with a specific menu_order value.", + "required": false, + "type": "integer" + }, + "menus": { + "description": "Limit result set to items with specific terms assigned in the menus taxonomy.", + "oneOf": [ + { + "description": "Match terms with the listed IDs.", + "items": { + "type": "integer" + }, + "title": "Term ID List", + "type": "array" + }, + { + "additionalProperties": false, + "description": "Perform an advanced term query.", + "properties": { + "operator": { + "default": "OR", + "description": "Whether items must be assigned all or any of the specified terms.", + "enum": ["AND", "OR"], + "type": "string" + }, + "terms": { + "default": [], + "description": "Term IDs.", + "items": { + "type": "integer" + }, + "type": "array" + } + }, + "title": "Term ID Taxonomy Query", + "type": "object" + } + ], + "required": false, + "type": ["object", "array"] + }, + "menus_exclude": { + "description": "Limit result set to items except those with specific terms assigned in the menus taxonomy.", + "oneOf": [ + { + "description": "Match terms with the listed IDs.", + "items": { + "type": "integer" + }, + "title": "Term ID List", + "type": "array" + }, + { + "additionalProperties": false, + "description": "Perform an advanced term query.", + "properties": { + "terms": { + "default": [], + "description": "Term IDs.", + "items": { + "type": "integer" + }, + "type": "array" + } + }, + "title": "Term ID Taxonomy Query", + "type": "object" + } + ], + "required": false, + "type": ["object", "array"] + }, + "modified_after": { + "description": "Limit response to posts modified after a given ISO8601 compliant date.", + "format": "date-time", + "required": false, + "type": "string" + }, + "modified_before": { + "description": "Limit response to posts modified before a given ISO8601 compliant date.", + "format": "date-time", + "required": false, + "type": "string" + }, + "offset": { + "description": "Offset the result set by a specific number of items.", + "required": false, + "type": "integer" + }, + "order": { + "default": "asc", + "description": "Order sort attribute ascending or descending.", + "enum": ["asc", "desc"], + "required": false, + "type": "string" + }, + "orderby": { + "default": "menu_order", + "description": "Sort collection by object attribute.", + "enum": [ + "author", + "date", + "id", + "include", + "modified", + "parent", + "relevance", + "slug", + "include_slugs", + "title", + "menu_order" + ], + "required": false, + "type": "string" + }, + "page": { + "default": 1, + "description": "Current page of the collection.", + "minimum": 1, + "required": false, + "type": "integer" + }, + "per_page": { + "default": 100, + "description": "Maximum number of items to be returned in result set.", + "maximum": 100, + "minimum": 1, + "required": false, + "type": "integer" + }, + "search": { + "description": "Limit results to those matching a string.", + "required": false, + "type": "string" + }, + "search_columns": { + "default": [], + "description": "Array of column names to be searched.", + "items": { + "enum": ["post_title", "post_content", "post_excerpt"], + "type": "string" + }, + "required": false, + "type": "array" + }, + "search_semantics": { + "description": "How to interpret the search input.", + "enum": ["exact"], + "required": false, + "type": "string" + }, + "slug": { + "description": "Limit result set to posts with one or more specific slugs.", + "items": { + "type": "string" + }, + "required": false, + "type": "array" + }, + "status": { + "default": "publish", + "description": "Limit result set to posts assigned one or more statuses.", + "items": { + "enum": [ + "publish", + "future", + "draft", + "pending", + "private", + "trash", + "auto-draft", + "inherit", + "request-pending", + "request-confirmed", + "request-failed", + "request-completed", + "any" + ], + "type": "string" + }, + "required": false, + "type": "array" + }, + "tax_relation": { + "description": "Limit result set based on relationship between multiple taxonomies.", + "enum": ["AND", "OR"], + "required": false, + "type": "string" + } + }, + "methods": ["GET"] + }, + { + "allow_batch": { + "v1": true + }, + "args": { + "attr_title": { + "description": "Text for the title attribute of the link element for this menu item.", + "required": false, + "type": "string" + }, + "classes": { + "description": "Class names for the link element of this menu item.", + "items": { + "type": "string" + }, + "required": false, + "type": "array" + }, + "description": { + "description": "The description of this menu item.", + "required": false, + "type": "string" + }, + "menu_order": { + "default": 1, + "description": "The DB ID of the nav_menu_item that is this item's menu parent, if any, otherwise 0.", + "minimum": 1, + "required": false, + "type": "integer" + }, + "menus": { + "description": "The terms assigned to the object in the nav_menu taxonomy.", + "required": false, + "type": "integer" + }, + "meta": { + "description": "Meta fields.", + "properties": [], + "required": false, + "type": "object" + }, + "object": { + "description": "The type of object originally represented, such as \"category\", \"post\", or \"attachment\".", + "required": false, + "type": "string" + }, + "object_id": { + "default": 0, + "description": "The database ID of the original object this menu item represents, for example the ID for posts or the term_id for categories.", + "minimum": 0, + "required": false, + "type": "integer" + }, + "parent": { + "default": 0, + "description": "The ID for the parent of the object.", + "minimum": 0, + "required": false, + "type": "integer" + }, + "status": { + "default": "publish", + "description": "A named status for the object.", + "enum": ["publish", "future", "draft", "pending", "private"], + "required": false, + "type": "string" + }, + "target": { + "description": "The target attribute of the link element for this menu item.", + "enum": ["_blank", ""], + "required": false, + "type": "string" + }, + "title": { + "description": "The title for the object.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Title for the object, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML title for the object, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "required": false, + "type": ["string", "object"] + }, + "type": { + "default": "custom", + "description": "The family of objects originally represented, such as \"post_type\" or \"taxonomy\".", + "enum": ["taxonomy", "post_type", "post_type_archive", "custom"], + "required": false, + "type": "string" + }, + "url": { + "description": "The URL to which this menu item points.", + "format": "uri", + "required": false, + "type": "string" + }, + "xfn": { + "description": "The XFN relationship expressed in the link of this menu item.", + "items": { + "type": "string" + }, + "required": false, + "type": "array" + } + }, + "methods": ["POST"] + } + ], + "methods": ["GET", "POST"], + "namespace": "wp/v2", + "schema": { + "$schema": "http://json-schema.org/draft-04/schema#", + "properties": { + "attr_title": { + "context": ["view", "edit", "embed"], + "description": "Text for the title attribute of the link element for this menu item.", + "type": "string" + }, + "classes": { + "context": ["view", "edit", "embed"], + "description": "Class names for the link element of this menu item.", + "items": { + "type": "string" + }, + "type": "array" + }, + "description": { + "context": ["view", "edit", "embed"], + "description": "The description of this menu item.", + "type": "string" + }, + "id": { + "context": ["view", "edit", "embed"], + "default": 0, + "description": "Unique identifier for the object.", + "minimum": 0, + "readonly": true, + "type": "integer" + }, + "invalid": { + "context": ["view", "edit", "embed"], + "description": "Whether the menu item represents an object that no longer exists.", + "readonly": true, + "type": "boolean" + }, + "menu_order": { + "context": ["view", "edit", "embed"], + "default": 1, + "description": "The DB ID of the nav_menu_item that is this item's menu parent, if any, otherwise 0.", + "minimum": 1, + "type": "integer" + }, + "menus": { + "context": ["view", "edit"], + "description": "The terms assigned to the object in the nav_menu taxonomy.", + "type": "integer" + }, + "meta": { + "context": ["view", "edit"], + "description": "Meta fields.", + "properties": [], + "type": "object" + }, + "object": { + "context": ["view", "edit", "embed"], + "description": "The type of object originally represented, such as \"category\", \"post\", or \"attachment\".", + "type": "string" + }, + "object_id": { + "context": ["view", "edit", "embed"], + "default": 0, + "description": "The database ID of the original object this menu item represents, for example the ID for posts or the term_id for categories.", + "minimum": 0, + "type": "integer" + }, + "parent": { + "context": ["view", "edit", "embed"], + "default": 0, + "description": "The ID for the parent of the object.", + "minimum": 0, + "type": "integer" + }, + "status": { + "context": ["view", "edit", "embed"], + "default": "publish", + "description": "A named status for the object.", + "enum": ["publish", "future", "draft", "pending", "private"], + "type": "string" + }, + "target": { + "context": ["view", "edit", "embed"], + "description": "The target attribute of the link element for this menu item.", + "enum": ["_blank", ""], + "type": "string" + }, + "title": { + "context": ["view", "edit", "embed"], + "description": "The title for the object.", + "properties": { + "raw": { + "context": ["edit"], + "description": "Title for the object, as it exists in the database.", + "type": "string" + }, + "rendered": { + "context": ["view", "edit", "embed"], + "description": "HTML title for the object, transformed for display.", + "readonly": true, + "type": "string" + } + }, + "type": ["string", "object"] + }, + "type": { + "context": ["view", "edit", "embed"], + "default": "custom", + "description": "The family of objects originally represented, such as \"post_type\" or \"taxonomy\".", + "enum": ["taxonomy", "post_type", "post_type_archive", "custom"], + "type": "string" + }, + "type_label": { + "context": ["view", "edit", "embed"], + "description": "The singular label used to describe this type of menu item.", + "readonly": true, + "type": "string" + }, + "url": { + "context": ["view", "edit", "embed"], + "description": "The URL to which this menu item points.", + "format": "uri", + "type": "string" + }, + "xfn": { + "context": ["view", "edit", "embed"], + "description": "The XFN relationship expressed in the link of this menu item.", + "items": { + "type": "string" + }, + "type": "array" + } + }, + "title": "nav_menu_item", + "type": "object" + } + } + } +}