@webpieces/openapi-generator 0.4.962 → 0.4.964

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.962",
3
+ "version": "0.4.964",
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.962",
27
- "@webpieces/core-util": "0.4.962",
26
+ "@webpieces/api-doc-model": "0.4.964",
27
+ "@webpieces/core-util": "0.4.964",
28
28
  "typescript": "5.9.3"
29
29
  },
30
30
  "bin": {
@@ -9,8 +9,11 @@ const OpenApiGenerationError_1 = require("../OpenApiGenerationError");
9
9
  /** What a webhook's `void` return means on the wire, said once. */
10
10
  const ACKNOWLEDGE = 'Return any 2xx to acknowledge delivery. The body is ignored.';
11
11
  /**
12
- * What a served route's `void` return (`responseBody: NONE`) means on the wire: our server answers
13
- * `204` with 0 bytes (#1339). Only a WEBHOOK keeps {@link ACKNOWLEDGE} — there the PARTNER answers.
12
+ * What a served route's `void` return means on the wire: our server answers `204` with 0 bytes
13
+ * (#1339) — whether `responseBody: NONE` declares it (RPC / EXTERNAL_INBOUND) or the CLOUDTASKS / CRON kind
14
+ * implies it (#1348; the scan requires such a method to return `Promise<void>`, so it renders here
15
+ * exactly like NONE). Only a WEBHOOK keeps {@link ACKNOWLEDGE} — there the PARTNER answers, and an
16
+ * EXTERNAL_OUTBOUND contract is always published as one, so its void is never documented as a 204.
14
17
  */
15
18
  const NO_CONTENT = 'Success. The response has no body.';
16
19
  /** The response document, and the responses a document-wide failure contract adds to it. */
@@ -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;;;GAGG;AACH,MAAM,UAAU,GAAG,oCAAoC,CAAC;AAExD,4FAA4F;AAC5F,MAAa,gBAAgB;IAGZ;IAEA;IAMA;IAVb;IACI,4DAA4D;IACnD,MAAqC;IAC9C,uEAAuE;IAC9D,cAAsC;IAC/C;;;;OAIG;IACM,OAA+B;QAR/B,WAAM,GAAN,MAAM,CAA+B;QAErC,mBAAc,GAAd,cAAc,CAAwB;QAMtC,YAAO,GAAP,OAAO,CAAwB;IACzC,CAAC;CACP;AAbD,4CAaC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,iBAAiB;IAKL;IAEA;IAEA;IAQA;IAhBJ,IAAI,GAAG,IAAI,yBAAW,EAAE,CAAC;IACzB,GAAG,CAAe;IAEnC,YACqB,OAAuB;IACxC,4DAA4D;IAC3C,UAAmB;IACpC,wEAAwE;IACvD,cAAuB;IACxC;;;;;;OAMG;IACc,gBAAyB;IAC1C,iEAAiE;IACjE,YAA8B;QAdb,YAAO,GAAP,OAAO,CAAgB;QAEvB,eAAU,GAAV,UAAU,CAAS;QAEnB,mBAAc,GAAd,cAAc,CAAS;QAQvB,qBAAgB,GAAhB,gBAAgB,CAAS;QAI1C,IAAI,CAAC,GAAG,GAAG,IAAI,4BAAY,CAAC,YAAY,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,QAA4B,EAAE,YAAoB;QAC5D,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC1D,CAAC;IAED,gCAAgC;IAChC,SAAS,CACL,QAA4B,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GAAG,CAAC,SAAS,EAAE,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;AA1YD,8CA0YC","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 (`responseBody: NONE`) means on the wire: our server answers\n * `204` with 0 bytes (#1339). Only a WEBHOOK keeps {@link ACKNOWLEDGE} — there the PARTNER answers.\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.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.\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(this.operationOf(endpoint), endpoint.openWorld);\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,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,MAAa,gBAAgB;IAGZ;IAEA;IAMA;IAVb;IACI,4DAA4D;IACnD,MAAqC;IAC9C,uEAAuE;IAC9D,cAAsC;IAC/C;;;;OAIG;IACM,OAA+B;QAR/B,WAAM,GAAN,MAAM,CAA+B;QAErC,mBAAc,GAAd,cAAc,CAAwB;QAMtC,YAAO,GAAP,OAAO,CAAwB;IACzC,CAAC;CACP;AAbD,4CAaC;AAED;;;;;;;;;;;;;;;;;;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,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;AA1YD,8CA0YC","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.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.\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(this.operationOf(endpoint), endpoint.openWorld);\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"]}