@webpieces/openapi-generator 0.4.1011 → 0.4.1013

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/openapi-generator",
3
- "version": "0.4.1011",
3
+ "version": "0.4.1013",
4
4
  "description": "Render an ApiDocModel to OpenAPI 3.1.0 — the canonical internal document and the customer-published one, JSON and YAML, from one generation pass. Ships the wp-openapi bin.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -23,8 +23,8 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@webpieces/api-doc-model": "0.4.1011",
27
- "@webpieces/core-util": "0.4.1011",
26
+ "@webpieces/api-doc-model": "0.4.1013",
27
+ "@webpieces/core-util": "0.4.1013",
28
28
  "typescript": "5.9.3"
29
29
  },
30
30
  "bin": {
@@ -70,7 +70,7 @@ export declare class DocumentSelection {
70
70
  * levels, and a second flag could only ever disagree with the first.
71
71
  */
72
72
  readonly dropHidden: boolean;
73
- /** Stamp `x-mcp-tool` and its siblings. Only the MCP document has a reader for them. */
73
+ /** Stamp `x-mcp-tools` and its siblings. Only the MCP document has a reader for them. */
74
74
  readonly includeMcpExtensions: boolean;
75
75
  /**
76
76
  * Prepend {@link INTERNAL_ONLY_LINE} to `info.description`, and say what TRIGGERS each
@@ -91,7 +91,7 @@ class DocumentSelection {
91
91
  * levels, and a second flag could only ever disagree with the first.
92
92
  */
93
93
  dropHidden,
94
- /** Stamp `x-mcp-tool` and its siblings. Only the MCP document has a reader for them. */
94
+ /** Stamp `x-mcp-tools` and its siblings. Only the MCP document has a reader for them. */
95
95
  includeMcpExtensions,
96
96
  /**
97
97
  * Prepend {@link INTERNAL_ONLY_LINE} to `info.description`, and say what TRIGGERS each
@@ -1 +1 @@
1
- {"version":3,"file":"DocumentSelection.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/Doc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AC;YACpC,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACpC,CAAC;QACD,IAAI,SAAS,EAAE,CAAC;YACZ,KAAK,CAAC,IAAI,CAAC,2BAAmB,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/D,CAAC;CACJ;AA7ID,8CA6IC","sourcesContent":["import { ApiDocModel, DocumentedEndpoint } from '@webpieces/api-doc-model';\nimport {\n ApiTypeKind,\n EXTERNAL_CUSTOMER,\n MCP,\n SVC_TO_SVC,\n} from '@webpieces/core-util';\n\n/** The one line that says a document is not the customer contract. It appears in exactly one. */\nexport const INTERNAL_ONLY_LINE =\n 'INTERNAL — service-to-service use only. This document lists every endpoint these services serve, including ones no customer is meant to see. It is not the customer contract and must never be handed to one.';\n\n/**\n * The retry contract, published ONCE per document rather than as booleans stamped on every operation.\n *\n * Each route's own `description` ends with one derived sentence saying whether it is safe to\n * retry; this table says where that sentence comes from. Webhooks are excluded (#1302): the sentence\n * tells a CALLER whether to repeat a call, and a webhook's caller is us — so a document holding only\n * webhooks states no table at all (see {@link DocumentSelection.description}). Three vendor-extension booleans per\n * operation would have been invisible to a human — Swagger UI and most themes do not render `x-`\n * extensions, and no standard generator reads `x-webpieces-*` — and would have tripled golden churn\n * the day the mapping changed.\n */\nexport const OPERATION_SEMANTICS = [\n \"Every route under `paths` states whether it is safe to retry, derived from the endpoint's\",\n 'declared side-effect contract. It covers routes only: a webhook is a call we send, and we',\n 'retry its delivery ourselves, so a webhook carries no retry sentence.',\n '',\n '| declared operation | read-only | destructive | idempotent |',\n '|---|---|---|---|',\n '| read | yes | no | yes |',\n '| write-idempotent | no | yes | yes |',\n '| write | no | yes | no |',\n].join('\\n');\n\n/**\n * WHICH contracts and operations a document contains, and what prose it stamps. The ONLY thing that\n * differs between the three generated documents.\n *\n * ## Two orthogonal decisions, at two levels\n *\n * - `@ApiType(SVC_TO_SVC, EXTERNAL_CUSTOMER)` on the CONTRACT selects which FILES it feeds. A document\n * is written at all only when some contract declares its type, so no contract declaring `MCP` means\n * no `mcp-openapi.json` — there is no second emptiness rule to keep in step with that one.\n * - `{ hidden: true }` on ONE `@Endpoint` subtracts that method from the CUSTOMER document only. It\n * stays in the private document, and in the MCP document when it is a tool.\n *\n * - `@hidden` in ONE field's JSDoc subtracts that field from the CUSTOMER document only (#1246),\n * with exactly the audience of `{ hidden: true }`: kept in the private document, and in the MCP\n * document and tool catalogs.\n *\n * The per-method case is real and cannot be said at class level: a NEW endpoint on an\n * already-published API, built on main before it is announced. The per-field case is the same thing\n * one level down: a new field on an already-published DTO. The per-contract case is the one that\n * must not default to permissive, and at class level naming it costs one token per contract.\n *\n * ## Select, then render — never render, then filter\n *\n * One render function takes one of these and is called once per document. It builds\n * `components.schemas` by walking OUTWARD from the operations this selection accepted, so an\n * unselected operation's DTOs are never constructed at all.\n *\n * That asymmetry is about what a BUG does. Build-then-filter puts an unreleased feature's full\n * request and response schemas into the document and then relies on a removal pass to take them out\n * again — so a defect in the visibility logic SHIPS them, named and fully shaped, with only the URL\n * missing, to customers who were told the feature was withheld. Select-then-render cannot do that:\n * no code path can emit a schema that was never built.\n *\n * The usual objection to rendering more than once — that the passes drift in how each renders the\n * same endpoint — applies to separate code paths. This is ONE function, so same code, same input,\n * same output.\n *\n * ## The thing that bites: map ordering\n *\n * Collecting schemas during a walk makes the key order of `components.schemas` depend on which\n * operations were walked, so two documents would list identical schemas in different orders and the\n * goldens would churn on unrelated changes. The renderer SORTS the schema keys before emitting.\n * Orders that carry MEANING are left alone and said so where they are built: `apis[]` order is the\n * published sidebar, and the security-scheme order is the order the credentials are declared in.\n */\nexport class DocumentSelection {\n private constructor(\n /** The file name this document is written to, and the name a failure uses for it. */\n readonly fileName: string,\n /** The `@ApiType` a contract must declare to appear in this document. */\n readonly apiType: ApiTypeKind,\n /**\n * Drop methods marked `{ hidden: true }` AND fields marked `@hidden` (#1246). True for the\n * customer document alone — one flag, because the two are one audience decision at two\n * levels, and a second flag could only ever disagree with the first.\n */\n readonly dropHidden: boolean,\n /** Stamp `x-mcp-tool` and its siblings. Only the MCP document has a reader for them. */\n readonly includeMcpExtensions: boolean,\n /**\n * Prepend {@link INTERNAL_ONLY_LINE} to `info.description`, and say what TRIGGERS each\n * operation. Both are internal facts: a customer calls what they are given a url for, and\n * whether ours fires on a clock or off a queue is our business.\n */\n readonly internalNotice: boolean,\n /**\n * Define EVERY reached schema locally, whichever package declares it, and write no bundled\n * sibling — the MCP projection (#1058). The MCP document is the agent-facing view our own MCP\n * tooling reads, and MCP never requires a DTO library to publish a components document: an\n * MCP-only consumer is not forced to tag anything. The other two documents are SPLIT — they\n * `$ref` every other package's schema, and fail closed when that package publishes none.\n */\n readonly inlinesEveryPackage: boolean,\n /**\n * Define a single-use request/response wrapper INLINE at its operation, with its published\n * name as `title`, rather than in `components.schemas` (#1303) — see `InlinedWrappers`. The\n * split documents and their bundled siblings do; the MCP projection keeps every wrapper a\n * component, unchanged.\n */\n readonly inlinesWrappers: boolean,\n /**\n * Stamp the `x-webpieces-*` operation extensions (`x-webpieces-authentication`,\n * `x-webpieces-webhook`). False for the PUBLIC document alone (#1303): they carry source\n * identifiers and internal tooling's facts, and everything a partner needs is already in the\n * standard `security` / `securitySchemes` and `webhooks:` keys.\n */\n readonly includeWebpiecesExtensions: boolean,\n ) {}\n\n /** Every contract declaring `SVC_TO_SVC` — which, by the fail-closed default, is every contract. */\n // webpieces-disable no-function-outside-class -- static factory; the private constructor is what stops a fourth, unnamed selection being invented at a call site\n static internal(): DocumentSelection {\n return new DocumentSelection(\n 'full-private-openapi',\n SVC_TO_SVC,\n false,\n false,\n true,\n false,\n true,\n true,\n );\n }\n\n /** Every contract declaring `EXTERNAL_CUSTOMER`, minus its hidden methods. */\n // webpieces-disable no-function-outside-class -- static factory of this class\n static customer(): DocumentSelection {\n return new DocumentSelection(\n 'public-openapi',\n EXTERNAL_CUSTOMER,\n true,\n false,\n false,\n false,\n true,\n false,\n );\n }\n\n /**\n * Every contract declaring `MCP`. A HIDDEN method is kept, and so is a `@hidden` field (#1246) — an internal endpoint that is an agent\n * tool is still a tool, and requiring it to be published to customers in order to be one would be\n * exactly the wrong coupling.\n */\n // webpieces-disable no-function-outside-class -- static factory of this class\n static mcp(): DocumentSelection {\n return new DocumentSelection('mcp-openapi', MCP, false, true, false, true, false, true);\n }\n\n /** Every document this generator knows how to write, in the order it writes them. */\n // webpieces-disable no-function-outside-class -- static factory of this class\n static all(): readonly DocumentSelection[] {\n return [\n DocumentSelection.internal(),\n DocumentSelection.customer(),\n DocumentSelection.mcp(),\n ];\n }\n\n acceptsContract(model: ApiDocModel): boolean {\n return model.apiTypes.includes(this.apiType);\n }\n\n /**\n * `{ hidden: true }` subtracts a method from the CUSTOMER document, and `@WpLocalOnly`\n * subtracts it from ALL of them.\n *\n * A local-only endpoint is not registered as a route at all once the process is deployed, so it\n * exists nowhere any reader of any of these documents could call it. Publishing it even in the\n * private one would document a route that does not exist in any deployed environment — worse\n * than omitting it, because a reader would reasonably try to call it.\n *\n * `@InvalidEndpointForMcp` subtracts a method from the MCP document ONLY (#1447). The method is\n * declared permanently unusable as an agent tool — typically because its shape cannot be an MCP\n * schema at all — so the agent-facing projection must not carry it, while the private and\n * customer documents still publish it exactly as before.\n */\n acceptsEndpoint(endpoint: DocumentedEndpoint): boolean {\n if (endpoint.localOnly) {\n return false;\n }\n if (this.apiType === MCP && endpoint.invalidForMcp !== undefined) {\n return false;\n }\n return !this.dropHidden || !endpoint.hidden;\n }\n\n /**\n * `info.description`: the manifest's prose, plus whatever this document adds to it.\n *\n * `hasRoutes` is false when every operation in the document is a webhook. The retry table then\n * describes a sentence no operation carries, so it is left out (#1302).\n */\n description(manifestDescription: string | undefined, hasRoutes: boolean): string | undefined {\n const parts: string[] = [];\n if (this.internalNotice) {\n parts.push(INTERNAL_ONLY_LINE);\n }\n if (manifestDescription !== undefined) {\n parts.push(manifestDescription);\n }\n if (hasRoutes) {\n parts.push(OPERATION_SEMANTICS);\n }\n return parts.length === 0 ? undefined : parts.join('\\n\\n');\n }\n}\n"]}
1
+ {"version":3,"file":"DocumentSelection.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/DocumentSelection.ts"],"names":[],"mappings":";;;AACA,oDAK8B;AAE9B,iGAAiG;AACpF,QAAA,kBAAkB,GAC3B,+MAA+M,CAAC;AAEpN;;;;;;;;;;GAUG;AACU,QAAA,mBAAmB,GAAG;IAC/B,2FAA2F;IAC3F,2FAA2F;IAC3F,uEAAuE;IACvE,EAAE;IACF,+DAA+D;IAC/D,mBAAmB;IACnB,2BAA2B;IAC3B,uCAAuC;IACvC,2BAA2B;CAC9B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,MAAa,iBAAiB;IAGb;IAEA;IAMA;IAEA;IAMA;IAQA;IAOA;IAOA;IAxCb;IACI,qFAAqF;IAC5E,QAAgB;IACzB,yEAAyE;IAChE,OAAoB;IAC7B;;;;OAIG;IACM,UAAmB;IAC5B,yFAAyF;IAChF,oBAA6B;IACtC;;;;OAIG;IACM,cAAuB;IAChC;;;;;;OAMG;IACM,mBAA4B;IACrC;;;;;OAKG;IACM,eAAwB;IACjC;;;;;OAKG;IACM,0BAAmC;QAtCnC,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,YAAO,GAAP,OAAO,CAAa;QAMpB,eAAU,GAAV,UAAU,CAAS;QAEnB,yBAAoB,GAApB,oBAAoB,CAAS;QAM7B,mBAAc,GAAd,cAAc,CAAS;QAQvB,wBAAmB,GAAnB,mBAAmB,CAAS;QAO5B,oBAAe,GAAf,eAAe,CAAS;QAOxB,+BAA0B,GAA1B,0BAA0B,CAAS;IAC7C,CAAC;IAEJ,oGAAoG;IACpG,iKAAiK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ACH,WAAW,CAAC,mBAAuC,EAAE,SAAkB;QACnE,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,IAAI,IAAI,CAAC,cAAc,EAAE,CAAC;YACtB,KAAK,CAAC,IAAI,CAAC,0BAAkB,CAAC,CAAC;QACnC,CAAC;QACD,IAAI,mBAAmB,KAAK,SAAS,EAAE,CAAC;YACpC,KAAK,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;QACpC,CAAC;QACD,IAAI,SAAS,EAAE,CAAC;YACZ,KAAK,CAAC,IAAI,CAAC,2BAAmB,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/D,CAAC;CACJ;AA7ID,8CA6IC","sourcesContent":["import { ApiDocModel, DocumentedEndpoint } from '@webpieces/api-doc-model';\nimport {\n ApiTypeKind,\n EXTERNAL_CUSTOMER,\n MCP,\n SVC_TO_SVC,\n} from '@webpieces/core-util';\n\n/** The one line that says a document is not the customer contract. It appears in exactly one. */\nexport const INTERNAL_ONLY_LINE =\n 'INTERNAL — service-to-service use only. This document lists every endpoint these services serve, including ones no customer is meant to see. It is not the customer contract and must never be handed to one.';\n\n/**\n * The retry contract, published ONCE per document rather than as booleans stamped on every operation.\n *\n * Each route's own `description` ends with one derived sentence saying whether it is safe to\n * retry; this table says where that sentence comes from. Webhooks are excluded (#1302): the sentence\n * tells a CALLER whether to repeat a call, and a webhook's caller is us — so a document holding only\n * webhooks states no table at all (see {@link DocumentSelection.description}). Three vendor-extension booleans per\n * operation would have been invisible to a human — Swagger UI and most themes do not render `x-`\n * extensions, and no standard generator reads `x-webpieces-*` — and would have tripled golden churn\n * the day the mapping changed.\n */\nexport const OPERATION_SEMANTICS = [\n \"Every route under `paths` states whether it is safe to retry, derived from the endpoint's\",\n 'declared side-effect contract. It covers routes only: a webhook is a call we send, and we',\n 'retry its delivery ourselves, so a webhook carries no retry sentence.',\n '',\n '| declared operation | read-only | destructive | idempotent |',\n '|---|---|---|---|',\n '| read | yes | no | yes |',\n '| write-idempotent | no | yes | yes |',\n '| write | no | yes | no |',\n].join('\\n');\n\n/**\n * WHICH contracts and operations a document contains, and what prose it stamps. The ONLY thing that\n * differs between the three generated documents.\n *\n * ## Two orthogonal decisions, at two levels\n *\n * - `@ApiType(SVC_TO_SVC, EXTERNAL_CUSTOMER)` on the CONTRACT selects which FILES it feeds. A document\n * is written at all only when some contract declares its type, so no contract declaring `MCP` means\n * no `mcp-openapi.json` — there is no second emptiness rule to keep in step with that one.\n * - `{ hidden: true }` on ONE `@Endpoint` subtracts that method from the CUSTOMER document only. It\n * stays in the private document, and in the MCP document when it is a tool.\n *\n * - `@hidden` in ONE field's JSDoc subtracts that field from the CUSTOMER document only (#1246),\n * with exactly the audience of `{ hidden: true }`: kept in the private document, and in the MCP\n * document and tool catalogs.\n *\n * The per-method case is real and cannot be said at class level: a NEW endpoint on an\n * already-published API, built on main before it is announced. The per-field case is the same thing\n * one level down: a new field on an already-published DTO. The per-contract case is the one that\n * must not default to permissive, and at class level naming it costs one token per contract.\n *\n * ## Select, then render — never render, then filter\n *\n * One render function takes one of these and is called once per document. It builds\n * `components.schemas` by walking OUTWARD from the operations this selection accepted, so an\n * unselected operation's DTOs are never constructed at all.\n *\n * That asymmetry is about what a BUG does. Build-then-filter puts an unreleased feature's full\n * request and response schemas into the document and then relies on a removal pass to take them out\n * again — so a defect in the visibility logic SHIPS them, named and fully shaped, with only the URL\n * missing, to customers who were told the feature was withheld. Select-then-render cannot do that:\n * no code path can emit a schema that was never built.\n *\n * The usual objection to rendering more than once — that the passes drift in how each renders the\n * same endpoint — applies to separate code paths. This is ONE function, so same code, same input,\n * same output.\n *\n * ## The thing that bites: map ordering\n *\n * Collecting schemas during a walk makes the key order of `components.schemas` depend on which\n * operations were walked, so two documents would list identical schemas in different orders and the\n * goldens would churn on unrelated changes. The renderer SORTS the schema keys before emitting.\n * Orders that carry MEANING are left alone and said so where they are built: `apis[]` order is the\n * published sidebar, and the security-scheme order is the order the credentials are declared in.\n */\nexport class DocumentSelection {\n private constructor(\n /** The file name this document is written to, and the name a failure uses for it. */\n readonly fileName: string,\n /** The `@ApiType` a contract must declare to appear in this document. */\n readonly apiType: ApiTypeKind,\n /**\n * Drop methods marked `{ hidden: true }` AND fields marked `@hidden` (#1246). True for the\n * customer document alone — one flag, because the two are one audience decision at two\n * levels, and a second flag could only ever disagree with the first.\n */\n readonly dropHidden: boolean,\n /** Stamp `x-mcp-tools` and its siblings. Only the MCP document has a reader for them. */\n readonly includeMcpExtensions: boolean,\n /**\n * Prepend {@link INTERNAL_ONLY_LINE} to `info.description`, and say what TRIGGERS each\n * operation. Both are internal facts: a customer calls what they are given a url for, and\n * whether ours fires on a clock or off a queue is our business.\n */\n readonly internalNotice: boolean,\n /**\n * Define EVERY reached schema locally, whichever package declares it, and write no bundled\n * sibling — the MCP projection (#1058). The MCP document is the agent-facing view our own MCP\n * tooling reads, and MCP never requires a DTO library to publish a components document: an\n * MCP-only consumer is not forced to tag anything. The other two documents are SPLIT — they\n * `$ref` every other package's schema, and fail closed when that package publishes none.\n */\n readonly inlinesEveryPackage: boolean,\n /**\n * Define a single-use request/response wrapper INLINE at its operation, with its published\n * name as `title`, rather than in `components.schemas` (#1303) — see `InlinedWrappers`. The\n * split documents and their bundled siblings do; the MCP projection keeps every wrapper a\n * component, unchanged.\n */\n readonly inlinesWrappers: boolean,\n /**\n * Stamp the `x-webpieces-*` operation extensions (`x-webpieces-authentication`,\n * `x-webpieces-webhook`). False for the PUBLIC document alone (#1303): they carry source\n * identifiers and internal tooling's facts, and everything a partner needs is already in the\n * standard `security` / `securitySchemes` and `webhooks:` keys.\n */\n readonly includeWebpiecesExtensions: boolean,\n ) {}\n\n /** Every contract declaring `SVC_TO_SVC` — which, by the fail-closed default, is every contract. */\n // webpieces-disable no-function-outside-class -- static factory; the private constructor is what stops a fourth, unnamed selection being invented at a call site\n static internal(): DocumentSelection {\n return new DocumentSelection(\n 'full-private-openapi',\n SVC_TO_SVC,\n false,\n false,\n true,\n false,\n true,\n true,\n );\n }\n\n /** Every contract declaring `EXTERNAL_CUSTOMER`, minus its hidden methods. */\n // webpieces-disable no-function-outside-class -- static factory of this class\n static customer(): DocumentSelection {\n return new DocumentSelection(\n 'public-openapi',\n EXTERNAL_CUSTOMER,\n true,\n false,\n false,\n false,\n true,\n false,\n );\n }\n\n /**\n * Every contract declaring `MCP`. A HIDDEN method is kept, and so is a `@hidden` field (#1246) — an internal endpoint that is an agent\n * tool is still a tool, and requiring it to be published to customers in order to be one would be\n * exactly the wrong coupling.\n */\n // webpieces-disable no-function-outside-class -- static factory of this class\n static mcp(): DocumentSelection {\n return new DocumentSelection('mcp-openapi', MCP, false, true, false, true, false, true);\n }\n\n /** Every document this generator knows how to write, in the order it writes them. */\n // webpieces-disable no-function-outside-class -- static factory of this class\n static all(): readonly DocumentSelection[] {\n return [\n DocumentSelection.internal(),\n DocumentSelection.customer(),\n DocumentSelection.mcp(),\n ];\n }\n\n acceptsContract(model: ApiDocModel): boolean {\n return model.apiTypes.includes(this.apiType);\n }\n\n /**\n * `{ hidden: true }` subtracts a method from the CUSTOMER document, and `@WpLocalOnly`\n * subtracts it from ALL of them.\n *\n * A local-only endpoint is not registered as a route at all once the process is deployed, so it\n * exists nowhere any reader of any of these documents could call it. Publishing it even in the\n * private one would document a route that does not exist in any deployed environment — worse\n * than omitting it, because a reader would reasonably try to call it.\n *\n * `@InvalidEndpointForMcp` subtracts a method from the MCP document ONLY (#1447). The method is\n * declared permanently unusable as an agent tool — typically because its shape cannot be an MCP\n * schema at all — so the agent-facing projection must not carry it, while the private and\n * customer documents still publish it exactly as before.\n */\n acceptsEndpoint(endpoint: DocumentedEndpoint): boolean {\n if (endpoint.localOnly) {\n return false;\n }\n if (this.apiType === MCP && endpoint.invalidForMcp !== undefined) {\n return false;\n }\n return !this.dropHidden || !endpoint.hidden;\n }\n\n /**\n * `info.description`: the manifest's prose, plus whatever this document adds to it.\n *\n * `hasRoutes` is false when every operation in the document is a webhook. The retry table then\n * describes a sentence no operation carries, so it is left out (#1302).\n */\n description(manifestDescription: string | undefined, hasRoutes: boolean): string | undefined {\n const parts: string[] = [];\n if (this.internalNotice) {\n parts.push(INTERNAL_ONLY_LINE);\n }\n if (manifestDescription !== undefined) {\n parts.push(manifestDescription);\n }\n if (hasRoutes) {\n parts.push(OPERATION_SEMANTICS);\n }\n return parts.length === 0 ? undefined : parts.join('\\n\\n');\n }\n}\n"]}
@@ -28,14 +28,15 @@ class McpToolNameGuard {
28
28
  continue;
29
29
  }
30
30
  for (const endpoint of contract.model.endpoints) {
31
- const tool = endpoint.mcpTool;
32
- if (tool === undefined || !selection.acceptsEndpoint(endpoint)) {
31
+ if (!selection.acceptsEndpoint(endpoint)) {
33
32
  continue;
34
33
  }
35
- const problem = core_util_1.McpToolName.problemWith(tool.name);
36
- if (problem !== undefined) {
37
- offenders.push(`${contract.model.contractName}.${endpoint.methodName}: tool name ` +
38
- `'${tool.name}' ${problem} (${contract.file})`);
34
+ for (const tool of endpoint.mcpTools) {
35
+ const problem = core_util_1.McpToolName.problemWith(tool.name);
36
+ if (problem !== undefined) {
37
+ offenders.push(`${contract.model.contractName}.${endpoint.methodName}: tool name ` +
38
+ `'${tool.name}' ${problem} (${contract.file})`);
39
+ }
39
40
  }
40
41
  }
41
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"McpToolNameGuard.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/McpToolNameGuard.ts"],"names":[],"mappings":";;;AAAA,oDAAmD;AACnD,sEAAmE;AAEnE,2DAAwD;AAExD;;;;;;;;;;;;;GAaG;AACH,MAAa,gBAAgB;IACzB,mEAAmE;IACnE,MAAM,CAAC,SAAmC,EAAE,YAAoB;QAC5D,MAAM,SAAS,GAAG,qCAAiB,CAAC,GAAG,EAAE,CAAC;QAC1C,MAAM,SAAS,GAAa,EAAE,CAAC;QAC/B,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YAC/B,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7C,SAAS;YACb,CAAC;YACD,KAAK,MAAM,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;gBAC9C,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC;gBAC9B,IAAI,IAAI,KAAK,SAAS,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;oBAC7D,SAAS;gBACb,CAAC;gBACD,MAAM,OAAO,GAAG,uBAAW,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACnD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;oBACxB,SAAS,CAAC,IAAI,CACV,GAAG,QAAQ,CAAC,KAAK,CAAC,YAAY,IAAI,QAAQ,CAAC,UAAU,cAAc;wBAC/D,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,KAAK,QAAQ,CAAC,IAAI,GAAG,CACrD,CAAC;gBACN,CAAC;YACL,CAAC;QACL,CAAC;QACD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO;QACX,CAAC;QACD,MAAM,IAAI,+CAAsB,CAC5B,GAAG,SAAS,CAAC,MAAM,uEAAuE,EAC1F,YAAY,EACZ,uBAAW,CAAC,IAAI,EAAE,EAClB,SAAS,CACZ,CAAC;IACN,CAAC;CACJ;AAjCD,4CAiCC","sourcesContent":["import { McpToolName } from '@webpieces/core-util';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\nimport { ContractModel } from './GenerationInputs';\nimport { DocumentSelection } from './DocumentSelection';\n\n/**\n * The refusal for an MCP tool whose stable protocol name the Claude Connectors Directory would refuse\n * (#1296): longer than {@link McpToolName.MAX_LENGTH} characters, or using a character outside\n * `[A-Za-z0-9_-]`.\n *\n * MCP itself allows up to 128 characters and a dot, but a server with even one longer name cannot be\n * listed in the Directory, and a tool name is the protocol identity agents save — renaming it later\n * breaks them. So it is refused at generation, where the author can still pick the final name, and\n * every offender of the run is named at once, before anything is rendered. The rule itself is\n * {@link McpToolName}, the one `@WpMcpTool`, the catalog codec and `api-rules-for-mcp` also apply.\n *\n * It judges every `@WpMcpTool` of every contract the MCP output selects — exactly the tools\n * `mcp-openapi.json` and the `mcp-<Contract>-tools.json` catalogs would publish.\n */\nexport class McpToolNameGuard {\n /** Refuse when any MCP tool of `contracts` has an illegal name. */\n refuse(contracts: readonly ContractModel[], manifestPath: string): void {\n const selection = DocumentSelection.mcp();\n const offenders: string[] = [];\n for (const contract of contracts) {\n if (!selection.acceptsContract(contract.model)) {\n continue;\n }\n for (const endpoint of contract.model.endpoints) {\n const tool = endpoint.mcpTool;\n if (tool === undefined || !selection.acceptsEndpoint(endpoint)) {\n continue;\n }\n const problem = McpToolName.problemWith(tool.name);\n if (problem !== undefined) {\n offenders.push(\n `${contract.model.contractName}.${endpoint.methodName}: tool name ` +\n `'${tool.name}' ${problem} (${contract.file})`,\n );\n }\n }\n }\n if (offenders.length === 0) {\n return;\n }\n throw new OpenApiGenerationError(\n `${offenders.length} MCP tool name(s) would be refused by the Claude Connectors Directory`,\n manifestPath,\n McpToolName.cure(),\n offenders,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"McpToolNameGuard.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/McpToolNameGuard.ts"],"names":[],"mappings":";;;AAAA,oDAAmD;AACnD,sEAAmE;AAEnE,2DAAwD;AAExD;;;;;;;;;;;;;GAaG;AACH,MAAa,gBAAgB;IACzB,mEAAmE;IACnE,MAAM,CAAC,SAAmC,EAAE,YAAoB;QAC5D,MAAM,SAAS,GAAG,qCAAiB,CAAC,GAAG,EAAE,CAAC;QAC1C,MAAM,SAAS,GAAa,EAAE,CAAC;QAC/B,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YAC/B,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7C,SAAS;YACb,CAAC;YACD,KAAK,MAAM,QAAQ,IAAI,QAAQ,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC;gBAC9C,IAAI,CAAC,SAAS,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,CAAC;oBACvC,SAAS;gBACb,CAAC;gBACD,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,QAAQ,EAAE,CAAC;oBACnC,MAAM,OAAO,GAAG,uBAAW,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACnD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;wBACxB,SAAS,CAAC,IAAI,CACV,GAAG,QAAQ,CAAC,KAAK,CAAC,YAAY,IAAI,QAAQ,CAAC,UAAU,cAAc;4BAC/D,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,KAAK,QAAQ,CAAC,IAAI,GAAG,CACrD,CAAC;oBACN,CAAC;gBACL,CAAC;YACL,CAAC;QACL,CAAC;QACD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO;QACX,CAAC;QACD,MAAM,IAAI,+CAAsB,CAC5B,GAAG,SAAS,CAAC,MAAM,uEAAuE,EAC1F,YAAY,EACZ,uBAAW,CAAC,IAAI,EAAE,EAClB,SAAS,CACZ,CAAC;IACN,CAAC;CACJ;AAlCD,4CAkCC","sourcesContent":["import { McpToolName } from '@webpieces/core-util';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\nimport { ContractModel } from './GenerationInputs';\nimport { DocumentSelection } from './DocumentSelection';\n\n/**\n * The refusal for an MCP tool whose stable protocol name the Claude Connectors Directory would refuse\n * (#1296): longer than {@link McpToolName.MAX_LENGTH} characters, or using a character outside\n * `[A-Za-z0-9_-]`.\n *\n * MCP itself allows up to 128 characters and a dot, but a server with even one longer name cannot be\n * listed in the Directory, and a tool name is the protocol identity agents save — renaming it later\n * breaks them. So it is refused at generation, where the author can still pick the final name, and\n * every offender of the run is named at once, before anything is rendered. The rule itself is\n * {@link McpToolName}, the one `@WpMcpTool`, the catalog codec and `api-rules-for-mcp` also apply.\n *\n * It judges every `@WpMcpTool` of every contract the MCP output selects — exactly the tools\n * `mcp-openapi.json` and the `mcp-<Contract>-tools.json` catalogs would publish.\n */\nexport class McpToolNameGuard {\n /** Refuse when any MCP tool of `contracts` has an illegal name. */\n refuse(contracts: readonly ContractModel[], manifestPath: string): void {\n const selection = DocumentSelection.mcp();\n const offenders: string[] = [];\n for (const contract of contracts) {\n if (!selection.acceptsContract(contract.model)) {\n continue;\n }\n for (const endpoint of contract.model.endpoints) {\n if (!selection.acceptsEndpoint(endpoint)) {\n continue;\n }\n for (const tool of endpoint.mcpTools) {\n const problem = McpToolName.problemWith(tool.name);\n if (problem !== undefined) {\n offenders.push(\n `${contract.model.contractName}.${endpoint.methodName}: tool name ` +\n `'${tool.name}' ${problem} (${contract.file})`,\n );\n }\n }\n }\n }\n if (offenders.length === 0) {\n return;\n }\n throw new OpenApiGenerationError(\n `${offenders.length} MCP tool name(s) would be refused by the Claude Connectors Directory`,\n manifestPath,\n McpToolName.cure(),\n offenders,\n );\n }\n}\n"]}
@@ -41,7 +41,7 @@ export declare class ResponseContract {
41
41
  *
42
42
  * ## The MCP extensions ride HERE, on the operation
43
43
  *
44
- * `x-mcp-tool`, `x-mcp-hints`, `x-mcp-description` and `x-mcp-auth` are stamped on every operation
44
+ * `x-mcp-tools`, `x-mcp-hints`, `x-mcp-description` and `x-mcp-auth` are stamped on every operation
45
45
  * carrying the tool decorator, hidden or not: an internal endpoint that is an agent tool is a
46
46
  * legitimate agent tool, and requiring it to be published to partners in order to be one would be
47
47
  * exactly the wrong coupling.
@@ -149,13 +149,13 @@ export declare class OperationRenderer {
149
149
  * only ever adds: it lowers `destructiveHint` to false, still through `mcpHintsForOperation` (#1422).
150
150
  *
151
151
  * ## The title is the operation's `summary`, published as the Tool's `title` AND `annotations.title`
152
- *
153
- * `x-mcp-title` and `x-mcp-hints.title` carry the `@summary` line exactly as `tools/list` serves it:
154
- * `Tool.title` for clients on the 2025-06-18+ spec and `annotations.title` (the block `x-mcp-hints`
155
- * mirrors) for older clients and the Claude Connectors Directory (#1296). One source, so they cannot
156
- * differ from the operation's own `summary`.
157
- *
158
- * ## There is no separate MCP description
152
+ *
153
+ * `x-mcp-title` and `x-mcp-hints.title` carry the `@summary` line exactly as `tools/list` serves it:
154
+ * `Tool.title` for clients on the 2025-06-18+ spec and `annotations.title` (the block `x-mcp-hints`
155
+ * mirrors) for older clients and the Claude Connectors Directory (#1296). One source, so they cannot
156
+ * differ from the operation's own `summary`.
157
+ *
158
+ * ## There is no separate MCP description
159
159
  *
160
160
  * The agent reads the operation's `description` — the method's JSDoc — byte-identical to what the
161
161
  * partner reads. `x-mcp-description` appears ONLY when the author wrote an explicit `@mcp` JSDoc
@@ -53,7 +53,7 @@ exports.ResponseContract = ResponseContract;
53
53
  *
54
54
  * ## The MCP extensions ride HERE, on the operation
55
55
  *
56
- * `x-mcp-tool`, `x-mcp-hints`, `x-mcp-description` and `x-mcp-auth` are stamped on every operation
56
+ * `x-mcp-tools`, `x-mcp-hints`, `x-mcp-description` and `x-mcp-auth` are stamped on every operation
57
57
  * carrying the tool decorator, hidden or not: an internal endpoint that is an agent tool is a
58
58
  * legitimate agent tool, and requiring it to be published to partners in order to be one would be
59
59
  * exactly the wrong coupling.
@@ -235,25 +235,25 @@ class OperationRenderer {
235
235
  * only ever adds: it lowers `destructiveHint` to false, still through `mcpHintsForOperation` (#1422).
236
236
  *
237
237
  * ## The title is the operation's `summary`, published as the Tool's `title` AND `annotations.title`
238
- *
239
- * `x-mcp-title` and `x-mcp-hints.title` carry the `@summary` line exactly as `tools/list` serves it:
240
- * `Tool.title` for clients on the 2025-06-18+ spec and `annotations.title` (the block `x-mcp-hints`
241
- * mirrors) for older clients and the Claude Connectors Directory (#1296). One source, so they cannot
242
- * differ from the operation's own `summary`.
243
- *
244
- * ## There is no separate MCP description
238
+ *
239
+ * `x-mcp-title` and `x-mcp-hints.title` carry the `@summary` line exactly as `tools/list` serves it:
240
+ * `Tool.title` for clients on the 2025-06-18+ spec and `annotations.title` (the block `x-mcp-hints`
241
+ * mirrors) for older clients and the Claude Connectors Directory (#1296). One source, so they cannot
242
+ * differ from the operation's own `summary`.
243
+ *
244
+ * ## There is no separate MCP description
245
245
  *
246
246
  * The agent reads the operation's `description` — the method's JSDoc — byte-identical to what the
247
247
  * partner reads. `x-mcp-description` appears ONLY when the author wrote an explicit `@mcp` JSDoc
248
248
  * tag, which is a deliberate act rather than a second copy of the same paragraph.
249
249
  */
250
250
  withMcp(operation, endpoint) {
251
- if (!this.includeMcp || endpoint.mcpTool === undefined) {
251
+ if (!this.includeMcp || endpoint.mcpTools.length === 0) {
252
252
  return operation;
253
253
  }
254
254
  const hints = (0, core_util_1.mcpHintsForOperation)(this.operationOf(endpoint), endpoint.openWorld, endpoint.additive);
255
255
  return operation
256
- .set('x-mcp-tool', endpoint.mcpTool.name)
256
+ .set('x-mcp-tools', endpoint.mcpTools.map((tool) => new JsonObject_1.JsonObject().set('name', tool.name).set('profiles', tool.profiles)))
257
257
  .set('x-mcp-title', endpoint.summary)
258
258
  .set('x-mcp-hints', new JsonObject_1.JsonObject()
259
259
  .set('title', endpoint.summary)
@@ -1 +1 @@
1
- {"version":3,"file":"OperationRenderer.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/OperationRenderer.ts"],"names":[],"mappings":";;;AAAA,4DAMkC;AAClC,oDAU8B;AAC9B,mDAA2D;AAG3D,+CAA4C;AAC5C,sEAAmE;AAEnE,mEAAmE;AACnE,MAAM,WAAW,GAAG,8DAA8D,CAAC;AAEnF;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,oCAAoC,CAAC;AAExD,4FAA4F;AAC5F,M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QACpB,CAAC;QACD,OAAO,QAAQ,CAAC,GAAG,CACf,SAAS,EACT,IAAI,uBAAU,EAAE,CAAC,GAAG,CAChB,kBAAkB,EAClB,IAAI,uBAAU,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,CAC1D,CACJ,CAAC;IACN,CAAC;IAED;;;;;;OAMG;IACK,kBAAkB,CACtB,QAA4B,EAC5B,YAAoB,EACpB,MAAe,EACf,OAAgB;QAEhB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;QACxD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,OAAO,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,+CAAsB,CAC5B,GAAG,QAAQ,CAAC,UAAU,sCAAsC,EAC5D,GAAG,YAAY,IAAI,QAAQ,CAAC,UAAU,gCAAgC,EACtE,mFAAmF;gBAC/E,wDAAwD,CAC/D,CAAC;QACN,CAAC;QACD,OAAO,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC;IAC9C,CAAC;IAEO,KAAK,CAAC,IAAwB;QAClC,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IACvE,CAAC;CACJ;AArZD,8CAqZC","sourcesContent":["import {\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedParameter,\n OperationIds,\n OperationIdStyle,\n} from '@webpieces/api-doc-model';\nimport {\n CLOUDTASKS,\n CRON,\n EXTERNAL_INBOUND,\n mcpHintsForOperation,\n READ,\n RPC,\n WRITE,\n WRITE_IDEMPOTENT,\n verbCarriesBody,\n} from '@webpieces/core-util';\nimport { JsonObject, JsonValue } from '../json/JsonObject';\nimport { ErrorResponseEntry } from '../manifest/OpenApiManifest';\nimport { SchemaRenderer } from './SchemaRenderer';\nimport { SuccessBody } from './SuccessBody';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\n\n/** What a webhook's `void` return means on the wire, said once. */\nconst ACKNOWLEDGE = 'Return any 2xx to acknowledge delivery. The body is ignored.';\n\n/**\n * What a served route's `void` return means on the wire: our server answers `204` with 0 bytes\n * (#1339) — whether `responseBody: NONE` declares it (RPC / EXTERNAL_INBOUND) or the CLOUDTASKS / CRON kind\n * implies it (#1348; the scan requires such a method to return `Promise<void>`, so it renders here\n * exactly like NONE). Only a WEBHOOK keeps {@link ACKNOWLEDGE} — there the PARTNER answers, and an\n * EXTERNAL_OUTBOUND contract is always published as one, so its void is never documented as a 204.\n */\nconst NO_CONTENT = 'Success. The response has no body.';\n\n/** The response document, and the responses a document-wide failure contract adds to it. */\nexport class ResponseContract {\n constructor(\n /** The manifest's `errors.responses`, in declared order. */\n readonly errors: readonly ErrorResponseEntry[],\n /** `$ref` at the error body schema, when the manifest declared one. */\n readonly errorSchemaRef: JsonObject | undefined,\n /**\n * Header name -> its `components.headers` `$ref`, on the success response AND on every\n * failure listed for the operation (#1270). The server stamps the header on every response,\n * and the failing one is the response a partner most needs to quote back.\n */\n readonly headers: JsonObject | undefined,\n ) {}\n}\n\n/**\n * ONE {@link DocumentedEndpoint} -> one OpenAPI Operation Object.\n *\n * ## `summary` is the method's `@summary` JSDoc tag — a short title, never a sentence (#1296)\n *\n * A docs theme titles the endpoint's page from `summary` and labels its sidebar with it, and puts\n * `description` in the body. It used to be the bare method name, which put code identifiers in every\n * heading. It is now the `@summary` line the author wrote — one line, at most 100 characters,\n * REQUIRED on every published operation by {@link SummaryGuard} — and the tag is not part of\n * `description`, so the page does not repeat its own heading. The code identifier stays published as\n * `operationId`, which is what a generated client names the method. The same line is the MCP tool's\n * `title`, so a partner's docs page and an agent's tool list name the endpoint identically.\n *\n * ## The MCP extensions ride HERE, on the operation\n *\n * `x-mcp-tool`, `x-mcp-hints`, `x-mcp-description` and `x-mcp-auth` are stamped on every operation\n * carrying the tool decorator, hidden or not: an internal endpoint that is an agent tool is a\n * legitimate agent tool, and requiring it to be published to partners in order to be one would be\n * exactly the wrong coupling.\n *\n * They are stamped on the BASE, which every published document is derived from, and\n * {@link DocumentDeriver} STRIPS them from the customer document. Stamping-then-stripping rather than\n * rendering the customer document without them is the same choice the whole deriver rests on: one\n * render of one operation, so two documents holding it cannot disagree about anything else in it.\n */\nexport class OperationRenderer {\n private readonly body = new SuccessBody();\n private readonly ids: OperationIds;\n\n constructor(\n private readonly schemas: SchemaRenderer,\n /** True only for the MCP document — see {@link withMcp}. */\n private readonly includeMcp: boolean,\n /** True only for the private document — see {@link triggerSentence}. */\n private readonly includeTrigger: boolean,\n /**\n * False only for the PUBLIC document (#1303): `x-webpieces-authentication` (whose `arguments`\n * are the TypeScript identifiers passed to `@WpAuth` — private names a partner cannot use) and\n * `x-webpieces-webhook` are internal tooling's. A partner's authentication is already in the\n * standard `components.securitySchemes` + `security`, and a webhook already sits in the\n * standard `webhooks:` block.\n */\n private readonly includeWebpieces: boolean,\n /** The manifest's `operationIds` — see {@link operationIdOf}. */\n operationIds: OperationIdStyle,\n ) {\n this.ids = new OperationIds(operationIds);\n }\n\n /**\n * The published `operationId`, in the manifest's chosen style (#1270).\n *\n * Public because the generator checks uniqueness with the SAME function before rendering: a\n * second spelling of the id there could pass a collision this one then publishes.\n */\n operationIdOf(endpoint: DocumentedEndpoint, contractName: string): string {\n return this.ids.of(contractName, endpoint.methodName);\n }\n\n /** An ordinary served route. */\n operation(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n security: readonly JsonValue[] | undefined,\n ): JsonObject {\n const operation = this.common(endpoint, contractName, tag, contract, true);\n // An endpoint that authenticates NOBODY says so explicitly: `security: []` is OpenAPI's\n // spelling of \"no credential required\", and leaving the key off instead means \"inherit the\n // document's\", which is a different statement that happens to coincide today.\n const explicit = this.isPublic(endpoint) ? [] : security;\n operation.set('security', explicit === undefined ? undefined : explicit.slice());\n return this.withMcp(operation, endpoint);\n }\n\n /**\n * A call WE make to a PARTNER's server.\n *\n * It carries `x-webpieces-webhook: true` in every document but the public one (#1303), where the\n * standard `webhooks:` block it sits in already says so. It gets no trigger sentence and no security at all, because neither is true of\n * it: nothing of ours triggers it and nothing of ours authenticates it — our api key must never\n * be published as a guard on somebody else's endpoint.\n *\n * It gets no retry sentence either (#1302). That sentence tells a CALLER whether it may repeat\n * the call, and the partner never calls a webhook — WE do, and we retry delivery ourselves. The\n * `@Endpoint` operation on a webhook method is an inert value the decorator requires (the\n * contract is never mounted as a route), so on a webhook \"NOT safe to retry\" would be backwards:\n * the receiver's concern is that one event can arrive more than once.\n */\n webhook(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n ): JsonObject {\n const operation = this.common(endpoint, contractName, tag, contract, false);\n return this.withMcp(\n operation.set('x-webpieces-webhook', this.includeWebpieces ? true : undefined),\n endpoint,\n );\n }\n\n private common(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n isRoute: boolean,\n ): JsonObject {\n return new JsonObject()\n .set('operationId', this.operationIdOf(endpoint, contractName))\n .set('x-webpieces-authentication', this.authentication(endpoint))\n .set('summary', endpoint.summary)\n .set('description', this.describe(endpoint, isRoute))\n .set('tags', [tag])\n .set('parameters', this.parameters(endpoint, contractName))\n .set('requestBody', this.requestBody(endpoint, contractName))\n .set('responses', this.responses(endpoint, contractName, contract, isRoute));\n }\n\n /** The declared `@WpAuth` methods, verbatim — never in the public document (#1303). */\n private authentication(endpoint: DocumentedEndpoint): readonly JsonValue[] | undefined {\n if (!this.includeWebpieces) {\n return undefined;\n }\n return endpoint.auth?.methods.map((method: DocumentedAuthMethod) =>\n new JsonObject().set('kind', method.kind).set('arguments', method.argumentTexts),\n );\n }\n\n /**\n * The JSDoc body, plus the sentences that are DERIVED rather than written.\n *\n * The retry sentence comes from the endpoint's declared `operation`, which every integration\n * wants to know and most APIs state nowhere. It is a SENTENCE and not a vendor extension because\n * Swagger UI and most themes do not render `x-` extensions and no standard generator reads\n * `x-webpieces-*`: an extension would be invisible to the human and unread by the machine. The\n * mapping it is derived from is published once, in `info.description`, so the rule is stated and\n * not only its consequences. It is stated on ROUTES only — a webhook is a call we make, so the\n * caller-facing retry sentence does not apply to it (see {@link webhook}).\n */\n private describe(endpoint: DocumentedEndpoint, isRoute: boolean): string | undefined {\n const parts: string[] = [];\n const body = this.prose(endpoint.description);\n if (body !== undefined) {\n parts.push(body);\n }\n // Both derived sentences are about a call the READER makes to us (may I repeat it? what\n // fires it?). A webhook is a call WE make to the reader, so neither applies (#1302).\n if (isRoute) {\n parts.push(this.retrySentence(endpoint));\n if (this.includeTrigger) {\n parts.push(this.triggerSentence(endpoint));\n }\n }\n if (endpoint.additive) {\n parts.push(\n 'Additive: it only adds new state; it does not delete, replace or irreversibly ' +\n 'change anything that already exists.',\n );\n }\n if (endpoint.openWorld) {\n parts.push(\n 'Reaches beyond this service: it may act on an external system, so its effects ' +\n 'are not all visible here.',\n );\n }\n return parts.length === 0 ? undefined : parts.join('\\n\\n');\n }\n\n /**\n * WHAT FIRES this endpoint, in the private document only.\n *\n * A customer calls what they are given a url for; whether ours runs off a queue or a clock is our\n * business and would only invite a question they cannot act on. It is a SENTENCE and not\n * `x-webpieces-trigger` for the same reason the retry sentence is: Swagger UI and most themes do\n * not render `x-` extensions, and no standard generator reads `x-webpieces-*`, so an extension is\n * invisible to the human and unread by the machine.\n */\n private triggerSentence(endpoint: DocumentedEndpoint): string {\n if (endpoint.kind === CLOUDTASKS) {\n return 'Triggered by a queued task, delivered asynchronously.';\n }\n if (endpoint.kind === CRON) {\n return 'Triggered on a schedule, not by a caller.';\n }\n if (endpoint.kind === EXTERNAL_INBOUND) {\n const caller = endpoint.options.calledBy;\n return caller === undefined\n ? 'Triggered by an outside system.'\n : `Triggered by an outside system: ${caller}.`;\n }\n return endpoint.kind === RPC\n ? 'Triggered by a direct call.'\n : `Triggered by: ${endpoint.kind}.`;\n }\n\n /** An endpoint whose declared credential is \"none\", said out loud rather than left absent. */\n private isPublic(endpoint: DocumentedEndpoint): boolean {\n return endpoint.auth?.publicReason !== undefined;\n }\n\n private retrySentence(endpoint: DocumentedEndpoint): string {\n if (endpoint.operation === READ) {\n return 'Safe to retry: this operation is read-only and idempotent.';\n }\n if (endpoint.operation === WRITE_IDEMPOTENT) {\n return 'Safe to retry: this operation changes state but is idempotent.';\n }\n return 'NOT safe to retry: this operation changes state and is not idempotent.';\n }\n\n /**\n * The MCP extensions, stamped only on the document that has an agent for a reader.\n *\n * ## The three side-effect hints are COMPUTED, never declared\n *\n * `mcpHintsForOperation` in `@webpieces/core-util` is the one place the mapping from\n * `READ | WRITE_IDEMPOTENT | WRITE` to `readOnlyHint` / `destructiveHint` / `idempotentHint`\n * lives, and this calls it rather than reimplementing it. The endpoint's `operation` already\n * states whether repeating the call is safe; a hand-declared hint would be a second answer to a\n * question the contract has answered, and the two could disagree. `openWorldHint` is the only one\n * a human declares, because it is a judgement about the world rather than a consequence of the\n * operation. The one refinement is `@Endpoint`'s `additive` option, which a write states when it\n * only ever adds: it lowers `destructiveHint` to false, still through `mcpHintsForOperation` (#1422).\n *\n * ## The title is the operation's `summary`, published as the Tool's `title` AND `annotations.title`\n *\n * `x-mcp-title` and `x-mcp-hints.title` carry the `@summary` line exactly as `tools/list` serves it:\n * `Tool.title` for clients on the 2025-06-18+ spec and `annotations.title` (the block `x-mcp-hints`\n * mirrors) for older clients and the Claude Connectors Directory (#1296). One source, so they cannot\n * differ from the operation's own `summary`.\n *\n * ## There is no separate MCP description\n *\n * The agent reads the operation's `description` — the method's JSDoc — byte-identical to what the\n * partner reads. `x-mcp-description` appears ONLY when the author wrote an explicit `@mcp` JSDoc\n * tag, which is a deliberate act rather than a second copy of the same paragraph.\n */\n private withMcp(operation: JsonObject, endpoint: DocumentedEndpoint): JsonObject {\n if (!this.includeMcp || endpoint.mcpTool === undefined) {\n return operation;\n }\n const hints = mcpHintsForOperation(\n this.operationOf(endpoint),\n endpoint.openWorld,\n endpoint.additive,\n );\n return operation\n .set('x-mcp-tool', endpoint.mcpTool.name)\n .set('x-mcp-title', endpoint.summary)\n .set(\n 'x-mcp-hints',\n new JsonObject()\n .set('title', endpoint.summary)\n .set('readOnlyHint', hints.readOnlyHint)\n .set('destructiveHint', hints.destructiveHint)\n .set('idempotentHint', hints.idempotentHint)\n .set('openWorldHint', hints.openWorldHint),\n )\n .set('x-mcp-description', this.prose(endpoint.mcpDescription))\n .set('x-webpieces-authorization', endpoint.authorizationText);\n }\n\n /**\n * The endpoint's operation as the REAL exported constant.\n *\n * The model carries it as a string, verbatim from the source, because the model invents no\n * taxonomy. Matching it back to the constant here — rather than casting — is what makes a rename\n * of `WRITE_IDEMPOTENT` in `core-util` a compile error in this file.\n */\n private operationOf(\n endpoint: DocumentedEndpoint,\n ): typeof READ | typeof WRITE_IDEMPOTENT | typeof WRITE {\n if (endpoint.operation === READ) {\n return READ;\n }\n return endpoint.operation === WRITE_IDEMPOTENT ? WRITE_IDEMPOTENT : WRITE;\n }\n\n /**\n * Every `@PathParam` / `@QueryParam` argument as an OpenAPI Parameter Object, in declaration order.\n * A list query argument is `style: form, explode: true` — repeated keys (`a=1&a=2`), which is what\n * the webpieces client sends. Absent (not `[]`) when the endpoint binds nothing to the URL, so a\n * contract with no URL parameters renders byte-identically to before.\n */\n private parameters(\n endpoint: DocumentedEndpoint,\n contractName: string,\n ): readonly JsonValue[] | undefined {\n if (endpoint.parameters.length === 0) {\n return undefined;\n }\n return endpoint.parameters.map((parameter: DocumentedParameter, index: number) => {\n const pointer = `#/paths/${contractName}_${endpoint.methodName}/parameters/${index}`;\n const schema =\n parameter.type === undefined\n ? new JsonObject().set('type', 'string')\n : this.schemas.type(parameter.type, pointer);\n const isList = parameter.type?.kind === 'array';\n return new JsonObject()\n .set('name', parameter.name)\n .set('in', parameter.location)\n .set('required', parameter.required)\n .set('style', isList ? 'form' : undefined)\n .set('explode', isList ? true : undefined)\n .set('schema', schema);\n });\n }\n\n /**\n * The request DTO as a body. Only for a verb that carries one (`verbCarriesBody`: POST, PUT,\n * PATCH): OpenAPI gives a `GET`/`DELETE` body no defined semantics and most tooling drops it, so\n * publishing one would document a request no generated client sends.\n */\n private requestBody(\n endpoint: DocumentedEndpoint,\n contractName: string,\n ): JsonObject | undefined {\n if (!verbCarriesBody(endpoint.httpMethod) || endpoint.request === undefined) {\n return undefined;\n }\n const pointer = `#/paths/${contractName}_${endpoint.methodName}/requestBody`;\n const media = endpoint.options.formPost\n ? 'application/x-www-form-urlencoded'\n : 'application/json';\n return new JsonObject()\n .set('required', true)\n .set(\n 'content',\n new JsonObject().set(\n media,\n new JsonObject().set('schema', this.schemas.body(endpoint.request, pointer)),\n ),\n );\n }\n\n private responses(\n endpoint: DocumentedEndpoint,\n contractName: string,\n contract: ResponseContract,\n isRoute: boolean,\n ): JsonObject {\n const responses = new JsonObject();\n // A void ROUTE is 204 with 0 bytes, exactly what our server sends. A void WEBHOOK stays a\n // `200` the partner returns — any 2xx acknowledges, and its body is ignored.\n const status = isRoute && this.body.isVoid(endpoint.response) ? '204' : '200';\n responses.set(status, this.success(endpoint, contractName, contract, isRoute));\n for (const error of contract.errors) {\n // A failure only an AUTHENTICATED operation can have (a 401) is not one a public\n // endpoint can return, so it is not documented there.\n if (error.requiresAuth && this.isPublic(endpoint)) {\n continue;\n }\n responses.set(error.status, this.failure(error.description, contract));\n }\n return responses;\n }\n\n private success(\n endpoint: DocumentedEndpoint,\n contractName: string,\n contract: ResponseContract,\n isRoute: boolean,\n ): JsonObject {\n const isVoid = this.body.isVoid(endpoint.response);\n const response = new JsonObject()\n .set('description', this.successDescription(endpoint, contractName, isVoid, isRoute))\n .set('headers', contract.headers);\n if (isVoid) {\n return response;\n }\n const pointer = `#/paths/${contractName}_${endpoint.methodName}/responses/200`;\n return response.set(\n 'content',\n new JsonObject().set(\n 'application/json',\n new JsonObject().set('schema', this.schemas.body(endpoint.response!, pointer)),\n ),\n );\n }\n\n private failure(description: string, contract: ResponseContract): JsonObject {\n const response = new JsonObject()\n .set('description', description)\n .set('headers', contract.headers);\n if (contract.errorSchemaRef === undefined) {\n return response;\n }\n return response.set(\n 'content',\n new JsonObject().set(\n 'application/json',\n new JsonObject().set('schema', contract.errorSchemaRef),\n ),\n );\n }\n\n /**\n * The method's `@returns` text (#1292). With none, a `void` operation gets a derived sentence —\n * there is no body for `@returns` to describe: \"no body\" for a served route (a 204), and the\n * acknowledgement sentence for a webhook the partner answers. A body-carrying\n * operation with none never gets here: {@link MissingReturnsGuard} refuses it before any document\n * renders, so there is no filler fallback to publish.\n */\n private successDescription(\n endpoint: DocumentedEndpoint,\n contractName: string,\n isVoid: boolean,\n isRoute: boolean,\n ): string {\n const returns = this.prose(endpoint.returnsDescription);\n if (returns !== undefined) {\n return returns;\n }\n if (!isVoid) {\n throw new OpenApiGenerationError(\n `${endpoint.methodName} has a response body but no @returns`,\n `${contractName}.${endpoint.methodName} (the contract method's JSDoc)`,\n 'Add a `@returns` line to its JSDoc. MissingReturnsGuard should have refused this ' +\n 'before rendering; reaching here is a generator defect.',\n );\n }\n return isRoute ? NO_CONTENT : ACKNOWLEDGE;\n }\n\n private prose(text: string | undefined): string | undefined {\n return text === undefined || text.trim() === '' ? undefined : text;\n }\n}\n"]}
1
+ {"version":3,"file":"OperationRenderer.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/OperationRenderer.ts"],"names":[],"mappings":";;;AAAA,4DAOkC;AAClC,oDAU8B;AAC9B,mDAA2D;AAG3D,+CAA4C;AAC5C,sEAAmE;AAEnE,mEAAmE;AACnE,MAAM,WAAW,GAAG,8DAA8D,CAAC;AAEnF;;;;;;GAMG;AACH,MAAM,UAAU,GAAG,oCAAoC,CAAC;AAExD,4FAA4F;AAC5F,MAAa,gBAAgB;IAGZ;IAEA;IAMA;IAVb;IACI,4DAA4D;IACnD,MAAqC;IAC9C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,QAAQ,CAAC,OAAO,CAAC,CAAC;QACtC,IAAI,QAAQ,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;YACxC,OAAO,QAAQ,CAAC;QACpB,CAAC;QACD,OAAO,QAAQ,CAAC,GAAG,CACf,SAAS,EACT,IAAI,uBAAU,EAAE,CAAC,GAAG,CAChB,kBAAkB,EAClB,IAAI,uBAAU,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,CAC1D,CACJ,CAAC;IACN,CAAC;IAED;;;;;;OAMG;IACK,kBAAkB,CACtB,QAA4B,EAC5B,YAAoB,EACpB,MAAe,EACf,OAAgB;QAEhB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;QACxD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,OAAO,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,+CAAsB,CAC5B,GAAG,QAAQ,CAAC,UAAU,sCAAsC,EAC5D,GAAG,YAAY,IAAI,QAAQ,CAAC,UAAU,gCAAgC,EACtE,mFAAmF;gBAC/E,wDAAwD,CAC/D,CAAC;QACN,CAAC;QACD,OAAO,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC;IAC9C,CAAC;IAEO,KAAK,CAAC,IAAwB;QAClC,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IACvE,CAAC;CACJ;AA1ZD,8CA0ZC","sourcesContent":["import {\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedMcpTool,\n DocumentedParameter,\n OperationIds,\n OperationIdStyle,\n} from '@webpieces/api-doc-model';\nimport {\n CLOUDTASKS,\n CRON,\n EXTERNAL_INBOUND,\n mcpHintsForOperation,\n READ,\n RPC,\n WRITE,\n WRITE_IDEMPOTENT,\n verbCarriesBody,\n} from '@webpieces/core-util';\nimport { JsonObject, JsonValue } from '../json/JsonObject';\nimport { ErrorResponseEntry } from '../manifest/OpenApiManifest';\nimport { SchemaRenderer } from './SchemaRenderer';\nimport { SuccessBody } from './SuccessBody';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\n\n/** What a webhook's `void` return means on the wire, said once. */\nconst ACKNOWLEDGE = 'Return any 2xx to acknowledge delivery. The body is ignored.';\n\n/**\n * What a served route's `void` return means on the wire: our server answers `204` with 0 bytes\n * (#1339) — whether `responseBody: NONE` declares it (RPC / EXTERNAL_INBOUND) or the CLOUDTASKS / CRON kind\n * implies it (#1348; the scan requires such a method to return `Promise<void>`, so it renders here\n * exactly like NONE). Only a WEBHOOK keeps {@link ACKNOWLEDGE} — there the PARTNER answers, and an\n * EXTERNAL_OUTBOUND contract is always published as one, so its void is never documented as a 204.\n */\nconst NO_CONTENT = 'Success. The response has no body.';\n\n/** The response document, and the responses a document-wide failure contract adds to it. */\nexport class ResponseContract {\n constructor(\n /** The manifest's `errors.responses`, in declared order. */\n readonly errors: readonly ErrorResponseEntry[],\n /** `$ref` at the error body schema, when the manifest declared one. */\n readonly errorSchemaRef: JsonObject | undefined,\n /**\n * Header name -> its `components.headers` `$ref`, on the success response AND on every\n * failure listed for the operation (#1270). The server stamps the header on every response,\n * and the failing one is the response a partner most needs to quote back.\n */\n readonly headers: JsonObject | undefined,\n ) {}\n}\n\n/**\n * ONE {@link DocumentedEndpoint} -> one OpenAPI Operation Object.\n *\n * ## `summary` is the method's `@summary` JSDoc tag — a short title, never a sentence (#1296)\n *\n * A docs theme titles the endpoint's page from `summary` and labels its sidebar with it, and puts\n * `description` in the body. It used to be the bare method name, which put code identifiers in every\n * heading. It is now the `@summary` line the author wrote — one line, at most 100 characters,\n * REQUIRED on every published operation by {@link SummaryGuard} — and the tag is not part of\n * `description`, so the page does not repeat its own heading. The code identifier stays published as\n * `operationId`, which is what a generated client names the method. The same line is the MCP tool's\n * `title`, so a partner's docs page and an agent's tool list name the endpoint identically.\n *\n * ## The MCP extensions ride HERE, on the operation\n *\n * `x-mcp-tools`, `x-mcp-hints`, `x-mcp-description` and `x-mcp-auth` are stamped on every operation\n * carrying the tool decorator, hidden or not: an internal endpoint that is an agent tool is a\n * legitimate agent tool, and requiring it to be published to partners in order to be one would be\n * exactly the wrong coupling.\n *\n * They are stamped on the BASE, which every published document is derived from, and\n * {@link DocumentDeriver} STRIPS them from the customer document. Stamping-then-stripping rather than\n * rendering the customer document without them is the same choice the whole deriver rests on: one\n * render of one operation, so two documents holding it cannot disagree about anything else in it.\n */\nexport class OperationRenderer {\n private readonly body = new SuccessBody();\n private readonly ids: OperationIds;\n\n constructor(\n private readonly schemas: SchemaRenderer,\n /** True only for the MCP document — see {@link withMcp}. */\n private readonly includeMcp: boolean,\n /** True only for the private document — see {@link triggerSentence}. */\n private readonly includeTrigger: boolean,\n /**\n * False only for the PUBLIC document (#1303): `x-webpieces-authentication` (whose `arguments`\n * are the TypeScript identifiers passed to `@WpAuth` — private names a partner cannot use) and\n * `x-webpieces-webhook` are internal tooling's. A partner's authentication is already in the\n * standard `components.securitySchemes` + `security`, and a webhook already sits in the\n * standard `webhooks:` block.\n */\n private readonly includeWebpieces: boolean,\n /** The manifest's `operationIds` — see {@link operationIdOf}. */\n operationIds: OperationIdStyle,\n ) {\n this.ids = new OperationIds(operationIds);\n }\n\n /**\n * The published `operationId`, in the manifest's chosen style (#1270).\n *\n * Public because the generator checks uniqueness with the SAME function before rendering: a\n * second spelling of the id there could pass a collision this one then publishes.\n */\n operationIdOf(endpoint: DocumentedEndpoint, contractName: string): string {\n return this.ids.of(contractName, endpoint.methodName);\n }\n\n /** An ordinary served route. */\n operation(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n security: readonly JsonValue[] | undefined,\n ): JsonObject {\n const operation = this.common(endpoint, contractName, tag, contract, true);\n // An endpoint that authenticates NOBODY says so explicitly: `security: []` is OpenAPI's\n // spelling of \"no credential required\", and leaving the key off instead means \"inherit the\n // document's\", which is a different statement that happens to coincide today.\n const explicit = this.isPublic(endpoint) ? [] : security;\n operation.set('security', explicit === undefined ? undefined : explicit.slice());\n return this.withMcp(operation, endpoint);\n }\n\n /**\n * A call WE make to a PARTNER's server.\n *\n * It carries `x-webpieces-webhook: true` in every document but the public one (#1303), where the\n * standard `webhooks:` block it sits in already says so. It gets no trigger sentence and no security at all, because neither is true of\n * it: nothing of ours triggers it and nothing of ours authenticates it — our api key must never\n * be published as a guard on somebody else's endpoint.\n *\n * It gets no retry sentence either (#1302). That sentence tells a CALLER whether it may repeat\n * the call, and the partner never calls a webhook — WE do, and we retry delivery ourselves. The\n * `@Endpoint` operation on a webhook method is an inert value the decorator requires (the\n * contract is never mounted as a route), so on a webhook \"NOT safe to retry\" would be backwards:\n * the receiver's concern is that one event can arrive more than once.\n */\n webhook(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n ): JsonObject {\n const operation = this.common(endpoint, contractName, tag, contract, false);\n return this.withMcp(\n operation.set('x-webpieces-webhook', this.includeWebpieces ? true : undefined),\n endpoint,\n );\n }\n\n private common(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n isRoute: boolean,\n ): JsonObject {\n return new JsonObject()\n .set('operationId', this.operationIdOf(endpoint, contractName))\n .set('x-webpieces-authentication', this.authentication(endpoint))\n .set('summary', endpoint.summary)\n .set('description', this.describe(endpoint, isRoute))\n .set('tags', [tag])\n .set('parameters', this.parameters(endpoint, contractName))\n .set('requestBody', this.requestBody(endpoint, contractName))\n .set('responses', this.responses(endpoint, contractName, contract, isRoute));\n }\n\n /** The declared `@WpAuth` methods, verbatim — never in the public document (#1303). */\n private authentication(endpoint: DocumentedEndpoint): readonly JsonValue[] | undefined {\n if (!this.includeWebpieces) {\n return undefined;\n }\n return endpoint.auth?.methods.map((method: DocumentedAuthMethod) =>\n new JsonObject().set('kind', method.kind).set('arguments', method.argumentTexts),\n );\n }\n\n /**\n * The JSDoc body, plus the sentences that are DERIVED rather than written.\n *\n * The retry sentence comes from the endpoint's declared `operation`, which every integration\n * wants to know and most APIs state nowhere. It is a SENTENCE and not a vendor extension because\n * Swagger UI and most themes do not render `x-` extensions and no standard generator reads\n * `x-webpieces-*`: an extension would be invisible to the human and unread by the machine. The\n * mapping it is derived from is published once, in `info.description`, so the rule is stated and\n * not only its consequences. It is stated on ROUTES only — a webhook is a call we make, so the\n * caller-facing retry sentence does not apply to it (see {@link webhook}).\n */\n private describe(endpoint: DocumentedEndpoint, isRoute: boolean): string | undefined {\n const parts: string[] = [];\n const body = this.prose(endpoint.description);\n if (body !== undefined) {\n parts.push(body);\n }\n // Both derived sentences are about a call the READER makes to us (may I repeat it? what\n // fires it?). A webhook is a call WE make to the reader, so neither applies (#1302).\n if (isRoute) {\n parts.push(this.retrySentence(endpoint));\n if (this.includeTrigger) {\n parts.push(this.triggerSentence(endpoint));\n }\n }\n if (endpoint.additive) {\n parts.push(\n 'Additive: it only adds new state; it does not delete, replace or irreversibly ' +\n 'change anything that already exists.',\n );\n }\n if (endpoint.openWorld) {\n parts.push(\n 'Reaches beyond this service: it may act on an external system, so its effects ' +\n 'are not all visible here.',\n );\n }\n return parts.length === 0 ? undefined : parts.join('\\n\\n');\n }\n\n /**\n * WHAT FIRES this endpoint, in the private document only.\n *\n * A customer calls what they are given a url for; whether ours runs off a queue or a clock is our\n * business and would only invite a question they cannot act on. It is a SENTENCE and not\n * `x-webpieces-trigger` for the same reason the retry sentence is: Swagger UI and most themes do\n * not render `x-` extensions, and no standard generator reads `x-webpieces-*`, so an extension is\n * invisible to the human and unread by the machine.\n */\n private triggerSentence(endpoint: DocumentedEndpoint): string {\n if (endpoint.kind === CLOUDTASKS) {\n return 'Triggered by a queued task, delivered asynchronously.';\n }\n if (endpoint.kind === CRON) {\n return 'Triggered on a schedule, not by a caller.';\n }\n if (endpoint.kind === EXTERNAL_INBOUND) {\n const caller = endpoint.options.calledBy;\n return caller === undefined\n ? 'Triggered by an outside system.'\n : `Triggered by an outside system: ${caller}.`;\n }\n return endpoint.kind === RPC\n ? 'Triggered by a direct call.'\n : `Triggered by: ${endpoint.kind}.`;\n }\n\n /** An endpoint whose declared credential is \"none\", said out loud rather than left absent. */\n private isPublic(endpoint: DocumentedEndpoint): boolean {\n return endpoint.auth?.publicReason !== undefined;\n }\n\n private retrySentence(endpoint: DocumentedEndpoint): string {\n if (endpoint.operation === READ) {\n return 'Safe to retry: this operation is read-only and idempotent.';\n }\n if (endpoint.operation === WRITE_IDEMPOTENT) {\n return 'Safe to retry: this operation changes state but is idempotent.';\n }\n return 'NOT safe to retry: this operation changes state and is not idempotent.';\n }\n\n /**\n * The MCP extensions, stamped only on the document that has an agent for a reader.\n *\n * ## The three side-effect hints are COMPUTED, never declared\n *\n * `mcpHintsForOperation` in `@webpieces/core-util` is the one place the mapping from\n * `READ | WRITE_IDEMPOTENT | WRITE` to `readOnlyHint` / `destructiveHint` / `idempotentHint`\n * lives, and this calls it rather than reimplementing it. The endpoint's `operation` already\n * states whether repeating the call is safe; a hand-declared hint would be a second answer to a\n * question the contract has answered, and the two could disagree. `openWorldHint` is the only one\n * a human declares, because it is a judgement about the world rather than a consequence of the\n * operation. The one refinement is `@Endpoint`'s `additive` option, which a write states when it\n * only ever adds: it lowers `destructiveHint` to false, still through `mcpHintsForOperation` (#1422).\n *\n * ## The title is the operation's `summary`, published as the Tool's `title` AND `annotations.title`\n *\n * `x-mcp-title` and `x-mcp-hints.title` carry the `@summary` line exactly as `tools/list` serves it:\n * `Tool.title` for clients on the 2025-06-18+ spec and `annotations.title` (the block `x-mcp-hints`\n * mirrors) for older clients and the Claude Connectors Directory (#1296). One source, so they cannot\n * differ from the operation's own `summary`.\n *\n * ## There is no separate MCP description\n *\n * The agent reads the operation's `description` — the method's JSDoc — byte-identical to what the\n * partner reads. `x-mcp-description` appears ONLY when the author wrote an explicit `@mcp` JSDoc\n * tag, which is a deliberate act rather than a second copy of the same paragraph.\n */\n private withMcp(operation: JsonObject, endpoint: DocumentedEndpoint): JsonObject {\n if (!this.includeMcp || endpoint.mcpTools.length === 0) {\n return operation;\n }\n const hints = mcpHintsForOperation(\n this.operationOf(endpoint),\n endpoint.openWorld,\n endpoint.additive,\n );\n return operation\n .set(\n 'x-mcp-tools',\n endpoint.mcpTools.map((tool: DocumentedMcpTool) =>\n new JsonObject().set('name', tool.name).set('profiles', tool.profiles),\n ),\n )\n .set('x-mcp-title', endpoint.summary)\n .set(\n 'x-mcp-hints',\n new JsonObject()\n .set('title', endpoint.summary)\n .set('readOnlyHint', hints.readOnlyHint)\n .set('destructiveHint', hints.destructiveHint)\n .set('idempotentHint', hints.idempotentHint)\n .set('openWorldHint', hints.openWorldHint),\n )\n .set('x-mcp-description', this.prose(endpoint.mcpDescription))\n .set('x-webpieces-authorization', endpoint.authorizationText);\n }\n\n /**\n * The endpoint's operation as the REAL exported constant.\n *\n * The model carries it as a string, verbatim from the source, because the model invents no\n * taxonomy. Matching it back to the constant here — rather than casting — is what makes a rename\n * of `WRITE_IDEMPOTENT` in `core-util` a compile error in this file.\n */\n private operationOf(\n endpoint: DocumentedEndpoint,\n ): typeof READ | typeof WRITE_IDEMPOTENT | typeof WRITE {\n if (endpoint.operation === READ) {\n return READ;\n }\n return endpoint.operation === WRITE_IDEMPOTENT ? WRITE_IDEMPOTENT : WRITE;\n }\n\n /**\n * Every `@PathParam` / `@QueryParam` argument as an OpenAPI Parameter Object, in declaration order.\n * A list query argument is `style: form, explode: true` — repeated keys (`a=1&a=2`), which is what\n * the webpieces client sends. Absent (not `[]`) when the endpoint binds nothing to the URL, so a\n * contract with no URL parameters renders byte-identically to before.\n */\n private parameters(\n endpoint: DocumentedEndpoint,\n contractName: string,\n ): readonly JsonValue[] | undefined {\n if (endpoint.parameters.length === 0) {\n return undefined;\n }\n return endpoint.parameters.map((parameter: DocumentedParameter, index: number) => {\n const pointer = `#/paths/${contractName}_${endpoint.methodName}/parameters/${index}`;\n const schema =\n parameter.type === undefined\n ? new JsonObject().set('type', 'string')\n : this.schemas.type(parameter.type, pointer);\n const isList = parameter.type?.kind === 'array';\n return new JsonObject()\n .set('name', parameter.name)\n .set('in', parameter.location)\n .set('required', parameter.required)\n .set('style', isList ? 'form' : undefined)\n .set('explode', isList ? true : undefined)\n .set('schema', schema);\n });\n }\n\n /**\n * The request DTO as a body. Only for a verb that carries one (`verbCarriesBody`: POST, PUT,\n * PATCH): OpenAPI gives a `GET`/`DELETE` body no defined semantics and most tooling drops it, so\n * publishing one would document a request no generated client sends.\n */\n private requestBody(\n endpoint: DocumentedEndpoint,\n contractName: string,\n ): JsonObject | undefined {\n if (!verbCarriesBody(endpoint.httpMethod) || endpoint.request === undefined) {\n return undefined;\n }\n const pointer = `#/paths/${contractName}_${endpoint.methodName}/requestBody`;\n const media = endpoint.options.formPost\n ? 'application/x-www-form-urlencoded'\n : 'application/json';\n return new JsonObject()\n .set('required', true)\n .set(\n 'content',\n new JsonObject().set(\n media,\n new JsonObject().set('schema', this.schemas.body(endpoint.request, pointer)),\n ),\n );\n }\n\n private responses(\n endpoint: DocumentedEndpoint,\n contractName: string,\n contract: ResponseContract,\n isRoute: boolean,\n ): JsonObject {\n const responses = new JsonObject();\n // A void ROUTE is 204 with 0 bytes, exactly what our server sends. A void WEBHOOK stays a\n // `200` the partner returns — any 2xx acknowledges, and its body is ignored.\n const status = isRoute && this.body.isVoid(endpoint.response) ? '204' : '200';\n responses.set(status, this.success(endpoint, contractName, contract, isRoute));\n for (const error of contract.errors) {\n // A failure only an AUTHENTICATED operation can have (a 401) is not one a public\n // endpoint can return, so it is not documented there.\n if (error.requiresAuth && this.isPublic(endpoint)) {\n continue;\n }\n responses.set(error.status, this.failure(error.description, contract));\n }\n return responses;\n }\n\n private success(\n endpoint: DocumentedEndpoint,\n contractName: string,\n contract: ResponseContract,\n isRoute: boolean,\n ): JsonObject {\n const isVoid = this.body.isVoid(endpoint.response);\n const response = new JsonObject()\n .set('description', this.successDescription(endpoint, contractName, isVoid, isRoute))\n .set('headers', contract.headers);\n if (isVoid) {\n return response;\n }\n const pointer = `#/paths/${contractName}_${endpoint.methodName}/responses/200`;\n return response.set(\n 'content',\n new JsonObject().set(\n 'application/json',\n new JsonObject().set('schema', this.schemas.body(endpoint.response!, pointer)),\n ),\n );\n }\n\n private failure(description: string, contract: ResponseContract): JsonObject {\n const response = new JsonObject()\n .set('description', description)\n .set('headers', contract.headers);\n if (contract.errorSchemaRef === undefined) {\n return response;\n }\n return response.set(\n 'content',\n new JsonObject().set(\n 'application/json',\n new JsonObject().set('schema', contract.errorSchemaRef),\n ),\n );\n }\n\n /**\n * The method's `@returns` text (#1292). With none, a `void` operation gets a derived sentence —\n * there is no body for `@returns` to describe: \"no body\" for a served route (a 204), and the\n * acknowledgement sentence for a webhook the partner answers. A body-carrying\n * operation with none never gets here: {@link MissingReturnsGuard} refuses it before any document\n * renders, so there is no filler fallback to publish.\n */\n private successDescription(\n endpoint: DocumentedEndpoint,\n contractName: string,\n isVoid: boolean,\n isRoute: boolean,\n ): string {\n const returns = this.prose(endpoint.returnsDescription);\n if (returns !== undefined) {\n return returns;\n }\n if (!isVoid) {\n throw new OpenApiGenerationError(\n `${endpoint.methodName} has a response body but no @returns`,\n `${contractName}.${endpoint.methodName} (the contract method's JSDoc)`,\n 'Add a `@returns` line to its JSDoc. MissingReturnsGuard should have refused this ' +\n 'before rendering; reaching here is a generator defect.',\n );\n }\n return isRoute ? NO_CONTENT : ACKNOWLEDGE;\n }\n\n private prose(text: string | undefined): string | undefined {\n return text === undefined || text.trim() === '' ? undefined : text;\n }\n}\n"]}