@webpieces/openapi-generator 0.4.934 → 0.4.935

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/README.md CHANGED
@@ -55,6 +55,7 @@ It carries exactly what is **not a property of the code**:
55
55
  ```json
56
56
  {
57
57
  "title": "Example Orders API",
58
+ "summary": "Read and cancel the orders placed at your stores.",
58
59
  "version": "1.0.0",
59
60
  "descriptionFile": "description.md",
60
61
  "servers": [{ "url": "https://api.example.com", "description": "Production." }],
@@ -84,6 +85,13 @@ It carries exactly what is **not a property of the code**:
84
85
 
85
86
  Every path is relative to the manifest's own directory.
86
87
 
88
+ The API itself has the same three forms an operation has (#1296): `title` is `info.title`, the
89
+ REQUIRED `summary` — one line, at most 200 characters, the Claude Connectors Directory's one-liner
90
+ limit, so the same text can be pasted there — is OpenAPI 3.1's `info.summary`, and `descriptionFile`
91
+ is `info.description`. A manifest with no `summary`, an empty one, a second line or more than 200
92
+ characters is refused, naming the key. A `"kind": "components"` manifest takes no `summary`: a DTO
93
+ library's document is not an API anybody lists.
94
+
87
95
  ### Source suffixes and published schema names
88
96
 
89
97
  An optional `schemaNames` list controls published type names independently of source
@@ -222,9 +230,13 @@ does not declare `MCP` is an error. Membership has one spelling.
222
230
 
223
231
  The agent reads the SAME `description` a human does — the method's JSDoc, byte for byte. Two authored
224
232
  copies of one paragraph drift the first time somebody edits one, so
225
- `@WpMcpTool('search_stores', 'Search stores')` carries only what JSDoc cannot say: the stable protocol
226
- name and the REQUIRED human-readable title, which each catalog entry carries as `title` and `tools/list`
227
- publishes as `title` and `annotations.title` (#1180). `readOnlyHint`, `destructiveHint` and
233
+ `@WpMcpTool('search_stores')` carries only what JSDoc cannot say: the stable protocol name — 1-64
234
+ characters of `[A-Za-z0-9_-]`, refused at generation otherwise, every offender named in one run, because
235
+ the Claude Connectors Directory refuses a longer one (#1296). The title is the method's `@summary`
236
+ (below): each catalog entry carries it as `title`, `tools/list` publishes it as `title` AND
237
+ `annotations.title` (#1180), and `mcp-openapi.json` stamps it as `x-mcp-title` and `x-mcp-hints.title`
238
+ beside the operation's own `summary`. The decorator's former title argument is gone; passing one is a
239
+ compile error. `readOnlyHint`, `destructiveHint` and
228
240
  `idempotentHint` are computed from the endpoint's declared `operation`; `openWorldHint` comes from
229
241
  `{ openWorld: true }` on the endpoint.
230
242
 
@@ -246,6 +258,7 @@ file. `--format` does not apply to them.
246
258
  | JSDoc on | Published as |
247
259
  |---|---|
248
260
  | a method | `operation.description` (and the MCP tool's `description`, unless an `@mcp` tag overrides it) |
261
+ | its `@summary` tag | `operation.summary` — the docs page heading and sidebar label — and the MCP tool's `title` and `annotations.title` (#1296) |
249
262
  | its `@returns` tag | the success response's `description`, and the MCP catalog's `outputSchema.description` |
250
263
  | a DTO class / interface / enum / union alias | `components.schemas.<Name>.description` (and the MCP catalog's `inputSchema.description` for the request DTO) |
251
264
  | a field | the property's `description` |
@@ -256,6 +269,12 @@ and the `mcp-<Contract>-tools.json` catalogs — and each refusal names every of
256
269
  writes nothing. None has an off switch.
257
270
 
258
271
  - **`@privateRemarks` is dropped** with its text, everywhere. Write internal notes there.
272
+ - **`@summary` is REQUIRED** on every published operation, route and webhook alike (#1296): one line,
273
+ at most 100 characters. It is the endpoint's short title — the OpenAPI `summary` (which used to be
274
+ the bare method name) and the MCP tool's `title` / `annotations.title` — and the tag and its text are
275
+ NOT part of `description`, which is the rest of the JSDoc body. A missing, multi-line or over-long
276
+ summary is refused, naming every method and file in one run. The code identifier stays published
277
+ as `operationId`.
259
278
  - **`@returns` is REQUIRED** on every published method whose response has a body. It replaces the
260
279
  hard-coded `"Success."` the success response used to carry. A `Promise<void>` method needs none and
261
280
  keeps the derived acknowledgement sentence. Error responses keep the manifest's descriptions.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/openapi-generator",
3
- "version": "0.4.934",
3
+ "version": "0.4.935",
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.934",
27
- "@webpieces/core-util": "0.4.934",
26
+ "@webpieces/api-doc-model": "0.4.935",
27
+ "@webpieces/core-util": "0.4.935",
28
28
  "typescript": "5.9.3"
29
29
  },
30
30
  "bin": {
@@ -0,0 +1,19 @@
1
+ import { ContractModel } from './GenerationInputs';
2
+ /**
3
+ * The refusal for an MCP tool whose stable protocol name the Claude Connectors Directory would refuse
4
+ * (#1296): longer than {@link McpToolName.MAX_LENGTH} characters, or using a character outside
5
+ * `[A-Za-z0-9_-]`.
6
+ *
7
+ * MCP itself allows up to 128 characters and a dot, but a server with even one longer name cannot be
8
+ * listed in the Directory, and a tool name is the protocol identity agents save — renaming it later
9
+ * breaks them. So it is refused at generation, where the author can still pick the final name, and
10
+ * every offender of the run is named at once, before anything is rendered. The rule itself is
11
+ * {@link McpToolName}, the one `@WpMcpTool`, the catalog codec and `api-rules-for-mcp` also apply.
12
+ *
13
+ * It judges every `@WpMcpTool` of every contract the MCP output selects — exactly the tools
14
+ * `mcp-openapi.json` and the `mcp-<Contract>-tools.json` catalogs would publish.
15
+ */
16
+ export declare class McpToolNameGuard {
17
+ /** Refuse when any MCP tool of `contracts` has an illegal name. */
18
+ refuse(contracts: readonly ContractModel[], manifestPath: string): void;
19
+ }
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.McpToolNameGuard = void 0;
4
+ const core_util_1 = require("@webpieces/core-util");
5
+ const OpenApiGenerationError_1 = require("../OpenApiGenerationError");
6
+ const DocumentSelection_1 = require("./DocumentSelection");
7
+ /**
8
+ * The refusal for an MCP tool whose stable protocol name the Claude Connectors Directory would refuse
9
+ * (#1296): longer than {@link McpToolName.MAX_LENGTH} characters, or using a character outside
10
+ * `[A-Za-z0-9_-]`.
11
+ *
12
+ * MCP itself allows up to 128 characters and a dot, but a server with even one longer name cannot be
13
+ * listed in the Directory, and a tool name is the protocol identity agents save — renaming it later
14
+ * breaks them. So it is refused at generation, where the author can still pick the final name, and
15
+ * every offender of the run is named at once, before anything is rendered. The rule itself is
16
+ * {@link McpToolName}, the one `@WpMcpTool`, the catalog codec and `api-rules-for-mcp` also apply.
17
+ *
18
+ * It judges every `@WpMcpTool` of every contract the MCP output selects — exactly the tools
19
+ * `mcp-openapi.json` and the `mcp-<Contract>-tools.json` catalogs would publish.
20
+ */
21
+ class McpToolNameGuard {
22
+ /** Refuse when any MCP tool of `contracts` has an illegal name. */
23
+ refuse(contracts, manifestPath) {
24
+ const selection = DocumentSelection_1.DocumentSelection.mcp();
25
+ const offenders = [];
26
+ for (const contract of contracts) {
27
+ if (!selection.acceptsContract(contract.model)) {
28
+ continue;
29
+ }
30
+ for (const endpoint of contract.model.endpoints) {
31
+ const tool = endpoint.mcpTool;
32
+ if (tool === undefined || !selection.acceptsEndpoint(endpoint)) {
33
+ continue;
34
+ }
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
+ }
40
+ }
41
+ }
42
+ if (offenders.length === 0) {
43
+ return;
44
+ }
45
+ throw new OpenApiGenerationError_1.OpenApiGenerationError(`${offenders.length} MCP tool name(s) would be refused by the Claude Connectors Directory`, manifestPath, core_util_1.McpToolName.cure(), offenders);
46
+ }
47
+ }
48
+ exports.McpToolNameGuard = McpToolNameGuard;
49
+ //# sourceMappingURL=McpToolNameGuard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"McpToolNameGuard.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/McpToolNameGuard.ts"],"names":[],"mappings":";;;AAAA,oDAAmD;A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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"]}
@@ -33,12 +33,15 @@ import { ComponentsInputs, GeneratedDocument, GeneratedDocuments, GenerationInpu
33
33
  * {@link StackedJsDocGuard} (#1286). And, in every document including the MCP projection and its tool
34
34
  * catalogs, an operation with a body but no `@returns` ({@link MissingReturnsGuard}) and a published
35
35
  * schema with no JSDoc description ({@link UndocumentedSchemaGuard}) — each naming every offender in
36
- * one run (#1292).
36
+ * one run (#1292). Likewise an operation with no valid `@summary` ({@link SummaryGuard}) and an MCP
37
+ * tool whose name the Claude Connectors Directory would refuse ({@link McpToolNameGuard}) (#1296).
37
38
  */
38
39
  export declare class OpenApiGenerator {
39
40
  private readonly security;
40
41
  private readonly stackedJsDoc;
41
42
  private readonly missingReturns;
43
+ private readonly summaries;
44
+ private readonly toolNames;
42
45
  private readonly tagOwnership;
43
46
  /**
44
47
  * ONE document per `@ApiType` some contract declares, and no others.
@@ -10,7 +10,9 @@ const OperationRenderer_1 = require("./OperationRenderer");
10
10
  const SchemaPlacement_1 = require("./SchemaPlacement");
11
11
  const SchemaRenderer_1 = require("./SchemaRenderer");
12
12
  const SecurityDeriver_1 = require("./SecurityDeriver");
13
+ const McpToolNameGuard_1 = require("./McpToolNameGuard");
13
14
  const MissingReturnsGuard_1 = require("./MissingReturnsGuard");
15
+ const SummaryGuard_1 = require("./SummaryGuard");
14
16
  const StackedJsDocGuard_1 = require("./StackedJsDocGuard");
15
17
  const TagOwnership_1 = require("./TagOwnership");
16
18
  const UndocumentedSchemaGuard_1 = require("./UndocumentedSchemaGuard");
@@ -76,12 +78,15 @@ const OPENAPI_VERSION = '3.1.0';
76
78
  * {@link StackedJsDocGuard} (#1286). And, in every document including the MCP projection and its tool
77
79
  * catalogs, an operation with a body but no `@returns` ({@link MissingReturnsGuard}) and a published
78
80
  * schema with no JSDoc description ({@link UndocumentedSchemaGuard}) — each naming every offender in
79
- * one run (#1292).
81
+ * one run (#1292). Likewise an operation with no valid `@summary` ({@link SummaryGuard}) and an MCP
82
+ * tool whose name the Claude Connectors Directory would refuse ({@link McpToolNameGuard}) (#1296).
80
83
  */
81
84
  class OpenApiGenerator {
82
85
  security = new SecurityDeriver_1.SecurityDeriver();
83
86
  stackedJsDoc = new StackedJsDocGuard_1.StackedJsDocGuard();
84
87
  missingReturns = new MissingReturnsGuard_1.MissingReturnsGuard();
88
+ summaries = new SummaryGuard_1.SummaryGuard();
89
+ toolNames = new McpToolNameGuard_1.McpToolNameGuard();
85
90
  tagOwnership = new TagOwnership_1.TagOwnership();
86
91
  /**
87
92
  * ONE document per `@ApiType` some contract declares, and no others.
@@ -99,6 +104,8 @@ class OpenApiGenerator {
99
104
  models.push(inputs.errorType);
100
105
  }
101
106
  this.stackedJsDoc.refuse(models.flatMap((model) => model.stackedJsDoc), inputs.manifestPath);
107
+ this.summaries.refuse(inputs.contracts, inputs.manifestPath);
108
+ this.toolNames.refuse(inputs.contracts, inputs.manifestPath);
102
109
  this.missingReturns.refuse(inputs.contracts, inputs.manifestPath);
103
110
  this.tagOwnership.refuseSharedOwners(inputs.contracts, inputs.manifestPath);
104
111
  // Collected across EVERY OpenAPI document of the run and refused once, after them all, so an
@@ -453,6 +460,7 @@ class OpenApiGenerator {
453
460
  info(inputs, selection) {
454
461
  return new JsonObject_1.JsonObject()
455
462
  .set('title', inputs.manifest.title)
463
+ .set('summary', inputs.manifest.summary)
456
464
  .set('version', inputs.manifest.version)
457
465
  .set('description', selection.description(inputs.description));
458
466
  }
@@ -1 +1 @@
1
- {"version":3,"file":"OpenApiGenerator.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/OpenApiGenerator.ts"],"names":[],"mappings":";;;AAAA,4DASkC;AAClC,mDAA2D;AAC3D,sEAAmE;AAEnE,yDAM4B;AAC5B,2DAAwD;AACxD,2DAA0E;AAC1E,uDAO2B;AAC3B,qDAAiE;AACjE,uDAAoD;AACpD,+DAA4D;AAC5D,2DAAwD;AACxD,iDAA8C;AAC9C,uEAAoE;AAGpE,uGAAuG;AACvG,MAAM,gBAAgB;IAEL;IACA;IAFb,YACa,QAAoB,EACpB,OAAuB;QADvB,aAAQ,GAAR,QAAQ,CAAY;QACpB,YAAO,GAAP,OAAO,CAAgB;IACjC,CAAC;CACP;AAED,8FAA8F;AAC9F,MAAM,cAAc,GAAG,U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CAAC,MAAwB;QACvC,MAAM,IAAI,GAAG,IAAI,uBAAU,EAAE,CAAC;QAC9B,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;YAC1C,IAAI,CAAC,GAAG,CACJ,MAAM,CAAC,UAAU,EACjB,IAAI,uBAAU,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,wBAAwB,MAAM,CAAC,UAAU,EAAE,CAAC,CAC5E,CAAC;QACN,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACK,cAAc,CAClB,QAAkC,EAClC,QAAgB,EAChB,YAAoB;QAEpB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO;QACX,CAAC;QACD,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CACzB,CAAC,KAAoB,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,QAAQ,GAAG,CACnE,CAAC;QACF,MAAM,IAAI,+CAAsB,CAC5B,GAAG,QAAQ,CAAC,MAAM,gBAAgB,QAAQ,8BAA8B,EACxE,YAAY,EACZ,8EAA8E;YAC1E,uFAAuF,EAC3F,QAAQ,CACX,CAAC;IACN,CAAC;CACJ;AAzqBD,4CAyqBC","sourcesContent":["import {\n ApiDocModel,\n DocumentedApiKey,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedField,\n DocumentedType,\n TypeNameCollision,\n TypeRef,\n} from '@webpieces/api-doc-model';\nimport { JsonObject, JsonValue } from '../json/JsonObject';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\nimport { ErrorResponseEntry, ServerEntry } from '../manifest/OpenApiManifest';\nimport {\n ComponentsInputs,\n ContractModel,\n GeneratedDocument,\n GeneratedDocuments,\n GenerationInputs,\n} from './GenerationInputs';\nimport { DocumentSelection } from './DocumentSelection';\nimport { OperationRenderer, ResponseContract } from './OperationRenderer';\nimport {\n BundledNames,\n BundledPlacement,\n ComponentsReference,\n DiscoveryPlacement,\n SchemaPlacement,\n SplitPlacement,\n} from './SchemaPlacement';\nimport { SchemaRenderer, UnmappedField } from './SchemaRenderer';\nimport { SecurityDeriver } from './SecurityDeriver';\nimport { MissingReturnsGuard } from './MissingReturnsGuard';\nimport { StackedJsDocGuard } from './StackedJsDocGuard';\nimport { TagOwnership } from './TagOwnership';\nimport { UndocumentedSchemaGuard } from './UndocumentedSchemaGuard';\nimport { UpstreamComponentsIndex } from './UpstreamComponents';\n\n/** One rendered document, and the renderer that built its schemas — what it defined and referenced. */\nclass RenderedDocument {\n constructor(\n readonly document: JsonObject,\n readonly schemas: SchemaRenderer,\n ) {}\n}\n\n/** The suffix of a split document's self-contained sibling: `public-openapi.bundled.json`. */\nconst BUNDLED_SUFFIX = '.bundled';\n\n/** The document a DTO library publishes, without its extension (#1058). */\nconst COMPONENTS_DOCUMENT = 'components.openapi';\n\n/**\n * Every cure for a type reached in a package that publishes no components document.\n *\n * Tagging is offered ONLY for a package that is already a role:api-lib DTO library (#1064, D5): a\n * general library such as `company-core` is refused the tag by validate-nx-wiring and by the\n * openapi-components-generate executor, so \"tag the package\" is never a way out of moving the type.\n */\nconst PUBLISH_COMPONENTS_CURE =\n 'Move each type into a role:api-lib DTO library that publishes a components document — as a ' +\n '`…Dto` string enum when it is a string-literal union. Only when the declaring package is ITSELF a ' +\n 'role:api-lib DTO library, tag it \"generate:openapi-components\" so it publishes one (with a ' +\n '\"kind\": \"components\" openapi.manifest.json naming its entry files; outside nx, render that manifest ' +\n 'with wp-openapi into the directory the package is packed from); a general library is refused the ' +\n \"tag. A document references another package's schema; it never copies one in.\";\n\n/** The OpenAPI version this generator writes. See the class doc for why 3.1 and not 3.0. */\nconst OPENAPI_VERSION = '3.1.0';\n\n/**\n * {@link GenerationInputs} -> one OpenAPI 3.1.0 document per `@ApiType` some contract declares.\n *\n * ## 3.1, because it is what the model can state HONESTLY\n *\n * `type: [T, \"null\"]` instead of a `nullable` keyword; a `description` legal beside a `$ref`; a\n * top-level `webhooks:` block. Each of those is a fact the model holds that 3.0 would have forced\n * this renderer to drop or to lie about. 3.1's schema dialect is also JSON Schema 2020-12, which is\n * what MCP `tools/list` speaks.\n *\n * ## ONE render function, called once per document\n *\n * ```\n * ApiDocModel --> render(selection) --+--> full-private-openapi.json SVC_TO_SVC contracts\n * +--> public-openapi.json EXTERNAL_CUSTOMER contracts, minus hidden methods\n * +--> mcp-openapi.json MCP contracts\n * ```\n *\n * `components.schemas` is built by walking OUTWARD from the operations the selection accepted, so an\n * unselected operation's DTOs are never constructed. See {@link DocumentSelection} for why that\n * asymmetry — a bug emits nothing, rather than shipping an unreleased feature's schemas with only\n * its URL removed — decides the whole design.\n *\n * ## It REFUSES to write an unmapped field\n *\n * An unmapped type renders as an empty schema, which in JSON Schema means \"anything\". Publishing one\n * is a green build handing a partner a field with no shape, so the guard names the JSON pointer of\n * every one and exits non-zero. There is deliberately NO flag to switch it off: the cure is at the\n * contract, by naming the type.\n *\n * It refuses a declaration with stacked JSDoc the same way, and for the same reason — see\n * {@link StackedJsDocGuard} (#1286). And, in every document including the MCP projection and its tool\n * catalogs, an operation with a body but no `@returns` ({@link MissingReturnsGuard}) and a published\n * schema with no JSDoc description ({@link UndocumentedSchemaGuard}) — each naming every offender in\n * one run (#1292).\n */\nexport class OpenApiGenerator {\n private readonly security = new SecurityDeriver();\n private readonly stackedJsDoc = new StackedJsDocGuard();\n private readonly missingReturns = new MissingReturnsGuard();\n private readonly tagOwnership = new TagOwnership();\n\n /**\n * ONE document per `@ApiType` some contract declares, and no others.\n *\n * A document nobody asked for is not written empty — it is not written. That is the ONE\n * conditional in the whole pipeline, and it lives here rather than in three places: no contract\n * declaring `MCP` means no `mcp-openapi.json`, with no second \"is it empty?\" rule to keep in step\n * with the first.\n */\n generate(inputs: GenerationInputs): GeneratedDocuments {\n // Before ANY selection: a declaration's prose reaches every document it appears in, so the\n // refusal is about the contracts, not about one document (#1286).\n const models = inputs.contracts.map((each: ContractModel) => each.model);\n if (inputs.errorType !== undefined) {\n models.push(inputs.errorType);\n }\n this.stackedJsDoc.refuse(\n models.flatMap((model: ApiDocModel) => model.stackedJsDoc),\n inputs.manifestPath,\n );\n this.missingReturns.refuse(inputs.contracts, inputs.manifestPath);\n this.tagOwnership.refuseSharedOwners(inputs.contracts, inputs.manifestPath);\n // Collected across EVERY OpenAPI document of the run and refused once, after them all, so an\n // author is handed every undocumented schema at once rather than one document at a time.\n const undocumented = new UndocumentedSchemaGuard();\n const documents: GeneratedDocument[] = [];\n for (const selection of DocumentSelection.all()) {\n const contracts = inputs.contracts.filter((each: ContractModel) =>\n selection.acceptsContract(each.model),\n );\n if (contracts.length === 0) {\n continue;\n }\n if (selection.inlinesEveryPackage) {\n documents.push(\n new GeneratedDocument(\n selection.fileName,\n this.bundled(inputs, contracts, selection, undocumented),\n ),\n );\n continue;\n }\n this.refuseCollisions(this.collisionsOf(inputs, contracts), inputs.manifestPath);\n const split = this.render(\n inputs,\n contracts,\n selection,\n new SplitPlacement(inputs.homePackage),\n );\n this.refuseUnpublished(\n split.schemas,\n this.mergedTypes(inputs),\n inputs.upstream,\n selection.fileName,\n inputs.manifestPath,\n );\n undocumented.collect(split.schemas.reachedTypes(), this.mergedTypes(inputs));\n documents.push(new GeneratedDocument(selection.fileName, split.document));\n documents.push(\n new GeneratedDocument(\n `${selection.fileName}${BUNDLED_SUFFIX}`,\n this.bundled(inputs, contracts, selection),\n ),\n );\n }\n undocumented.refuse(inputs.manifestPath);\n return new GeneratedDocuments(documents);\n }\n\n /**\n * A DTO library's COMPONENTS-ONLY document (#1058): `openapi`, `info`, `x-webpieces-id` and\n * `components.schemas` — every type the library exports and declares, with every OTHER package's\n * type a `$ref` into that package's own components document, so a chain of DTO libraries is a\n * chain of documents of any depth.\n *\n * `info.version` is the PACKAGE version. The package-qualified URI downstream documents reference\n * it by (`@scope/pkg/components.openapi.json`) is stated as `x-webpieces-id`, because OpenAPI 3.1's\n * root object admits no `$id` — a 3.1 validator rejects one — and the document must validate on its\n * own.\n */\n components(inputs: ComponentsInputs): GeneratedDocument {\n const model = inputs.model;\n const where = inputs.manifestPath;\n this.stackedJsDoc.refuse(model.stackedJsDoc, where);\n this.refuseCollisions(model.collisions, where);\n const schemas = new SchemaRenderer(model.types, new SplitPlacement(model.packageName));\n for (const key of model.exported) {\n schemas.define(key);\n }\n const rendered = schemas.components();\n this.refuseUnmapped(schemas.unmapped(), COMPONENTS_DOCUMENT, where);\n this.refuseUnpublished(schemas, model.types, inputs.upstream, COMPONENTS_DOCUMENT, where);\n const undocumented = new UndocumentedSchemaGuard();\n undocumented.collect(schemas.reachedTypes(), model.types);\n undocumented.refuse(where);\n if (rendered.isEmpty()) {\n throw new OpenApiGenerationError(\n `${model.packageName}'s entries export no type with a schema`,\n where,\n 'Name the entry files that export the library\\'s DTOs and enums — usually \"src/index.ts\".',\n );\n }\n return new GeneratedDocument(\n COMPONENTS_DOCUMENT,\n new JsonObject()\n .set('openapi', OPENAPI_VERSION)\n .set(\n 'info',\n new JsonObject()\n .set('title', inputs.manifest.title)\n .set('version', model.packageVersion),\n )\n .set('x-webpieces-id', ComponentsReference.documentUri(model.packageName))\n .set('components', new JsonObject().set('schemas', rendered)),\n );\n }\n\n /**\n * The SELF-CONTAINED form of a document: every reached schema defined locally, whichever package\n * declares it — the `*.bundled.json` sibling of a split document, and the MCP projection.\n *\n * Two passes, because a schema's NAME depends on which other schemas the document reaches: the\n * first renders with every type under its unique model key just to learn the reached set, and the\n * second renders with the names {@link BundledNames} assigns from it. Rendering is a pure walk of\n * the model, so the second pass reaches exactly what the first did.\n */\n private bundled(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n undocumented?: UndocumentedSchemaGuard,\n ): JsonObject {\n const discovery = this.render(inputs, contracts, selection, new DiscoveryPlacement());\n // The MCP projection inlines every type it reaches, from any package, so it is judged here\n // over that whole set (#1292). A split document's bundled sibling is not: each type in it is\n // judged by the document — or the components document — that defines it.\n undocumented?.collect(discovery.schemas.reachedTypes(), this.mergedTypes(inputs));\n const names = BundledNames.assign(\n discovery.schemas.reachedTypes(),\n this.mergedTypes(inputs),\n inputs.homePackage,\n );\n return this.render(inputs, contracts, selection, new BundledPlacement(names)).document;\n }\n\n /** ONE document, from the operations this selection accepts and nothing else. */\n private render(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n placement: SchemaPlacement,\n ): RenderedDocument {\n const types = this.mergedTypes(inputs);\n const schemas = new SchemaRenderer(types, placement);\n const operations = new OperationRenderer(\n schemas,\n selection.includeMcpExtensions,\n selection.internalNotice,\n inputs.manifest.operationIds,\n );\n this.refuseDuplicateOperationIds(contracts, selection, operations, inputs.manifestPath);\n const apiKey = this.singleApiKey(inputs, contracts, selection);\n const schemeNames = inputs.manifest.securitySchemeNames;\n const hoisted =\n apiKey !== undefined && this.everyOperationIsCovered(contracts, selection)\n ? this.security.requirement(schemeNames)\n : undefined;\n\n const contract = new ResponseContract(\n this.errorResponses(inputs),\n this.errorSchemaRef(inputs, schemas),\n this.headerRefs(inputs),\n );\n\n const paths = new JsonObject();\n const webhooks = new JsonObject();\n const tags = new Set<string>();\n for (const contractModel of contracts) {\n this.renderContract(\n contractModel,\n selection,\n operations,\n contract,\n this.webhookContract(),\n hoisted === undefined ? this.security.requirement(schemeNames) : undefined,\n paths,\n webhooks,\n tags,\n );\n }\n\n // The schemas are built HERE, after the operations, because building them is what walks a\n // DTO's fields — and an unmapped field can only be found by that walk. A guard that ran\n // before it would see only the top-level request and response refs and miss every one.\n const renderedSchemas = schemas.components().orUndefined();\n this.refuseUnmapped(schemas.unmapped(), selection.fileName, inputs.manifestPath);\n\n const components = new JsonObject()\n .set('schemas', renderedSchemas)\n .set(\n 'securitySchemes',\n this.renderSecuritySchemes(inputs, contracts, selection, apiKey),\n )\n .set('headers', this.headers(inputs));\n\n const document = new JsonObject()\n .set('openapi', OPENAPI_VERSION)\n .set('info', this.info(inputs, selection))\n .set('servers', this.servers(inputs))\n .set('tags', this.tagList(tags, contracts))\n .set('security', hoisted === undefined ? undefined : hoisted.slice())\n .set('paths', paths)\n .set('webhooks', webhooks.orUndefined())\n .set('components', components.orUndefined());\n return new RenderedDocument(document, schemas);\n }\n\n private renderSecuritySchemes(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n apiKey: DocumentedApiKey | undefined,\n ): JsonObject | undefined {\n const schemes =\n apiKey === undefined\n ? new JsonObject()\n : this.security.schemes(\n apiKey,\n inputs.manifest.securitySchemeNames,\n inputs.manifestPath,\n );\n return this.security\n .addBuiltinSchemes(schemes, this.selectedEndpoints(contracts, selection))\n .orUndefined();\n }\n\n /** Same-named, different declarations in one package, across every contract a document reads. */\n private collisionsOf(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n ): readonly TypeNameCollision[] {\n const models = contracts.map((each: ContractModel) => each.model);\n const all = inputs.errorType === undefined ? models : models.concat([inputs.errorType]);\n return all.flatMap((model: ApiDocModel) => Array.from(model.collisions));\n }\n\n /**\n * Two DIFFERENT declarations of one name in one package. A document defines each of its\n * package's schemas under its bare name, so one of the two would be published as the other's\n * shape. (Two packages' same-named types are not this: each is defined in its own package's\n * document — #1058's `LocalizedDescriptionsDto` case.)\n */\n private refuseCollisions(collisions: readonly TypeNameCollision[], where: string): void {\n if (collisions.length === 0) {\n return;\n }\n throw new OpenApiGenerationError(\n `${collisions.length} name(s) are declared twice in one package, so one document would ` +\n 'publish two different types under one name',\n where,\n 'Rename one declaration of each. Within one package a schema name is one type.',\n collisions.map(\n (each: TypeNameCollision) =>\n `${each.name} (${each.packageName ?? 'no package'}): ${each.firstLocation} and ${each.secondLocation}`,\n ),\n );\n }\n\n /**\n * OpenAPI requires every operationId to be unique among ALL operations of a document, webhooks\n * included. `\"operationIds\": \"method\"` publishes the bare method name, so two contracts with a\n * same-named method would publish one id twice — and a generated client would silently get one\n * method for two operations. Refused here, naming both, before anything renders (#1270). The ids\n * come from the renderer's own {@link OperationRenderer.operationIdOf}, so the check and the\n * published value cannot disagree.\n */\n private refuseDuplicateOperationIds(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n operations: OperationRenderer,\n where: string,\n ): void {\n const firstOwner = new Map<string, string>();\n const duplicates: string[] = [];\n for (const contractModel of contracts) {\n const model = contractModel.model;\n for (const endpoint of model.endpoints) {\n if (!selection.acceptsEndpoint(endpoint)) {\n continue;\n }\n const id = operations.operationIdOf(endpoint, model.contractName);\n const owner = `${model.contractName}.${endpoint.methodName} (${contractModel.file})`;\n const first = firstOwner.get(id);\n if (first === undefined) {\n firstOwner.set(id, owner);\n } else {\n duplicates.push(`operationId '${id}': ${first} and ${owner}`);\n }\n }\n }\n if (duplicates.length === 0) {\n return;\n }\n throw new OpenApiGenerationError(\n `${duplicates.length} operationId(s) would be published twice in ${selection.fileName}; ` +\n 'an operationId must be unique across every operation of one document',\n where,\n 'Rename one of each pair of methods, or set \"operationIds\": \"contract_method\" in the ' +\n 'manifest, which prefixes every id with its contract name (this renames every method ' +\n \"in partners' generated clients).\",\n duplicates,\n );\n }\n\n /**\n * FAIL CLOSED (#1058): every type this document references in another package must be a schema\n * of that package's published components document. A package that publishes none is refused —\n * naming the type, its package and the fix — rather than copied in, because silent copying is\n * exactly the duplication this replaces. A document that exists but lacks the schema is stale.\n */\n private refuseUnpublished(\n schemas: SchemaRenderer,\n types: ReadonlyMap<string, DocumentedType>,\n upstream: UpstreamComponentsIndex,\n fileName: string,\n where: string,\n ): void {\n const unpublished: string[] = [];\n const stale: string[] = [];\n for (const key of Array.from(schemas.externalTypes()).sort()) {\n const type = types.get(key)!;\n const owner = type.packageName;\n const declared = `${type.name} — declared in ${owner ?? 'no package'} (${type.location})`;\n if (owner === undefined) {\n unpublished.push(\n `${declared}: its file belongs to no package, so no document can own its schema`,\n );\n continue;\n }\n const published = upstream.publishedBy(owner);\n if (published === undefined) {\n const reason = upstream.missingFor(owner)?.reason ?? 'it was never located';\n unpublished.push(\n `${declared}: ${owner} publishes no components document — ${reason}`,\n );\n } else if (!published.schemaNames.has(type.schemaName)) {\n stale.push(\n `${declared}: ${published.documentPath} has no schema '${type.schemaName}'`,\n );\n }\n }\n if (unpublished.length > 0) {\n throw new OpenApiGenerationError(\n `${unpublished.length} type(s) ${fileName} reaches are declared in a package that ` +\n 'publishes no components document',\n where,\n PUBLISH_COMPONENTS_CURE,\n unpublished,\n );\n }\n if (stale.length > 0) {\n throw new OpenApiGenerationError(\n `${stale.length} type(s) ${fileName} references are missing from their package's components document`,\n where,\n 'Regenerate the upstream components document before this one — it is older than its ' +\n 'source (in nx, \"^openapi-components-generate\" in this target\\'s dependsOn orders it).',\n stale,\n );\n }\n }\n\n /**\n * A webhook is served by the PARTNER, so neither our failure envelope nor the header we stamp on\n * our own responses is true of it. Publishing either would document their server, not ours.\n */\n private webhookContract(): ResponseContract {\n return new ResponseContract([], undefined, undefined);\n }\n\n /** One contract's ACCEPTED endpoints, into `paths` or into `webhooks`. */\n private renderContract(\n contractModel: ContractModel,\n selection: DocumentSelection,\n operations: OperationRenderer,\n contract: ResponseContract,\n webhookContract: ResponseContract,\n perOperationSecurity: readonly JsonValue[] | undefined,\n paths: JsonObject,\n webhooks: JsonObject,\n tags: Set<string>,\n ): void {\n const model = contractModel.model;\n const tag = contractModel.entry.tag;\n for (const endpoint of model.endpoints) {\n if (!selection.acceptsEndpoint(endpoint)) {\n continue;\n }\n // A tag is added only by an operation that survived, so a document never advertises a\n // section of its sidebar that turns out to be empty.\n tags.add(tag);\n if (contractModel.entry.isWebhook()) {\n webhooks.set(\n this.eventName(endpoint),\n new JsonObject().set(\n 'post',\n operations.webhook(endpoint, model.contractName, tag, webhookContract),\n ),\n );\n continue;\n }\n const url = `${model.basePath}${endpoint.path}`;\n const existing = paths.get(url);\n const item = existing instanceof JsonObject ? existing : new JsonObject();\n item.set(\n endpoint.httpMethod.toLowerCase(),\n operations.operation(\n endpoint,\n model.contractName,\n tag,\n contract,\n this.security.operation(endpoint.auth, perOperationSecurity),\n ),\n );\n paths.set(url, item);\n }\n }\n\n /**\n * A webhook is keyed by the EVENT NAME, with the `@ApiPath` base deliberately NOT prepended.\n *\n * There is no url of ours here — the partner hosts the endpoint, at whatever path they choose —\n * so publishing `/our-base/delivered` would document a route that exists nowhere. What we are\n * naming is the event we will send.\n */\n private eventName(endpoint: DocumentedEndpoint): string {\n return endpoint.path.replace(/^\\/+/, '');\n }\n\n /**\n * Every named type from every contract, merged by MODEL KEY — which carries the declaring\n * package, so two packages' same-named types never meet here (#1058).\n *\n * Two contracts declaring DIFFERENT types under one key is a hard failure, not a first-wins\n * merge: `components.schemas` is keyed by name, so one of the two would be published as the\n * other's shape, and the operation referring to it would be quietly wrong.\n */\n private mergedTypes(inputs: GenerationInputs): ReadonlyMap<string, DocumentedType> {\n const merged = new Map<string, DocumentedType>();\n const published = new Map<string, DocumentedType>();\n const sources = inputs.contracts.map((each: ContractModel) => each.model);\n const all = inputs.errorType === undefined ? sources : sources.concat([inputs.errorType]);\n for (const model of all) {\n for (const name of Array.from(model.types.keys())) {\n const incoming = model.types.get(name)!;\n const previous = published.get(incoming.schemaName);\n if (\n previous !== undefined &&\n previous.location !== incoming.location &&\n (previous.name !== previous.schemaName || incoming.name !== incoming.schemaName)\n ) {\n throw new OpenApiGenerationError(\n `stripped schema name '${incoming.schemaName}' collides: '${previous.name}' at ${previous.location} and '${incoming.name}' at ${incoming.location}`,\n inputs.manifestPath,\n 'Change schemaNames so every reached declaration has a distinct published name.',\n );\n }\n published.set(incoming.schemaName, incoming);\n const existing = merged.get(name);\n if (\n existing !== undefined &&\n this.signature(existing) !== this.signature(incoming)\n ) {\n throw new OpenApiGenerationError(\n `two different types are both named '${incoming.name}'`,\n `${model.contractName} (${inputs.manifestPath})`,\n 'Rename one of them. `components.schemas` is keyed by name, so one shape ' +\n 'would be published as the other.',\n );\n }\n merged.set(name, incoming);\n }\n }\n return merged;\n }\n\n /** Enough of a type's shape to tell two same-named types apart without comparing prose. */\n private signature(type: DocumentedType): string {\n const fields = type.fields.map((field: DocumentedField) => field.name).join(',');\n return `${fields}|${type.enumValues.join(',')}|${type.unionRefNames.join(',')}`;\n }\n\n /**\n * The ONE api-key regime this document publishes.\n *\n * Two regimes in one document is a hard failure: `securitySchemeNames` is a single ordered list,\n * so there is no honest way to say which regime a given name belongs to, and a document that\n * guessed would publish one regime's header names under the other's scheme keys.\n */\n private singleApiKey(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): DocumentedApiKey | undefined {\n let found: DocumentedApiKey | undefined;\n for (const endpoint of this.selectedEndpoints(contracts, selection)) {\n const apiKey = endpoint.auth?.methods.find(\n (method: DocumentedAuthMethod) => method.apiKey !== undefined,\n )?.apiKey;\n if (apiKey === undefined) {\n continue;\n }\n if (found !== undefined && found.regime !== apiKey.regime) {\n throw new OpenApiGenerationError(\n `the ${selection.fileName} document mixes the api-key regimes ` +\n `'${found.regime}' ` +\n `and '${apiKey.regime}'`,\n inputs.manifestPath,\n 'Publish one regime per document — split the manifest, or move the ' +\n \"other regime's contract out of `apis`.\",\n );\n }\n found = apiKey;\n }\n return found;\n }\n\n /**\n * True when EVERY selected operation demands the credential, which is what licenses hoisting the\n * requirement to the document. A document that mixes credentialled and uncredentialled routes\n * stamps it per-operation instead — hoisting there would tell a partner that a public endpoint\n * needs a key.\n *\n * Judged per DOCUMENT, over the operations that document actually contains, because that is the\n * only question the document's own `security` block answers.\n */\n private everyOperationIsCovered(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): boolean {\n const served = this.selectedEndpoints(contracts, selection);\n return (\n served.length > 0 &&\n served.every(\n (e: DocumentedEndpoint) =>\n e.auth?.methods.length === 1 && e.auth.methods[0].apiKey !== undefined,\n )\n );\n }\n\n /**\n * The endpoints this selection accepts that are routes on OUR server. A webhook is somebody\n * else's route, so it never counts toward our security requirement or our regime.\n */\n private selectedEndpoints(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): readonly DocumentedEndpoint[] {\n const served: DocumentedEndpoint[] = [];\n for (const contract of contracts) {\n if (contract.entry.isWebhook()) {\n continue;\n }\n for (const endpoint of contract.model.endpoints) {\n if (selection.acceptsEndpoint(endpoint)) {\n served.push(endpoint);\n }\n }\n }\n return served;\n }\n\n /** `info`, whose `description` is the ONE piece of prose that differs between the documents. */\n private info(inputs: GenerationInputs, selection: DocumentSelection): JsonObject {\n return new JsonObject()\n .set('title', inputs.manifest.title)\n .set('version', inputs.manifest.version)\n .set('description', selection.description(inputs.description));\n }\n\n private servers(inputs: GenerationInputs): readonly JsonValue[] | undefined {\n if (inputs.manifest.servers.length === 0) {\n return undefined;\n }\n return inputs.manifest.servers.map((server: ServerEntry) =>\n new JsonObject().set('url', server.url).set('description', server.description),\n );\n }\n\n /**\n * `tags[]` in MANIFEST ORDER, because that order IS the published sidebar — one of the two\n * orders in this document that carries meaning and is therefore NOT sorted. Each description is\n * the owning contract's JSDoc — see {@link TagOwnership} (#1292).\n */\n private tagList(\n tags: ReadonlySet<string>,\n contracts: readonly ContractModel[],\n ): readonly JsonValue[] | undefined {\n const list: JsonValue[] = [];\n for (const name of Array.from(tags)) {\n list.push(\n new JsonObject()\n .set('name', name)\n .set('description', this.tagOwnership.descriptionOf(name, contracts)),\n );\n }\n return list.length === 0 ? undefined : list;\n }\n\n private errorResponses(inputs: GenerationInputs): readonly ErrorResponseEntry[] {\n return inputs.manifest.errors?.responses ?? [];\n }\n\n private errorSchemaRef(\n inputs: GenerationInputs,\n schemas: SchemaRenderer,\n ): JsonObject | undefined {\n const errors = inputs.manifest.errors;\n if (errors === undefined || inputs.errorType === undefined) {\n return undefined;\n }\n // Rendering the reference is what puts the error body into `components.schemas`, so the\n // published shape is the compiler's answer about that TS type and not a hand-copied one.\n // The model key of a type its own file declares is its bare name (`DocumentedType.keyOf`).\n return schemas.type(TypeRef.ref(errors.type), '#/components/schemas/error');\n }\n\n /** `components.headers`, one entry per declared response header. */\n private headers(inputs: GenerationInputs): JsonObject | undefined {\n const headers = new JsonObject();\n for (const header of inputs.responseHeaders) {\n headers.set(\n header.headerName,\n new JsonObject()\n .set('description', header.description)\n .set('required', header.required)\n .set('schema', new JsonObject().set('type', 'string')),\n );\n }\n return headers.orUndefined();\n }\n\n /** The `$ref`s every SUCCESS response carries at those headers. */\n private headerRefs(inputs: GenerationInputs): JsonObject | undefined {\n const refs = new JsonObject();\n for (const header of inputs.responseHeaders) {\n refs.set(\n header.headerName,\n new JsonObject().set('$ref', `#/components/headers/${header.headerName}`),\n );\n }\n return refs.orUndefined();\n }\n\n /**\n * The guard. An unmapped field is a published partner-facing field with no shape, and there is\n * deliberately no flag to switch this off — the cure is at the contract, by naming the type.\n */\n private refuseUnmapped(\n unmapped: readonly UnmappedField[],\n fileName: string,\n manifestPath: string,\n ): void {\n if (unmapped.length === 0) {\n return;\n }\n const pointers = unmapped.map(\n (field: UnmappedField) => `${field.pointer} (${field.typeText})`,\n );\n throw new OpenApiGenerationError(\n `${unmapped.length} field(s) in ${fileName} have no schema it can state`,\n manifestPath,\n 'Give each one a type a document can carry — a named DTO, an array of one, a ' +\n 'string-literal union, or Record<string, X>. An untyped field publishes as \"anything\".',\n pointers,\n );\n }\n}\n"]}
1
+ {"version":3,"file":"OpenApiGenerator.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/OpenApiGenerator.ts"],"names":[],"mappings":";;;AAAA,4DASkC;AAClC,mDAA2D;AAC3D,sEAAmE;AAEnE,yDAM4B;AAC5B,2DAAwD;AACxD,2DAA0E;AAC1E,uDAO2B;AAC3B,qDAAiE;AACjE,uDAAoD;AACpD,yDAAsD;AACtD,+DAA4D;AAC5D,iDAA8C;AAC9C,2DAAwD;AACxD,iDAA8C;AAC9C,uEAAoE;AAGpE,uGAAuG;AACvG,MAAM,gBAAgB;IAEL;IACA;IAFb,YACa,QAAoB,EACpB,OAAuB;QADvB,aAAQ,GAAR,QAAQ,CAAY;QACpB,YAAO,GAAP,OAAO,CAAgB;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cesContent":["import {\n ApiDocModel,\n DocumentedApiKey,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedField,\n DocumentedType,\n TypeNameCollision,\n TypeRef,\n} from '@webpieces/api-doc-model';\nimport { JsonObject, JsonValue } from '../json/JsonObject';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\nimport { ErrorResponseEntry, ServerEntry } from '../manifest/OpenApiManifest';\nimport {\n ComponentsInputs,\n ContractModel,\n GeneratedDocument,\n GeneratedDocuments,\n GenerationInputs,\n} from './GenerationInputs';\nimport { DocumentSelection } from './DocumentSelection';\nimport { OperationRenderer, ResponseContract } from './OperationRenderer';\nimport {\n BundledNames,\n BundledPlacement,\n ComponentsReference,\n DiscoveryPlacement,\n SchemaPlacement,\n SplitPlacement,\n} from './SchemaPlacement';\nimport { SchemaRenderer, UnmappedField } from './SchemaRenderer';\nimport { SecurityDeriver } from './SecurityDeriver';\nimport { McpToolNameGuard } from './McpToolNameGuard';\nimport { MissingReturnsGuard } from './MissingReturnsGuard';\nimport { SummaryGuard } from './SummaryGuard';\nimport { StackedJsDocGuard } from './StackedJsDocGuard';\nimport { TagOwnership } from './TagOwnership';\nimport { UndocumentedSchemaGuard } from './UndocumentedSchemaGuard';\nimport { UpstreamComponentsIndex } from './UpstreamComponents';\n\n/** One rendered document, and the renderer that built its schemas — what it defined and referenced. */\nclass RenderedDocument {\n constructor(\n readonly document: JsonObject,\n readonly schemas: SchemaRenderer,\n ) {}\n}\n\n/** The suffix of a split document's self-contained sibling: `public-openapi.bundled.json`. */\nconst BUNDLED_SUFFIX = '.bundled';\n\n/** The document a DTO library publishes, without its extension (#1058). */\nconst COMPONENTS_DOCUMENT = 'components.openapi';\n\n/**\n * Every cure for a type reached in a package that publishes no components document.\n *\n * Tagging is offered ONLY for a package that is already a role:api-lib DTO library (#1064, D5): a\n * general library such as `company-core` is refused the tag by validate-nx-wiring and by the\n * openapi-components-generate executor, so \"tag the package\" is never a way out of moving the type.\n */\nconst PUBLISH_COMPONENTS_CURE =\n 'Move each type into a role:api-lib DTO library that publishes a components document — as a ' +\n '`…Dto` string enum when it is a string-literal union. Only when the declaring package is ITSELF a ' +\n 'role:api-lib DTO library, tag it \"generate:openapi-components\" so it publishes one (with a ' +\n '\"kind\": \"components\" openapi.manifest.json naming its entry files; outside nx, render that manifest ' +\n 'with wp-openapi into the directory the package is packed from); a general library is refused the ' +\n \"tag. A document references another package's schema; it never copies one in.\";\n\n/** The OpenAPI version this generator writes. See the class doc for why 3.1 and not 3.0. */\nconst OPENAPI_VERSION = '3.1.0';\n\n/**\n * {@link GenerationInputs} -> one OpenAPI 3.1.0 document per `@ApiType` some contract declares.\n *\n * ## 3.1, because it is what the model can state HONESTLY\n *\n * `type: [T, \"null\"]` instead of a `nullable` keyword; a `description` legal beside a `$ref`; a\n * top-level `webhooks:` block. Each of those is a fact the model holds that 3.0 would have forced\n * this renderer to drop or to lie about. 3.1's schema dialect is also JSON Schema 2020-12, which is\n * what MCP `tools/list` speaks.\n *\n * ## ONE render function, called once per document\n *\n * ```\n * ApiDocModel --> render(selection) --+--> full-private-openapi.json SVC_TO_SVC contracts\n * +--> public-openapi.json EXTERNAL_CUSTOMER contracts, minus hidden methods\n * +--> mcp-openapi.json MCP contracts\n * ```\n *\n * `components.schemas` is built by walking OUTWARD from the operations the selection accepted, so an\n * unselected operation's DTOs are never constructed. See {@link DocumentSelection} for why that\n * asymmetry — a bug emits nothing, rather than shipping an unreleased feature's schemas with only\n * its URL removed — decides the whole design.\n *\n * ## It REFUSES to write an unmapped field\n *\n * An unmapped type renders as an empty schema, which in JSON Schema means \"anything\". Publishing one\n * is a green build handing a partner a field with no shape, so the guard names the JSON pointer of\n * every one and exits non-zero. There is deliberately NO flag to switch it off: the cure is at the\n * contract, by naming the type.\n *\n * It refuses a declaration with stacked JSDoc the same way, and for the same reason — see\n * {@link StackedJsDocGuard} (#1286). And, in every document including the MCP projection and its tool\n * catalogs, an operation with a body but no `@returns` ({@link MissingReturnsGuard}) and a published\n * schema with no JSDoc description ({@link UndocumentedSchemaGuard}) — each naming every offender in\n * one run (#1292). Likewise an operation with no valid `@summary` ({@link SummaryGuard}) and an MCP\n * tool whose name the Claude Connectors Directory would refuse ({@link McpToolNameGuard}) (#1296).\n */\nexport class OpenApiGenerator {\n private readonly security = new SecurityDeriver();\n private readonly stackedJsDoc = new StackedJsDocGuard();\n private readonly missingReturns = new MissingReturnsGuard();\n private readonly summaries = new SummaryGuard();\n private readonly toolNames = new McpToolNameGuard();\n private readonly tagOwnership = new TagOwnership();\n\n /**\n * ONE document per `@ApiType` some contract declares, and no others.\n *\n * A document nobody asked for is not written empty — it is not written. That is the ONE\n * conditional in the whole pipeline, and it lives here rather than in three places: no contract\n * declaring `MCP` means no `mcp-openapi.json`, with no second \"is it empty?\" rule to keep in step\n * with the first.\n */\n generate(inputs: GenerationInputs): GeneratedDocuments {\n // Before ANY selection: a declaration's prose reaches every document it appears in, so the\n // refusal is about the contracts, not about one document (#1286).\n const models = inputs.contracts.map((each: ContractModel) => each.model);\n if (inputs.errorType !== undefined) {\n models.push(inputs.errorType);\n }\n this.stackedJsDoc.refuse(\n models.flatMap((model: ApiDocModel) => model.stackedJsDoc),\n inputs.manifestPath,\n );\n this.summaries.refuse(inputs.contracts, inputs.manifestPath);\n this.toolNames.refuse(inputs.contracts, inputs.manifestPath);\n this.missingReturns.refuse(inputs.contracts, inputs.manifestPath);\n this.tagOwnership.refuseSharedOwners(inputs.contracts, inputs.manifestPath);\n // Collected across EVERY OpenAPI document of the run and refused once, after them all, so an\n // author is handed every undocumented schema at once rather than one document at a time.\n const undocumented = new UndocumentedSchemaGuard();\n const documents: GeneratedDocument[] = [];\n for (const selection of DocumentSelection.all()) {\n const contracts = inputs.contracts.filter((each: ContractModel) =>\n selection.acceptsContract(each.model),\n );\n if (contracts.length === 0) {\n continue;\n }\n if (selection.inlinesEveryPackage) {\n documents.push(\n new GeneratedDocument(\n selection.fileName,\n this.bundled(inputs, contracts, selection, undocumented),\n ),\n );\n continue;\n }\n this.refuseCollisions(this.collisionsOf(inputs, contracts), inputs.manifestPath);\n const split = this.render(\n inputs,\n contracts,\n selection,\n new SplitPlacement(inputs.homePackage),\n );\n this.refuseUnpublished(\n split.schemas,\n this.mergedTypes(inputs),\n inputs.upstream,\n selection.fileName,\n inputs.manifestPath,\n );\n undocumented.collect(split.schemas.reachedTypes(), this.mergedTypes(inputs));\n documents.push(new GeneratedDocument(selection.fileName, split.document));\n documents.push(\n new GeneratedDocument(\n `${selection.fileName}${BUNDLED_SUFFIX}`,\n this.bundled(inputs, contracts, selection),\n ),\n );\n }\n undocumented.refuse(inputs.manifestPath);\n return new GeneratedDocuments(documents);\n }\n\n /**\n * A DTO library's COMPONENTS-ONLY document (#1058): `openapi`, `info`, `x-webpieces-id` and\n * `components.schemas` — every type the library exports and declares, with every OTHER package's\n * type a `$ref` into that package's own components document, so a chain of DTO libraries is a\n * chain of documents of any depth.\n *\n * `info.version` is the PACKAGE version. The package-qualified URI downstream documents reference\n * it by (`@scope/pkg/components.openapi.json`) is stated as `x-webpieces-id`, because OpenAPI 3.1's\n * root object admits no `$id` — a 3.1 validator rejects one — and the document must validate on its\n * own.\n */\n components(inputs: ComponentsInputs): GeneratedDocument {\n const model = inputs.model;\n const where = inputs.manifestPath;\n this.stackedJsDoc.refuse(model.stackedJsDoc, where);\n this.refuseCollisions(model.collisions, where);\n const schemas = new SchemaRenderer(model.types, new SplitPlacement(model.packageName));\n for (const key of model.exported) {\n schemas.define(key);\n }\n const rendered = schemas.components();\n this.refuseUnmapped(schemas.unmapped(), COMPONENTS_DOCUMENT, where);\n this.refuseUnpublished(schemas, model.types, inputs.upstream, COMPONENTS_DOCUMENT, where);\n const undocumented = new UndocumentedSchemaGuard();\n undocumented.collect(schemas.reachedTypes(), model.types);\n undocumented.refuse(where);\n if (rendered.isEmpty()) {\n throw new OpenApiGenerationError(\n `${model.packageName}'s entries export no type with a schema`,\n where,\n 'Name the entry files that export the library\\'s DTOs and enums — usually \"src/index.ts\".',\n );\n }\n return new GeneratedDocument(\n COMPONENTS_DOCUMENT,\n new JsonObject()\n .set('openapi', OPENAPI_VERSION)\n .set(\n 'info',\n new JsonObject()\n .set('title', inputs.manifest.title)\n .set('version', model.packageVersion),\n )\n .set('x-webpieces-id', ComponentsReference.documentUri(model.packageName))\n .set('components', new JsonObject().set('schemas', rendered)),\n );\n }\n\n /**\n * The SELF-CONTAINED form of a document: every reached schema defined locally, whichever package\n * declares it — the `*.bundled.json` sibling of a split document, and the MCP projection.\n *\n * Two passes, because a schema's NAME depends on which other schemas the document reaches: the\n * first renders with every type under its unique model key just to learn the reached set, and the\n * second renders with the names {@link BundledNames} assigns from it. Rendering is a pure walk of\n * the model, so the second pass reaches exactly what the first did.\n */\n private bundled(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n undocumented?: UndocumentedSchemaGuard,\n ): JsonObject {\n const discovery = this.render(inputs, contracts, selection, new DiscoveryPlacement());\n // The MCP projection inlines every type it reaches, from any package, so it is judged here\n // over that whole set (#1292). A split document's bundled sibling is not: each type in it is\n // judged by the document — or the components document — that defines it.\n undocumented?.collect(discovery.schemas.reachedTypes(), this.mergedTypes(inputs));\n const names = BundledNames.assign(\n discovery.schemas.reachedTypes(),\n this.mergedTypes(inputs),\n inputs.homePackage,\n );\n return this.render(inputs, contracts, selection, new BundledPlacement(names)).document;\n }\n\n /** ONE document, from the operations this selection accepts and nothing else. */\n private render(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n placement: SchemaPlacement,\n ): RenderedDocument {\n const types = this.mergedTypes(inputs);\n const schemas = new SchemaRenderer(types, placement);\n const operations = new OperationRenderer(\n schemas,\n selection.includeMcpExtensions,\n selection.internalNotice,\n inputs.manifest.operationIds,\n );\n this.refuseDuplicateOperationIds(contracts, selection, operations, inputs.manifestPath);\n const apiKey = this.singleApiKey(inputs, contracts, selection);\n const schemeNames = inputs.manifest.securitySchemeNames;\n const hoisted =\n apiKey !== undefined && this.everyOperationIsCovered(contracts, selection)\n ? this.security.requirement(schemeNames)\n : undefined;\n\n const contract = new ResponseContract(\n this.errorResponses(inputs),\n this.errorSchemaRef(inputs, schemas),\n this.headerRefs(inputs),\n );\n\n const paths = new JsonObject();\n const webhooks = new JsonObject();\n const tags = new Set<string>();\n for (const contractModel of contracts) {\n this.renderContract(\n contractModel,\n selection,\n operations,\n contract,\n this.webhookContract(),\n hoisted === undefined ? this.security.requirement(schemeNames) : undefined,\n paths,\n webhooks,\n tags,\n );\n }\n\n // The schemas are built HERE, after the operations, because building them is what walks a\n // DTO's fields — and an unmapped field can only be found by that walk. A guard that ran\n // before it would see only the top-level request and response refs and miss every one.\n const renderedSchemas = schemas.components().orUndefined();\n this.refuseUnmapped(schemas.unmapped(), selection.fileName, inputs.manifestPath);\n\n const components = new JsonObject()\n .set('schemas', renderedSchemas)\n .set(\n 'securitySchemes',\n this.renderSecuritySchemes(inputs, contracts, selection, apiKey),\n )\n .set('headers', this.headers(inputs));\n\n const document = new JsonObject()\n .set('openapi', OPENAPI_VERSION)\n .set('info', this.info(inputs, selection))\n .set('servers', this.servers(inputs))\n .set('tags', this.tagList(tags, contracts))\n .set('security', hoisted === undefined ? undefined : hoisted.slice())\n .set('paths', paths)\n .set('webhooks', webhooks.orUndefined())\n .set('components', components.orUndefined());\n return new RenderedDocument(document, schemas);\n }\n\n private renderSecuritySchemes(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n apiKey: DocumentedApiKey | undefined,\n ): JsonObject | undefined {\n const schemes =\n apiKey === undefined\n ? new JsonObject()\n : this.security.schemes(\n apiKey,\n inputs.manifest.securitySchemeNames,\n inputs.manifestPath,\n );\n return this.security\n .addBuiltinSchemes(schemes, this.selectedEndpoints(contracts, selection))\n .orUndefined();\n }\n\n /** Same-named, different declarations in one package, across every contract a document reads. */\n private collisionsOf(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n ): readonly TypeNameCollision[] {\n const models = contracts.map((each: ContractModel) => each.model);\n const all = inputs.errorType === undefined ? models : models.concat([inputs.errorType]);\n return all.flatMap((model: ApiDocModel) => Array.from(model.collisions));\n }\n\n /**\n * Two DIFFERENT declarations of one name in one package. A document defines each of its\n * package's schemas under its bare name, so one of the two would be published as the other's\n * shape. (Two packages' same-named types are not this: each is defined in its own package's\n * document — #1058's `LocalizedDescriptionsDto` case.)\n */\n private refuseCollisions(collisions: readonly TypeNameCollision[], where: string): void {\n if (collisions.length === 0) {\n return;\n }\n throw new OpenApiGenerationError(\n `${collisions.length} name(s) are declared twice in one package, so one document would ` +\n 'publish two different types under one name',\n where,\n 'Rename one declaration of each. Within one package a schema name is one type.',\n collisions.map(\n (each: TypeNameCollision) =>\n `${each.name} (${each.packageName ?? 'no package'}): ${each.firstLocation} and ${each.secondLocation}`,\n ),\n );\n }\n\n /**\n * OpenAPI requires every operationId to be unique among ALL operations of a document, webhooks\n * included. `\"operationIds\": \"method\"` publishes the bare method name, so two contracts with a\n * same-named method would publish one id twice — and a generated client would silently get one\n * method for two operations. Refused here, naming both, before anything renders (#1270). The ids\n * come from the renderer's own {@link OperationRenderer.operationIdOf}, so the check and the\n * published value cannot disagree.\n */\n private refuseDuplicateOperationIds(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n operations: OperationRenderer,\n where: string,\n ): void {\n const firstOwner = new Map<string, string>();\n const duplicates: string[] = [];\n for (const contractModel of contracts) {\n const model = contractModel.model;\n for (const endpoint of model.endpoints) {\n if (!selection.acceptsEndpoint(endpoint)) {\n continue;\n }\n const id = operations.operationIdOf(endpoint, model.contractName);\n const owner = `${model.contractName}.${endpoint.methodName} (${contractModel.file})`;\n const first = firstOwner.get(id);\n if (first === undefined) {\n firstOwner.set(id, owner);\n } else {\n duplicates.push(`operationId '${id}': ${first} and ${owner}`);\n }\n }\n }\n if (duplicates.length === 0) {\n return;\n }\n throw new OpenApiGenerationError(\n `${duplicates.length} operationId(s) would be published twice in ${selection.fileName}; ` +\n 'an operationId must be unique across every operation of one document',\n where,\n 'Rename one of each pair of methods, or set \"operationIds\": \"contract_method\" in the ' +\n 'manifest, which prefixes every id with its contract name (this renames every method ' +\n \"in partners' generated clients).\",\n duplicates,\n );\n }\n\n /**\n * FAIL CLOSED (#1058): every type this document references in another package must be a schema\n * of that package's published components document. A package that publishes none is refused —\n * naming the type, its package and the fix — rather than copied in, because silent copying is\n * exactly the duplication this replaces. A document that exists but lacks the schema is stale.\n */\n private refuseUnpublished(\n schemas: SchemaRenderer,\n types: ReadonlyMap<string, DocumentedType>,\n upstream: UpstreamComponentsIndex,\n fileName: string,\n where: string,\n ): void {\n const unpublished: string[] = [];\n const stale: string[] = [];\n for (const key of Array.from(schemas.externalTypes()).sort()) {\n const type = types.get(key)!;\n const owner = type.packageName;\n const declared = `${type.name} — declared in ${owner ?? 'no package'} (${type.location})`;\n if (owner === undefined) {\n unpublished.push(\n `${declared}: its file belongs to no package, so no document can own its schema`,\n );\n continue;\n }\n const published = upstream.publishedBy(owner);\n if (published === undefined) {\n const reason = upstream.missingFor(owner)?.reason ?? 'it was never located';\n unpublished.push(\n `${declared}: ${owner} publishes no components document — ${reason}`,\n );\n } else if (!published.schemaNames.has(type.schemaName)) {\n stale.push(\n `${declared}: ${published.documentPath} has no schema '${type.schemaName}'`,\n );\n }\n }\n if (unpublished.length > 0) {\n throw new OpenApiGenerationError(\n `${unpublished.length} type(s) ${fileName} reaches are declared in a package that ` +\n 'publishes no components document',\n where,\n PUBLISH_COMPONENTS_CURE,\n unpublished,\n );\n }\n if (stale.length > 0) {\n throw new OpenApiGenerationError(\n `${stale.length} type(s) ${fileName} references are missing from their package's components document`,\n where,\n 'Regenerate the upstream components document before this one — it is older than its ' +\n 'source (in nx, \"^openapi-components-generate\" in this target\\'s dependsOn orders it).',\n stale,\n );\n }\n }\n\n /**\n * A webhook is served by the PARTNER, so neither our failure envelope nor the header we stamp on\n * our own responses is true of it. Publishing either would document their server, not ours.\n */\n private webhookContract(): ResponseContract {\n return new ResponseContract([], undefined, undefined);\n }\n\n /** One contract's ACCEPTED endpoints, into `paths` or into `webhooks`. */\n private renderContract(\n contractModel: ContractModel,\n selection: DocumentSelection,\n operations: OperationRenderer,\n contract: ResponseContract,\n webhookContract: ResponseContract,\n perOperationSecurity: readonly JsonValue[] | undefined,\n paths: JsonObject,\n webhooks: JsonObject,\n tags: Set<string>,\n ): void {\n const model = contractModel.model;\n const tag = contractModel.entry.tag;\n for (const endpoint of model.endpoints) {\n if (!selection.acceptsEndpoint(endpoint)) {\n continue;\n }\n // A tag is added only by an operation that survived, so a document never advertises a\n // section of its sidebar that turns out to be empty.\n tags.add(tag);\n if (contractModel.entry.isWebhook()) {\n webhooks.set(\n this.eventName(endpoint),\n new JsonObject().set(\n 'post',\n operations.webhook(endpoint, model.contractName, tag, webhookContract),\n ),\n );\n continue;\n }\n const url = `${model.basePath}${endpoint.path}`;\n const existing = paths.get(url);\n const item = existing instanceof JsonObject ? existing : new JsonObject();\n item.set(\n endpoint.httpMethod.toLowerCase(),\n operations.operation(\n endpoint,\n model.contractName,\n tag,\n contract,\n this.security.operation(endpoint.auth, perOperationSecurity),\n ),\n );\n paths.set(url, item);\n }\n }\n\n /**\n * A webhook is keyed by the EVENT NAME, with the `@ApiPath` base deliberately NOT prepended.\n *\n * There is no url of ours here — the partner hosts the endpoint, at whatever path they choose —\n * so publishing `/our-base/delivered` would document a route that exists nowhere. What we are\n * naming is the event we will send.\n */\n private eventName(endpoint: DocumentedEndpoint): string {\n return endpoint.path.replace(/^\\/+/, '');\n }\n\n /**\n * Every named type from every contract, merged by MODEL KEY — which carries the declaring\n * package, so two packages' same-named types never meet here (#1058).\n *\n * Two contracts declaring DIFFERENT types under one key is a hard failure, not a first-wins\n * merge: `components.schemas` is keyed by name, so one of the two would be published as the\n * other's shape, and the operation referring to it would be quietly wrong.\n */\n private mergedTypes(inputs: GenerationInputs): ReadonlyMap<string, DocumentedType> {\n const merged = new Map<string, DocumentedType>();\n const published = new Map<string, DocumentedType>();\n const sources = inputs.contracts.map((each: ContractModel) => each.model);\n const all = inputs.errorType === undefined ? sources : sources.concat([inputs.errorType]);\n for (const model of all) {\n for (const name of Array.from(model.types.keys())) {\n const incoming = model.types.get(name)!;\n const previous = published.get(incoming.schemaName);\n if (\n previous !== undefined &&\n previous.location !== incoming.location &&\n (previous.name !== previous.schemaName || incoming.name !== incoming.schemaName)\n ) {\n throw new OpenApiGenerationError(\n `stripped schema name '${incoming.schemaName}' collides: '${previous.name}' at ${previous.location} and '${incoming.name}' at ${incoming.location}`,\n inputs.manifestPath,\n 'Change schemaNames so every reached declaration has a distinct published name.',\n );\n }\n published.set(incoming.schemaName, incoming);\n const existing = merged.get(name);\n if (\n existing !== undefined &&\n this.signature(existing) !== this.signature(incoming)\n ) {\n throw new OpenApiGenerationError(\n `two different types are both named '${incoming.name}'`,\n `${model.contractName} (${inputs.manifestPath})`,\n 'Rename one of them. `components.schemas` is keyed by name, so one shape ' +\n 'would be published as the other.',\n );\n }\n merged.set(name, incoming);\n }\n }\n return merged;\n }\n\n /** Enough of a type's shape to tell two same-named types apart without comparing prose. */\n private signature(type: DocumentedType): string {\n const fields = type.fields.map((field: DocumentedField) => field.name).join(',');\n return `${fields}|${type.enumValues.join(',')}|${type.unionRefNames.join(',')}`;\n }\n\n /**\n * The ONE api-key regime this document publishes.\n *\n * Two regimes in one document is a hard failure: `securitySchemeNames` is a single ordered list,\n * so there is no honest way to say which regime a given name belongs to, and a document that\n * guessed would publish one regime's header names under the other's scheme keys.\n */\n private singleApiKey(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): DocumentedApiKey | undefined {\n let found: DocumentedApiKey | undefined;\n for (const endpoint of this.selectedEndpoints(contracts, selection)) {\n const apiKey = endpoint.auth?.methods.find(\n (method: DocumentedAuthMethod) => method.apiKey !== undefined,\n )?.apiKey;\n if (apiKey === undefined) {\n continue;\n }\n if (found !== undefined && found.regime !== apiKey.regime) {\n throw new OpenApiGenerationError(\n `the ${selection.fileName} document mixes the api-key regimes ` +\n `'${found.regime}' ` +\n `and '${apiKey.regime}'`,\n inputs.manifestPath,\n 'Publish one regime per document — split the manifest, or move the ' +\n \"other regime's contract out of `apis`.\",\n );\n }\n found = apiKey;\n }\n return found;\n }\n\n /**\n * True when EVERY selected operation demands the credential, which is what licenses hoisting the\n * requirement to the document. A document that mixes credentialled and uncredentialled routes\n * stamps it per-operation instead — hoisting there would tell a partner that a public endpoint\n * needs a key.\n *\n * Judged per DOCUMENT, over the operations that document actually contains, because that is the\n * only question the document's own `security` block answers.\n */\n private everyOperationIsCovered(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): boolean {\n const served = this.selectedEndpoints(contracts, selection);\n return (\n served.length > 0 &&\n served.every(\n (e: DocumentedEndpoint) =>\n e.auth?.methods.length === 1 && e.auth.methods[0].apiKey !== undefined,\n )\n );\n }\n\n /**\n * The endpoints this selection accepts that are routes on OUR server. A webhook is somebody\n * else's route, so it never counts toward our security requirement or our regime.\n */\n private selectedEndpoints(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): readonly DocumentedEndpoint[] {\n const served: DocumentedEndpoint[] = [];\n for (const contract of contracts) {\n if (contract.entry.isWebhook()) {\n continue;\n }\n for (const endpoint of contract.model.endpoints) {\n if (selection.acceptsEndpoint(endpoint)) {\n served.push(endpoint);\n }\n }\n }\n return served;\n }\n\n /** `info`, whose `description` is the ONE piece of prose that differs between the documents. */\n private info(inputs: GenerationInputs, selection: DocumentSelection): JsonObject {\n return new JsonObject()\n .set('title', inputs.manifest.title)\n .set('summary', inputs.manifest.summary)\n .set('version', inputs.manifest.version)\n .set('description', selection.description(inputs.description));\n }\n\n private servers(inputs: GenerationInputs): readonly JsonValue[] | undefined {\n if (inputs.manifest.servers.length === 0) {\n return undefined;\n }\n return inputs.manifest.servers.map((server: ServerEntry) =>\n new JsonObject().set('url', server.url).set('description', server.description),\n );\n }\n\n /**\n * `tags[]` in MANIFEST ORDER, because that order IS the published sidebar — one of the two\n * orders in this document that carries meaning and is therefore NOT sorted. Each description is\n * the owning contract's JSDoc — see {@link TagOwnership} (#1292).\n */\n private tagList(\n tags: ReadonlySet<string>,\n contracts: readonly ContractModel[],\n ): readonly JsonValue[] | undefined {\n const list: JsonValue[] = [];\n for (const name of Array.from(tags)) {\n list.push(\n new JsonObject()\n .set('name', name)\n .set('description', this.tagOwnership.descriptionOf(name, contracts)),\n );\n }\n return list.length === 0 ? undefined : list;\n }\n\n private errorResponses(inputs: GenerationInputs): readonly ErrorResponseEntry[] {\n return inputs.manifest.errors?.responses ?? [];\n }\n\n private errorSchemaRef(\n inputs: GenerationInputs,\n schemas: SchemaRenderer,\n ): JsonObject | undefined {\n const errors = inputs.manifest.errors;\n if (errors === undefined || inputs.errorType === undefined) {\n return undefined;\n }\n // Rendering the reference is what puts the error body into `components.schemas`, so the\n // published shape is the compiler's answer about that TS type and not a hand-copied one.\n // The model key of a type its own file declares is its bare name (`DocumentedType.keyOf`).\n return schemas.type(TypeRef.ref(errors.type), '#/components/schemas/error');\n }\n\n /** `components.headers`, one entry per declared response header. */\n private headers(inputs: GenerationInputs): JsonObject | undefined {\n const headers = new JsonObject();\n for (const header of inputs.responseHeaders) {\n headers.set(\n header.headerName,\n new JsonObject()\n .set('description', header.description)\n .set('required', header.required)\n .set('schema', new JsonObject().set('type', 'string')),\n );\n }\n return headers.orUndefined();\n }\n\n /** The `$ref`s every SUCCESS response carries at those headers. */\n private headerRefs(inputs: GenerationInputs): JsonObject | undefined {\n const refs = new JsonObject();\n for (const header of inputs.responseHeaders) {\n refs.set(\n header.headerName,\n new JsonObject().set('$ref', `#/components/headers/${header.headerName}`),\n );\n }\n return refs.orUndefined();\n }\n\n /**\n * The guard. An unmapped field is a published partner-facing field with no shape, and there is\n * deliberately no flag to switch this off — the cure is at the contract, by naming the type.\n */\n private refuseUnmapped(\n unmapped: readonly UnmappedField[],\n fileName: string,\n manifestPath: string,\n ): void {\n if (unmapped.length === 0) {\n return;\n }\n const pointers = unmapped.map(\n (field: UnmappedField) => `${field.pointer} (${field.typeText})`,\n );\n throw new OpenApiGenerationError(\n `${unmapped.length} field(s) in ${fileName} have no schema it can state`,\n manifestPath,\n 'Give each one a type a document can carry — a named DTO, an array of one, a ' +\n 'string-literal union, or Record<string, X>. An untyped field publishes as \"anything\".',\n pointers,\n );\n }\n}\n"]}
@@ -29,12 +29,15 @@ export declare class ResponseContract {
29
29
  /**
30
30
  * ONE {@link DocumentedEndpoint} -> one OpenAPI Operation Object.
31
31
  *
32
- * ## `summary` is the operation NAME, never a sentence
32
+ * ## `summary` is the method's `@summary` JSDoc tag — a short title, never a sentence (#1296)
33
33
  *
34
- * A docs theme titles the endpoint's page from `summary` and puts `description` in the body. Writing
35
- * the first sentence of the prose into `summary` therefore produces a sidebar of sentences and a page
36
- * whose heading repeats its own first line. The method name is what a reader is looking for, and it
37
- * is also what the generated client calls the method, so the two agree by construction.
34
+ * A docs theme titles the endpoint's page from `summary` and labels its sidebar with it, and puts
35
+ * `description` in the body. It used to be the bare method name, which put code identifiers in every
36
+ * heading. It is now the `@summary` line the author wrote — one line, at most 100 characters,
37
+ * REQUIRED on every published operation by {@link SummaryGuard} — and the tag is not part of
38
+ * `description`, so the page does not repeat its own heading. The code identifier stays published as
39
+ * `operationId`, which is what a generated client names the method. The same line is the MCP tool's
40
+ * `title`, so a partner's docs page and an agent's tool list name the endpoint identically.
38
41
  *
39
42
  * ## The MCP extensions ride HERE, on the operation
40
43
  *
@@ -120,7 +123,14 @@ export declare class OperationRenderer {
120
123
  * a human declares, because it is a judgement about the world rather than a consequence of the
121
124
  * operation.
122
125
  *
123
- * ## There is no separate MCP description
126
+ * ## The title is the operation's `summary`, published as the Tool's `title` AND `annotations.title`
127
+ *
128
+ * `x-mcp-title` and `x-mcp-hints.title` carry the `@summary` line exactly as `tools/list` serves it:
129
+ * `Tool.title` for clients on the 2025-06-18+ spec and `annotations.title` (the block `x-mcp-hints`
130
+ * mirrors) for older clients and the Claude Connectors Directory (#1296). One source, so they cannot
131
+ * differ from the operation's own `summary`.
132
+ *
133
+ * ## There is no separate MCP description
124
134
  *
125
135
  * The agent reads the operation's `description` — the method's JSDoc — byte-identical to what the
126
136
  * partner reads. `x-mcp-description` appears ONLY when the author wrote an explicit `@mcp` JSDoc
@@ -33,12 +33,15 @@ exports.ResponseContract = ResponseContract;
33
33
  /**
34
34
  * ONE {@link DocumentedEndpoint} -> one OpenAPI Operation Object.
35
35
  *
36
- * ## `summary` is the operation NAME, never a sentence
36
+ * ## `summary` is the method's `@summary` JSDoc tag — a short title, never a sentence (#1296)
37
37
  *
38
- * A docs theme titles the endpoint's page from `summary` and puts `description` in the body. Writing
39
- * the first sentence of the prose into `summary` therefore produces a sidebar of sentences and a page
40
- * whose heading repeats its own first line. The method name is what a reader is looking for, and it
41
- * is also what the generated client calls the method, so the two agree by construction.
38
+ * A docs theme titles the endpoint's page from `summary` and labels its sidebar with it, and puts
39
+ * `description` in the body. It used to be the bare method name, which put code identifiers in every
40
+ * heading. It is now the `@summary` line the author wrote — one line, at most 100 characters,
41
+ * REQUIRED on every published operation by {@link SummaryGuard} — and the tag is not part of
42
+ * `description`, so the page does not repeat its own heading. The code identifier stays published as
43
+ * `operationId`, which is what a generated client names the method. The same line is the MCP tool's
44
+ * `title`, so a partner's docs page and an agent's tool list name the endpoint identically.
42
45
  *
43
46
  * ## The MCP extensions ride HERE, on the operation
44
47
  *
@@ -107,7 +110,7 @@ class OperationRenderer {
107
110
  return new JsonObject_1.JsonObject()
108
111
  .set('operationId', this.operationIdOf(endpoint, contractName))
109
112
  .set('x-webpieces-authentication', endpoint.auth?.methods.map((method) => new JsonObject_1.JsonObject().set('kind', method.kind).set('arguments', method.argumentTexts)))
110
- .set('summary', endpoint.methodName)
113
+ .set('summary', endpoint.summary)
111
114
  .set('description', this.describe(endpoint))
112
115
  .set('tags', [tag])
113
116
  .set('requestBody', this.requestBody(endpoint, contractName))
@@ -191,7 +194,14 @@ class OperationRenderer {
191
194
  * a human declares, because it is a judgement about the world rather than a consequence of the
192
195
  * operation.
193
196
  *
194
- * ## There is no separate MCP description
197
+ * ## The title is the operation's `summary`, published as the Tool's `title` AND `annotations.title`
198
+ *
199
+ * `x-mcp-title` and `x-mcp-hints.title` carry the `@summary` line exactly as `tools/list` serves it:
200
+ * `Tool.title` for clients on the 2025-06-18+ spec and `annotations.title` (the block `x-mcp-hints`
201
+ * mirrors) for older clients and the Claude Connectors Directory (#1296). One source, so they cannot
202
+ * differ from the operation's own `summary`.
203
+ *
204
+ * ## There is no separate MCP description
195
205
  *
196
206
  * The agent reads the operation's `description` — the method's JSDoc — byte-identical to what the
197
207
  * partner reads. `x-mcp-description` appears ONLY when the author wrote an explicit `@mcp` JSDoc
@@ -204,7 +214,9 @@ class OperationRenderer {
204
214
  const hints = (0, core_util_1.mcpHintsForOperation)(this.operationOf(endpoint), endpoint.openWorld);
205
215
  return operation
206
216
  .set('x-mcp-tool', endpoint.mcpTool.name)
217
+ .set('x-mcp-title', endpoint.summary)
207
218
  .set('x-mcp-hints', new JsonObject_1.JsonObject()
219
+ .set('title', endpoint.summary)
208
220
  .set('readOnlyHint', hints.readOnlyHint)
209
221
  .set('destructiveHint', hints.destructiveHint)
210
222
  .set('idempotentHint', hints.idempotentHint)
@@ -1 +1 @@
1
- {"version":3,"file":"OperationRenderer.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/OperationRenderer.ts"],"names":[],"mappings":";;;AACA,oDAU8B;AAC9B,mDAA2D;AAC3D,iEAAmF;AAEnF,+CAA4C;AAC5C,sEAAmE;AAEnE,mEAAmE;AACnE,MAAM,WAAW,GAAG,8DAA8D,CAAC;AAEnF,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,GA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,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;;;;;OAKG;IACK,kBAAkB,CACtB,QAA4B,EAC5B,YAAoB,EACpB,MAAe;QAEf,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,WAAW,CAAC;IACvB,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;AAxTD,8CAwTC","sourcesContent":["import { DocumentedAuthMethod, DocumentedEndpoint } from '@webpieces/api-doc-model';\nimport {\n CLOUDTASKS,\n CRON,\n EXTERNAL,\n mcpHintsForOperation,\n POST,\n READ,\n RPC,\n WRITE,\n WRITE_IDEMPOTENT,\n} from '@webpieces/core-util';\nimport { JsonObject, JsonValue } from '../json/JsonObject';\nimport { ErrorResponseEntry, OperationIdStyle } 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/** 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 operation NAME, never a sentence\n *\n * A docs theme titles the endpoint's page from `summary` and puts `description` in the body. Writing\n * the first sentence of the prose into `summary` therefore produces a sidebar of sentences and a page\n * whose heading repeats its own first line. The method name is what a reader is looking for, and it\n * is also what the generated client calls the method, so the two agree by construction.\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\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 /** The manifest's `operationIds` — see {@link operationIdOf}. */\n private readonly operationIds: OperationIdStyle,\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.operationIds === OperationIdStyle.METHOD\n ? endpoint.methodName\n : `${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);\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`, which is the one fact about it a document cannot state\n * any other way. 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 webhook(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n ): JsonObject {\n const operation = this.common(endpoint, contractName, tag, contract);\n return this.withMcp(operation.set('x-webpieces-webhook', true), endpoint);\n }\n\n private common(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n ): JsonObject {\n return new JsonObject()\n .set('operationId', this.operationIdOf(endpoint, contractName))\n .set('x-webpieces-authentication', endpoint.auth?.methods.map((method: DocumentedAuthMethod) => new JsonObject().set('kind', method.kind).set('arguments', method.argumentTexts)))\n .set('summary', endpoint.methodName)\n .set('description', this.describe(endpoint))\n .set('tags', [tag])\n .set('requestBody', this.requestBody(endpoint, contractName))\n .set('responses', this.responses(endpoint, contractName, contract));\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.\n */\n private describe(endpoint: DocumentedEndpoint): string | undefined {\n const parts: string[] = [];\n const body = this.prose(endpoint.description);\n if (body !== undefined) {\n parts.push(body);\n }\n parts.push(this.retrySentence(endpoint));\n if (this.includeTrigger) {\n parts.push(this.triggerSentence(endpoint));\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.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) {\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 * ## 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(\n 'x-mcp-hints',\n new JsonObject()\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 * The request DTO as a body. Only for `POST`: OpenAPI gives a `GET` body no defined semantics and\n * most tooling drops it, so 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 (endpoint.httpMethod !== 'POST' || 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.type(endpoint.request, pointer)),\n ),\n );\n }\n\n private responses(\n endpoint: DocumentedEndpoint,\n contractName: string,\n contract: ResponseContract,\n ): JsonObject {\n const responses = new JsonObject();\n responses.set('200', this.success(endpoint, contractName, contract));\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 ): JsonObject {\n const isVoid = this.body.isVoid(endpoint.response);\n const response = new JsonObject()\n .set('description', this.successDescription(endpoint, contractName, isVoid))\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.type(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 keeps the derived\n * acknowledgement sentence — there is no body for `@returns` to describe. 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 ): 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 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":";;;AACA,oDAU8B;AAC9B,mDAA2D;AAC3D,iEAAmF;AAEnF,+CAA4C;AAC5C,sEAAmE;AAEnE,mEAAmE;AACnE,MAAM,WAAW,GAAG,8DAA8D,CAAC;AAEnF,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;IAIL;IAEA;IAEA;IAEA;IATJ,IAAI,GAAG,IAAI,yBAAW,EAAE,CAA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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;;;;;OAKG;IACK,kBAAkB,CACtB,QAA4B,EAC5B,YAAoB,EACpB,MAAe;QAEf,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,WAAW,CAAC;IACvB,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;AAjUD,8CAiUC","sourcesContent":["import { DocumentedAuthMethod, DocumentedEndpoint } from '@webpieces/api-doc-model';\nimport {\n CLOUDTASKS,\n CRON,\n EXTERNAL,\n mcpHintsForOperation,\n POST,\n READ,\n RPC,\n WRITE,\n WRITE_IDEMPOTENT,\n} from '@webpieces/core-util';\nimport { JsonObject, JsonValue } from '../json/JsonObject';\nimport { ErrorResponseEntry, OperationIdStyle } 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/** 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\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 /** The manifest's `operationIds` — see {@link operationIdOf}. */\n private readonly operationIds: OperationIdStyle,\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.operationIds === OperationIdStyle.METHOD\n ? endpoint.methodName\n : `${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);\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`, which is the one fact about it a document cannot state\n * any other way. 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 webhook(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n ): JsonObject {\n const operation = this.common(endpoint, contractName, tag, contract);\n return this.withMcp(operation.set('x-webpieces-webhook', true), endpoint);\n }\n\n private common(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n ): JsonObject {\n return new JsonObject()\n .set('operationId', this.operationIdOf(endpoint, contractName))\n .set('x-webpieces-authentication', endpoint.auth?.methods.map((method: DocumentedAuthMethod) => new JsonObject().set('kind', method.kind).set('arguments', method.argumentTexts)))\n .set('summary', endpoint.summary)\n .set('description', this.describe(endpoint))\n .set('tags', [tag])\n .set('requestBody', this.requestBody(endpoint, contractName))\n .set('responses', this.responses(endpoint, contractName, contract));\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.\n */\n private describe(endpoint: DocumentedEndpoint): string | undefined {\n const parts: string[] = [];\n const body = this.prose(endpoint.description);\n if (body !== undefined) {\n parts.push(body);\n }\n parts.push(this.retrySentence(endpoint));\n if (this.includeTrigger) {\n parts.push(this.triggerSentence(endpoint));\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.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) {\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 * The request DTO as a body. Only for `POST`: OpenAPI gives a `GET` body no defined semantics and\n * most tooling drops it, so 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 (endpoint.httpMethod !== 'POST' || 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.type(endpoint.request, pointer)),\n ),\n );\n }\n\n private responses(\n endpoint: DocumentedEndpoint,\n contractName: string,\n contract: ResponseContract,\n ): JsonObject {\n const responses = new JsonObject();\n responses.set('200', this.success(endpoint, contractName, contract));\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 ): JsonObject {\n const isVoid = this.body.isVoid(endpoint.response);\n const response = new JsonObject()\n .set('description', this.successDescription(endpoint, contractName, isVoid))\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.type(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 keeps the derived\n * acknowledgement sentence — there is no body for `@returns` to describe. 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 ): 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 ACKNOWLEDGE;\n }\n\n private prose(text: string | undefined): string | undefined {\n return text === undefined || text.trim() === '' ? undefined : text;\n }\n}\n"]}
@@ -0,0 +1,24 @@
1
+ import { ContractModel } from './GenerationInputs';
2
+ /**
3
+ * The refusal for a published operation whose method has no usable `@summary` (#1296).
4
+ *
5
+ * The summary is the endpoint's short title, and it has ONE source: the `@summary` JSDoc tag. It is
6
+ * published as the OpenAPI operation's `summary` — the page heading and sidebar label a docs site
7
+ * shows — and, for a tool, as MCP `Tool.title` AND `annotations.title`. It used to be the bare method
8
+ * name in OpenAPI and a second, decorator-argument title in MCP, and the two drifted; the decorator
9
+ * argument is gone. A missing, multi-line or over-long (> {@link EndpointSummary.MAX_LENGTH}
10
+ * characters) summary is refused rather than papered over, and every offender is named in ONE run,
11
+ * before anything is rendered — the same shape as {@link MissingReturnsGuard}. There is deliberately
12
+ * no flag to switch it off: projects that predate it fail until they add the line.
13
+ *
14
+ * ## What it judges
15
+ *
16
+ * Every operation EVERY document of the run would publish — `full-private-openapi`, `public-openapi`
17
+ * and the MCP output (`mcp-openapi.json` and the `mcp-<Contract>-tools.json` catalogs) — served routes
18
+ * and webhooks alike.
19
+ */
20
+ export declare class SummaryGuard {
21
+ /** Refuse when any selected operation of `contracts` has no usable `@summary`. */
22
+ refuse(contracts: readonly ContractModel[], manifestPath: string): void;
23
+ private collect;
24
+ }
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SummaryGuard = void 0;
4
+ const api_doc_model_1 = require("@webpieces/api-doc-model");
5
+ const OpenApiGenerationError_1 = require("../OpenApiGenerationError");
6
+ const DocumentSelection_1 = require("./DocumentSelection");
7
+ /**
8
+ * The refusal for a published operation whose method has no usable `@summary` (#1296).
9
+ *
10
+ * The summary is the endpoint's short title, and it has ONE source: the `@summary` JSDoc tag. It is
11
+ * published as the OpenAPI operation's `summary` — the page heading and sidebar label a docs site
12
+ * shows — and, for a tool, as MCP `Tool.title` AND `annotations.title`. It used to be the bare method
13
+ * name in OpenAPI and a second, decorator-argument title in MCP, and the two drifted; the decorator
14
+ * argument is gone. A missing, multi-line or over-long (> {@link EndpointSummary.MAX_LENGTH}
15
+ * characters) summary is refused rather than papered over, and every offender is named in ONE run,
16
+ * before anything is rendered — the same shape as {@link MissingReturnsGuard}. There is deliberately
17
+ * no flag to switch it off: projects that predate it fail until they add the line.
18
+ *
19
+ * ## What it judges
20
+ *
21
+ * Every operation EVERY document of the run would publish — `full-private-openapi`, `public-openapi`
22
+ * and the MCP output (`mcp-openapi.json` and the `mcp-<Contract>-tools.json` catalogs) — served routes
23
+ * and webhooks alike.
24
+ */
25
+ class SummaryGuard {
26
+ /** Refuse when any selected operation of `contracts` has no usable `@summary`. */
27
+ refuse(contracts, manifestPath) {
28
+ const offenders = new Map();
29
+ for (const selection of DocumentSelection_1.DocumentSelection.all()) {
30
+ for (const contract of contracts) {
31
+ if (selection.acceptsContract(contract.model)) {
32
+ this.collect(contract, selection, offenders);
33
+ }
34
+ }
35
+ }
36
+ if (offenders.size === 0) {
37
+ return;
38
+ }
39
+ throw new OpenApiGenerationError_1.OpenApiGenerationError(`${offenders.size} published operation(s) have no usable @summary, so they have no short ` +
40
+ 'title to publish as the OpenAPI summary or the MCP tool title', manifestPath, api_doc_model_1.EndpointSummary.cure(), Array.from(offenders.values()));
41
+ }
42
+ collect(contract, selection, offenders) {
43
+ const model = contract.model;
44
+ for (const endpoint of model.endpoints) {
45
+ if (!selection.acceptsEndpoint(endpoint)) {
46
+ continue;
47
+ }
48
+ const problem = api_doc_model_1.EndpointSummary.problemWith(endpoint.summary);
49
+ const name = `${model.contractName}.${endpoint.methodName}`;
50
+ if (problem !== undefined && !offenders.has(name)) {
51
+ offenders.set(name, `${name} ${problem} (${contract.file})`);
52
+ }
53
+ }
54
+ }
55
+ }
56
+ exports.SummaryGuard = SummaryGuard;
57
+ //# sourceMappingURL=SummaryGuard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SummaryGuard.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/SummaryGuard.ts"],"names":[],"mappings":";;;AAAA,4DAA2D;AAC3D,sEAAmE;AAEnE,2DAAwD;AAExD;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAa,YAAY;IACrB,kFAAkF;IAClF,MAAM,CAAC,SAAmC,EAAE,YAAoB;QAC5D,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC5C,KAAK,MAAM,SAAS,IAAI,qCAAiB,CAAC,GAAG,EAAE,EAAE,CAAC;YAC9C,KAAK,MAAM,QAAQ,IA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OpenApiGenerationError';\nimport { ContractModel } from './GenerationInputs';\nimport { DocumentSelection } from './DocumentSelection';\n\n/**\n * The refusal for a published operation whose method has no usable `@summary` (#1296).\n *\n * The summary is the endpoint's short title, and it has ONE source: the `@summary` JSDoc tag. It is\n * published as the OpenAPI operation's `summary` — the page heading and sidebar label a docs site\n * shows — and, for a tool, as MCP `Tool.title` AND `annotations.title`. It used to be the bare method\n * name in OpenAPI and a second, decorator-argument title in MCP, and the two drifted; the decorator\n * argument is gone. A missing, multi-line or over-long (> {@link EndpointSummary.MAX_LENGTH}\n * characters) summary is refused rather than papered over, and every offender is named in ONE run,\n * before anything is rendered — the same shape as {@link MissingReturnsGuard}. There is deliberately\n * no flag to switch it off: projects that predate it fail until they add the line.\n *\n * ## What it judges\n *\n * Every operation EVERY document of the run would publish — `full-private-openapi`, `public-openapi`\n * and the MCP output (`mcp-openapi.json` and the `mcp-<Contract>-tools.json` catalogs) — served routes\n * and webhooks alike.\n */\nexport class SummaryGuard {\n /** Refuse when any selected operation of `contracts` has no usable `@summary`. */\n refuse(contracts: readonly ContractModel[], manifestPath: string): void {\n const offenders = new Map<string, string>();\n for (const selection of DocumentSelection.all()) {\n for (const contract of contracts) {\n if (selection.acceptsContract(contract.model)) {\n this.collect(contract, selection, offenders);\n }\n }\n }\n if (offenders.size === 0) {\n return;\n }\n throw new OpenApiGenerationError(\n `${offenders.size} published operation(s) have no usable @summary, so they have no short ` +\n 'title to publish as the OpenAPI summary or the MCP tool title',\n manifestPath,\n EndpointSummary.cure(),\n Array.from(offenders.values()),\n );\n }\n\n private collect(\n contract: ContractModel,\n selection: DocumentSelection,\n offenders: Map<string, string>,\n ): void {\n const model = contract.model;\n for (const endpoint of model.endpoints) {\n if (!selection.acceptsEndpoint(endpoint)) {\n continue;\n }\n const problem = EndpointSummary.problemWith(endpoint.summary);\n const name = `${model.contractName}.${endpoint.methodName}`;\n if (problem !== undefined && !offenders.has(name)) {\n offenders.set(name, `${name} ${problem} (${contract.file})`);\n }\n }\n }\n}\n"]}
package/src/index.d.ts CHANGED
@@ -14,7 +14,7 @@ export type { JsonValue } from './json/JsonObject';
14
14
  export { JsonWriter } from './json/JsonWriter';
15
15
  export { YamlWriter } from './json/YamlWriter';
16
16
  export { YamlReader } from './json/YamlReader';
17
- export { ApiEntry, ComponentsManifest, ErrorResponseEntry, ErrorsEntry, OpenApiManifest, OperationIdStyle, ResponseHeaderEntry, ServerEntry, } from './manifest/OpenApiManifest';
17
+ export { ApiEntry, ComponentsManifest, ErrorResponseEntry, ErrorsEntry, MANIFEST_SUMMARY_MAX_LENGTH, OpenApiManifest, OperationIdStyle, ResponseHeaderEntry, ServerEntry, } from './manifest/OpenApiManifest';
18
18
  export { JsonReader } from './manifest/JsonReader';
19
19
  export { ManifestLoader } from './manifest/ManifestLoader';
20
20
  export { ComponentsInputs, ContractModel, GeneratedDocument, GeneratedDocuments, GenerationInputs, ResolvedResponseHeader, } from './generate/GenerationInputs';
package/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.WpOpenApiMain = exports.USAGE = exports.OpenApiCli = exports.CliResult = exports.GeneratedArtifact = exports.ArtifactWriter = exports.InputsLoader = exports.ForeignFailure = exports.SecurityDeriver = exports.LocatedComponents = exports.ComponentsLocator = exports.UpstreamComponentsIndex = exports.PublishedComponents = exports.MissingComponents = exports.SplitPlacement = exports.DiscoveryPlacement = exports.ComponentsReference = exports.BundledPlacement = exports.BundledNames = exports.UnmappedField = exports.SchemaRenderer = exports.ResponseContract = exports.OperationRenderer = exports.OpenApiGenerator = exports.OPERATION_SEMANTICS = exports.INTERNAL_ONLY_LINE = exports.DocumentSelection = exports.ResolvedResponseHeader = exports.GenerationInputs = exports.GeneratedDocuments = exports.GeneratedDocument = exports.ContractModel = exports.ComponentsInputs = exports.ManifestLoader = exports.JsonReader = exports.ServerEntry = exports.ResponseHeaderEntry = exports.OperationIdStyle = exports.OpenApiManifest = exports.ErrorsEntry = exports.ErrorResponseEntry = exports.ComponentsManifest = exports.ApiEntry = exports.YamlReader = exports.YamlWriter = exports.JsonWriter = exports.JsonObject = exports.OpenApiGenerationError = void 0;
3
+ exports.WpOpenApiMain = exports.USAGE = exports.OpenApiCli = exports.CliResult = exports.GeneratedArtifact = exports.ArtifactWriter = exports.InputsLoader = exports.ForeignFailure = exports.SecurityDeriver = exports.LocatedComponents = exports.ComponentsLocator = exports.UpstreamComponentsIndex = exports.PublishedComponents = exports.MissingComponents = exports.SplitPlacement = exports.DiscoveryPlacement = exports.ComponentsReference = exports.BundledPlacement = exports.BundledNames = exports.UnmappedField = exports.SchemaRenderer = exports.ResponseContract = exports.OperationRenderer = exports.OpenApiGenerator = exports.OPERATION_SEMANTICS = exports.INTERNAL_ONLY_LINE = exports.DocumentSelection = exports.ResolvedResponseHeader = exports.GenerationInputs = exports.GeneratedDocuments = exports.GeneratedDocument = exports.ContractModel = exports.ComponentsInputs = exports.ManifestLoader = exports.JsonReader = exports.ServerEntry = exports.ResponseHeaderEntry = exports.OperationIdStyle = exports.OpenApiManifest = exports.MANIFEST_SUMMARY_MAX_LENGTH = exports.ErrorsEntry = exports.ErrorResponseEntry = exports.ComponentsManifest = exports.ApiEntry = exports.YamlReader = exports.YamlWriter = exports.JsonWriter = exports.JsonObject = exports.OpenApiGenerationError = void 0;
4
4
  /**
5
5
  * `@webpieces/openapi-generator` — render an `ApiDocModel` to OpenAPI 3.1.0.
6
6
  *
@@ -26,6 +26,7 @@ Object.defineProperty(exports, "ApiEntry", { enumerable: true, get: function ()
26
26
  Object.defineProperty(exports, "ComponentsManifest", { enumerable: true, get: function () { return OpenApiManifest_1.ComponentsManifest; } });
27
27
  Object.defineProperty(exports, "ErrorResponseEntry", { enumerable: true, get: function () { return OpenApiManifest_1.ErrorResponseEntry; } });
28
28
  Object.defineProperty(exports, "ErrorsEntry", { enumerable: true, get: function () { return OpenApiManifest_1.ErrorsEntry; } });
29
+ Object.defineProperty(exports, "MANIFEST_SUMMARY_MAX_LENGTH", { enumerable: true, get: function () { return OpenApiManifest_1.MANIFEST_SUMMARY_MAX_LENGTH; } });
29
30
  Object.defineProperty(exports, "OpenApiManifest", { enumerable: true, get: function () { return OpenApiManifest_1.OpenApiManifest; } });
30
31
  Object.defineProperty(exports, "OperationIdStyle", { enumerable: true, get: function () { return OpenApiManifest_1.OperationIdStyle; } });
31
32
  Object.defineProperty(exports, "ResponseHeaderEntry", { enumerable: true, get: function () { return OpenApiManifest_1.ResponseHeaderEntry; } });
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/docs/openapi-generator/src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,gDAA+C;AAAtC,wGAAA,UAAU,OAAA;AAEnB,gDAA+C;AAAtC,wGAAA,UAAU,OAAA;AACnB,gDAA+C;AAAtC,wGAAA,UAAU,OAAA;AACnB,gDAA+C;AAAtC,wGAAA,UAAU,OAAA;AACnB,8DASoC;AARhC,2GAAA,QAAQ,OAAA;AACR,qHAAA,kBAAkB,OAAA;AAClB,qHAAA,kBAAkB,OAAA;AAClB,8GAAA,WAAW,OAAA;AACX,kHAAA,eAAe,OAAA;AACf,mHAAA,gBAAgB,OAAA;AAChB,sHAAA,mBAAmB,OAAA;AACnB,8GAAA,WAAW,OAAA;AAEf,oDAAmD;AAA1C,wGAAA,UAAU,OAAA;AACnB,4DAA2D;AAAlD,gHAAA,cAAc,OAAA;AACvB,gEAOqC;AANjC,oHAAA,gBAAgB,OAAA;AAChB,iHAAA,aAAa,OAAA;AACb,qHAAA,iBAAiB,OAAA;AACjB,sHAAA,kBAAkB,OAAA;AAClB,oHAAA,gBAAgB,OAAA;AAChB,0HAAA,sBAAsB,OAAA;AAE1B,kEAIsC;AAHlC,sHAAA,iBAAiB,OAAA;AACjB,uHAAA,kBAAkB,OAAA;AAClB,wHAAA,mBAAmB,OAAA;AAEvB,gEAA+D;AAAtD,oHAAA,gBAAgB,OAAA;AACzB,kEAAmF;AAA1E,sHAAA,iBAAiB,OAAA;AAAE,qHAAA,gBAAgB,OAAA;AAC5C,4DAA0E;AAAjE,gHAAA,cAAc,OAAA;AAAE,+GAAA,aAAa,OAAA;AACtC,8DAMoC;AALhC,+GAAA,YAAY,OAAA;AACZ,mHAAA,gBAAgB,OAAA;AAChB,sHAAA,mBAAmB,OAAA;AACnB,qHAAA,kBAAkB,OAAA;AAClB,iHAAA,cAAc,OAAA;AAGlB,oEAIuC;AAHnC,uHAAA,iBAAiB,OAAA;AACjB,yHAAA,mBAAmB,OAAA;AACnB,6HAAA,uBAAuB,OAAA;AAE3B,8DAAgF;AAAvE,sHAAA,iBAAiB,OAAA;AAAE,sHAAA,iBAAiB,OAAA;AAC7C,8DAA6D;AAApD,kHAAA,eAAe,OAAA;AACxB,wDAAuD;AAA9C,gHAAA,cAAc,OAAA;AACvB,oDAAmD;AAA1C,4GAAA,YAAY,OAAA;AACrB,wDAA0E;AAAjE,gHAAA,cAAc,OAAA;AAAE,mHAAA,iBAAiB,OAAA;AAE1C,+CAAgE;AAAvD,uGAAA,SAAS,OAAA;AAAE,wGAAA,UAAU,OAAA;AAAE,mGAAA,KAAK,OAAA;AACrC,qDAAoD;AAA3C,8GAAA,aAAa,OAAA","sourcesContent":["/**\n * `@webpieces/openapi-generator` — render an `ApiDocModel` to OpenAPI 3.1.0.\n *\n * ONE generation pass produces TWO documents: the CANONICAL internal one, which carries every\n * operation including hidden ones plus the `x-mcp-*` extensions, and the CUSTOMER one, from which a\n * hidden endpoint is absent entirely. They are byte-identical when nothing is hidden, which is the\n * property that makes hiding reviewable — see `responsibilities.md`.\n *\n * It ships the `wp-openapi` bin, and depends on `typescript` and `@webpieces/api-doc-model` alone.\n */\nexport { OpenApiGenerationError } from './OpenApiGenerationError';\nexport { JsonObject } from './json/JsonObject';\nexport type { JsonValue } from './json/JsonObject';\nexport { JsonWriter } from './json/JsonWriter';\nexport { YamlWriter } from './json/YamlWriter';\nexport { YamlReader } from './json/YamlReader';\nexport {\n ApiEntry,\n ComponentsManifest,\n ErrorResponseEntry,\n ErrorsEntry,\n OpenApiManifest,\n OperationIdStyle,\n ResponseHeaderEntry,\n ServerEntry,\n} from './manifest/OpenApiManifest';\nexport { JsonReader } from './manifest/JsonReader';\nexport { ManifestLoader } from './manifest/ManifestLoader';\nexport {\n ComponentsInputs,\n ContractModel,\n GeneratedDocument,\n GeneratedDocuments,\n GenerationInputs,\n ResolvedResponseHeader,\n} from './generate/GenerationInputs';\nexport {\n DocumentSelection,\n INTERNAL_ONLY_LINE,\n OPERATION_SEMANTICS,\n} from './generate/DocumentSelection';\nexport { OpenApiGenerator } from './generate/OpenApiGenerator';\nexport { OperationRenderer, ResponseContract } from './generate/OperationRenderer';\nexport { SchemaRenderer, UnmappedField } from './generate/SchemaRenderer';\nexport {\n BundledNames,\n BundledPlacement,\n ComponentsReference,\n DiscoveryPlacement,\n SplitPlacement,\n} from './generate/SchemaPlacement';\nexport type { SchemaPlacement } from './generate/SchemaPlacement';\nexport {\n MissingComponents,\n PublishedComponents,\n UpstreamComponentsIndex,\n} from './generate/UpstreamComponents';\nexport { ComponentsLocator, LocatedComponents } from './load/ComponentsLocator';\nexport { SecurityDeriver } from './generate/SecurityDeriver';\nexport { ForeignFailure } from './load/ForeignFailure';\nexport { InputsLoader } from './load/InputsLoader';\nexport { ArtifactWriter, GeneratedArtifact } from './emit/ArtifactWriter';\nexport type { OutputFormat } from './emit/ArtifactWriter';\nexport { CliResult, OpenApiCli, USAGE } from './cli/OpenApiCli';\nexport { WpOpenApiMain } from './cli/WpOpenApiMain';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/docs/openapi-generator/src/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;GASG;AACH,mEAAkE;AAAzD,gIAAA,sBAAsB,OAAA;AAC/B,gDAA+C;AAAtC,wGA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sHAAA,iBAAiB,OAAA;AAC7C,8DAA6D;AAApD,kHAAA,eAAe,OAAA;AACxB,wDAAuD;AAA9C,gHAAA,cAAc,OAAA;AACvB,oDAAmD;AAA1C,4GAAA,YAAY,OAAA;AACrB,wDAA0E;AAAjE,gHAAA,cAAc,OAAA;AAAE,mHAAA,iBAAiB,OAAA;AAE1C,+CAAgE;AAAvD,uGAAA,SAAS,OAAA;AAAE,wGAAA,UAAU,OAAA;AAAE,mGAAA,KAAK,OAAA;AACrC,qDAAoD;AAA3C,8GAAA,aAAa,OAAA","sourcesContent":["/**\n * `@webpieces/openapi-generator` — render an `ApiDocModel` to OpenAPI 3.1.0.\n *\n * ONE generation pass produces TWO documents: the CANONICAL internal one, which carries every\n * operation including hidden ones plus the `x-mcp-*` extensions, and the CUSTOMER one, from which a\n * hidden endpoint is absent entirely. They are byte-identical when nothing is hidden, which is the\n * property that makes hiding reviewable — see `responsibilities.md`.\n *\n * It ships the `wp-openapi` bin, and depends on `typescript` and `@webpieces/api-doc-model` alone.\n */\nexport { OpenApiGenerationError } from './OpenApiGenerationError';\nexport { JsonObject } from './json/JsonObject';\nexport type { JsonValue } from './json/JsonObject';\nexport { JsonWriter } from './json/JsonWriter';\nexport { YamlWriter } from './json/YamlWriter';\nexport { YamlReader } from './json/YamlReader';\nexport {\n ApiEntry,\n ComponentsManifest,\n ErrorResponseEntry,\n ErrorsEntry,\n MANIFEST_SUMMARY_MAX_LENGTH,\n OpenApiManifest,\n OperationIdStyle,\n ResponseHeaderEntry,\n ServerEntry,\n} from './manifest/OpenApiManifest';\nexport { JsonReader } from './manifest/JsonReader';\nexport { ManifestLoader } from './manifest/ManifestLoader';\nexport {\n ComponentsInputs,\n ContractModel,\n GeneratedDocument,\n GeneratedDocuments,\n GenerationInputs,\n ResolvedResponseHeader,\n} from './generate/GenerationInputs';\nexport {\n DocumentSelection,\n INTERNAL_ONLY_LINE,\n OPERATION_SEMANTICS,\n} from './generate/DocumentSelection';\nexport { OpenApiGenerator } from './generate/OpenApiGenerator';\nexport { OperationRenderer, ResponseContract } from './generate/OperationRenderer';\nexport { SchemaRenderer, UnmappedField } from './generate/SchemaRenderer';\nexport {\n BundledNames,\n BundledPlacement,\n ComponentsReference,\n DiscoveryPlacement,\n SplitPlacement,\n} from './generate/SchemaPlacement';\nexport type { SchemaPlacement } from './generate/SchemaPlacement';\nexport {\n MissingComponents,\n PublishedComponents,\n UpstreamComponentsIndex,\n} from './generate/UpstreamComponents';\nexport { ComponentsLocator, LocatedComponents } from './load/ComponentsLocator';\nexport { SecurityDeriver } from './generate/SecurityDeriver';\nexport { ForeignFailure } from './load/ForeignFailure';\nexport { InputsLoader } from './load/InputsLoader';\nexport { ArtifactWriter, GeneratedArtifact } from './emit/ArtifactWriter';\nexport type { OutputFormat } from './emit/ArtifactWriter';\nexport { CliResult, OpenApiCli, USAGE } from './cli/OpenApiCli';\nexport { WpOpenApiMain } from './cli/WpOpenApiMain';\n"]}
@@ -19,6 +19,12 @@ export declare class ManifestLoader {
19
19
  private read;
20
20
  /** @param manifestPath absolute path to a CONTRACT library's `openapi.manifest.json`. */
21
21
  load(manifestPath: string): OpenApiManifest;
22
+ /**
23
+ * REQUIRED (#1296): the API's one-line summary, published as `info.summary`. A heading's subtitle
24
+ * and a directory listing's one-liner, so a second line or a paragraph is refused rather than
25
+ * published.
26
+ */
27
+ private summary;
22
28
  /**
23
29
  * OPTIONAL, defaulting to `"contract_method"` (#1283) — the spelling every release before #1270
24
30
  * published, and the one that is unique by construction, so a new contract gets the safe scheme
@@ -87,7 +87,31 @@ class ManifestLoader {
87
87
  throw new OpenApiGenerationError_1.OpenApiGenerationError(`this is a "kind": "${COMPONENTS}" manifest, not a contract manifest`, manifestPath, 'Render it as a components document (wp-openapi does so on its own when it reads the kind).');
88
88
  }
89
89
  const raw = this.read(manifestPath);
90
- return new OpenApiManifest_1.OpenApiManifest(raw.string('title'), raw.string('version'), this.servers(raw), raw.optionalString('descriptionFile'), this.apis(raw), raw.strings('securitySchemeNames'), this.errors(raw), this.responseHeaders(raw), this.schemaNames(raw), this.operationIds(raw));
90
+ return new OpenApiManifest_1.OpenApiManifest(raw.string('title'), this.summary(raw), raw.string('version'), this.servers(raw), raw.optionalString('descriptionFile'), this.apis(raw), raw.strings('securitySchemeNames'), this.errors(raw), this.responseHeaders(raw), this.schemaNames(raw), this.operationIds(raw));
91
+ }
92
+ /**
93
+ * REQUIRED (#1296): the API's one-line summary, published as `info.summary`. A heading's subtitle
94
+ * and a directory listing's one-liner, so a second line or a paragraph is refused rather than
95
+ * published.
96
+ */
97
+ summary(raw) {
98
+ const cure = `Give "summary" one line of at most ${OpenApiManifest_1.MANIFEST_SUMMARY_MAX_LENGTH} characters saying what the API ` +
99
+ 'lets a caller do, e.g. "summary": "Read and cancel the orders placed at your stores." It is ' +
100
+ "published as info.summary under the API's title; the long form stays in descriptionFile.";
101
+ if (!raw.has('summary')) {
102
+ throw new OpenApiGenerationError_1.OpenApiGenerationError("'summary' is missing", raw.where, cure);
103
+ }
104
+ const value = raw.optionalString('summary');
105
+ if (value === undefined || value.trim() === '') {
106
+ throw new OpenApiGenerationError_1.OpenApiGenerationError("'summary' is not a non-empty string", raw.where, cure);
107
+ }
108
+ if (/[\r\n]/.test(value)) {
109
+ throw new OpenApiGenerationError_1.OpenApiGenerationError("'summary' spans more than one line", raw.where, cure);
110
+ }
111
+ if (value.length > OpenApiManifest_1.MANIFEST_SUMMARY_MAX_LENGTH) {
112
+ throw new OpenApiGenerationError_1.OpenApiGenerationError(`'summary' is ${value.length} characters, over the ${OpenApiManifest_1.MANIFEST_SUMMARY_MAX_LENGTH}-character limit`, raw.where, cure);
113
+ }
114
+ return value;
91
115
  }
92
116
  /**
93
117
  * OPTIONAL, defaulting to `"contract_method"` (#1283) — the spelling every release before #1270
@@ -1 +1 @@
1
- {"version":3,"file":"ManifestLoader.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/manifest/ManifestLoader.ts"],"names":[],"mappings":";;;;AAAA,o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CAAC,WAAW,CAAC;aACpB,GAAG,CACA,CAAC,QAAoB,EAAE,EAAE,CACrB,IAAI,oCAAkB,CAClB,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,EACzB,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,EAC9B,QAAQ,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,KAAK,CACpD,CACR,CACR,CAAC;IACN,CAAC;IAEO,eAAe,CAAC,GAAe;QACnC,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,MAAkB,EAAE,EAAE;YAC7D,0FAA0F;YAC1F,0FAA0F;YAC1F,8DAA8D;YAC9D,IAAI,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAAE,CAAC;gBACpC,MAAM,IAAI,+CAAsB,CAC5B,IAAI,qBAAqB,gEAAgE,EACzF,GAAG,CAAC,KAAK,EACT,YAAY,qBAAqB,uDAAuD;oBACpF,kFAAkF;oBAClF,8FAA8F,CACrG,CAAC;YACN,CAAC;YACD,OAAO,IAAI,qCAAmB,CAC1B,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EACtB,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAC3B,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,EACpC,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CACrC,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;IAED,+EAA+E;IAC/E,OAAO,CAAC,YAAoB,EAAE,QAAgB;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACJ;AA3ND,wCA2NC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\nimport { JsonReader } from './JsonReader';\nimport { SchemaNameEntry } from '@webpieces/api-doc-model';\nimport {\n ApiEntry,\n ComponentsManifest,\n ErrorResponseEntry,\n ErrorsEntry,\n OpenApiManifest,\n OperationIdStyle,\n ResponseHeaderEntry,\n ServerEntry,\n} from './OpenApiManifest';\n\n/** The only `kind` an api entry may declare. Anything else is a typo, and typos are refused. */\nconst WEBHOOK = 'webhook';\n\n/**\n * The only `kind` a MANIFEST may declare (#1058): a DTO library's components-only document. A\n * manifest with no `kind` is a contract library's, exactly as before.\n */\nconst COMPONENTS = 'components';\n\n/** The deleted string-constant spelling of a response header's name (#1249). */\nconst RETIRED_NAME_CONSTANT = 'nameConstant';\n\n/** Keys a components manifest must not carry, each with why — a contract-manifest key is a mix-up. */\nconst NOT_IN_COMPONENTS: ReadonlyMap<string, string> = new Map<string, string>([\n ['apis', 'a components document has no paths; list the library\\'s entry files in \"entries\"'],\n [\n 'version',\n \"a library document's info.version is the package version, read from its package.json\",\n ],\n ['servers', 'a components document has no operations to serve'],\n ['errors', 'the error contract belongs to a contract document'],\n ['responseHeaders', 'response headers belong to a contract document'],\n ['securitySchemeNames', 'security belongs to a contract document'],\n ['operationIds', 'a components document has no operations to name'],\n]);\n\n/** Every spelling `operationIds` accepts, in the order the refusal lists them. */\nconst OPERATION_ID_STYLES: readonly OperationIdStyle[] = [\n OperationIdStyle.CONTRACT_METHOD,\n OperationIdStyle.METHOD,\n];\n\n/**\n * Read `openapi.manifest.json` into {@link OpenApiManifest}.\n *\n * It deals only in {@link JsonReader}, which is where the \"came off disk, not yet checked\" state is\n * concentrated — so nothing in this file, or anywhere downstream, handles an unnarrowed value.\n *\n * Every rejection is a HARD FAILURE naming the field. A published document quietly missing a section\n * is indistinguishable, from outside, from an API that genuinely has no error contract.\n */\nexport class ManifestLoader {\n /**\n * True for a DTO library's `\"kind\": \"components\"` manifest, false for a contract library's (no\n * `kind`). Any other `kind` is refused: a typo there would otherwise render the wrong document.\n */\n isComponents(manifestPath: string): boolean {\n const kind = this.read(manifestPath).optionalString('kind');\n if (kind === undefined) {\n return false;\n }\n if (kind !== COMPONENTS) {\n throw new OpenApiGenerationError(\n `unknown manifest kind '${kind}'`,\n manifestPath,\n `The only manifest kind is \"${COMPONENTS}\", for a DTO library's components document. ` +\n \"Leave it out for a contract library's manifest.\",\n );\n }\n return true;\n }\n\n /** A DTO library's components manifest. See {@link ComponentsManifest}. */\n loadComponents(manifestPath: string): ComponentsManifest {\n const raw = this.read(manifestPath);\n for (const key of NOT_IN_COMPONENTS.keys()) {\n const why = NOT_IN_COMPONENTS.get(key)!;\n if (raw.has(key)) {\n throw new OpenApiGenerationError(\n `a \"kind\": \"${COMPONENTS}\" manifest declares '${key}'`,\n raw.where,\n `Delete it — ${why}.`,\n );\n }\n }\n const entries = raw.strings('entries');\n if (entries.length === 0) {\n throw new OpenApiGenerationError(\n \"'entries' is empty\",\n raw.where,\n 'Name the library\\'s entry files, e.g. \"entries\": [\"src/index.ts\"]; the document holds every type they export.',\n );\n }\n return new ComponentsManifest(raw.string('title'), entries, this.schemaNames(raw));\n }\n\n private read(manifestPath: string): JsonReader {\n if (!fs.existsSync(manifestPath)) {\n throw new OpenApiGenerationError(\n 'no manifest at this path',\n manifestPath,\n 'Pass --manifest pointing at an openapi.manifest.json that exists.',\n );\n }\n return JsonReader.parseFile(fs.readFileSync(manifestPath, 'utf8'), manifestPath);\n }\n\n /** @param manifestPath absolute path to a CONTRACT library's `openapi.manifest.json`. */\n load(manifestPath: string): OpenApiManifest {\n if (this.isComponents(manifestPath)) {\n throw new OpenApiGenerationError(\n `this is a \"kind\": \"${COMPONENTS}\" manifest, not a contract manifest`,\n manifestPath,\n 'Render it as a components document (wp-openapi does so on its own when it reads the kind).',\n );\n }\n const raw = this.read(manifestPath);\n return new OpenApiManifest(\n raw.string('title'),\n raw.string('version'),\n this.servers(raw),\n raw.optionalString('descriptionFile'),\n this.apis(raw),\n raw.strings('securitySchemeNames'),\n this.errors(raw),\n this.responseHeaders(raw),\n this.schemaNames(raw),\n this.operationIds(raw),\n );\n }\n\n /**\n * OPTIONAL, defaulting to `\"contract_method\"` (#1283) — the spelling every release before #1270\n * published, and the one that is unique by construction, so a new contract gets the safe scheme\n * without writing anything. `\"method\"` is the opt-in for a document that already published bare\n * names. A value that is present but is neither choice is still refused.\n */\n private operationIds(raw: JsonReader): OperationIdStyle {\n if (!raw.has('operationIds')) {\n return OperationIdStyle.CONTRACT_METHOD;\n }\n const value = raw.optionalString('operationIds');\n const style = OPERATION_ID_STYLES.find((each: OperationIdStyle) => each === value);\n if (style !== undefined) {\n return style;\n }\n const choices = OPERATION_ID_STYLES.map((each: OperationIdStyle) => `\"${each}\"`).join(' or ');\n throw new OpenApiGenerationError(\n value === undefined\n ? \"'operationIds' is present but is not a non-empty string\"\n : `unknown operationIds style '${value}'`,\n raw.where,\n `Set \"operationIds\" to ${choices}, or omit it for \"${OperationIdStyle.CONTRACT_METHOD}\". ` +\n `\"${OperationIdStyle.CONTRACT_METHOD}\" publishes OrdersApi_fetchOrders; ` +\n `\"${OperationIdStyle.METHOD}\" publishes fetchOrders and fails generation when two ` +\n 'operations of one document would share it. Generated partner clients name their ' +\n 'methods from it, so changing it renames every method in their SDKs.',\n );\n }\n\n private servers(raw: JsonReader): readonly ServerEntry[] {\n return raw\n .objects('servers')\n .map(\n (server: JsonReader) =>\n new ServerEntry(server.string('url'), server.optionalString('description')),\n );\n }\n\n private schemaNames(raw: JsonReader): readonly SchemaNameEntry[] {\n return raw.objects('schemaNames').map((entry: JsonReader) => {\n const paths = entry.strings('paths');\n const suffixes = entry.strings('stripSuffixes');\n if (\n paths.length === 0 ||\n paths.some((glob: string) => glob.trim() === '') ||\n !entry.has('stripSuffixes') ||\n suffixes.some((suffix: string) => suffix.length === 0)\n ) {\n throw new OpenApiGenerationError(\n 'invalid schemaNames entry',\n raw.where,\n 'Provide non-empty paths and an explicit stripSuffixes array of non-empty suffixes (or [] to preserve names). First matching path wins.',\n );\n }\n return new SchemaNameEntry(\n paths.map((glob: string) => path.resolve(path.dirname(raw.where), glob)),\n suffixes,\n );\n });\n }\n\n private apis(raw: JsonReader): readonly ApiEntry[] {\n const entries = raw\n .objects('apis')\n .map(\n (api: JsonReader) =>\n new ApiEntry(\n api.string('entry'),\n api.string('tag'),\n api.optionalString('kind'),\n ),\n );\n if (entries.length === 0) {\n throw new OpenApiGenerationError(\n \"'apis' is empty\",\n raw.where,\n 'List at least one contract; a document with no operations publishes nothing.',\n );\n }\n for (const entry of entries) {\n if (entry.kind !== undefined && entry.kind !== WEBHOOK) {\n throw new OpenApiGenerationError(\n `unknown api kind '${entry.kind}' on '${entry.entry}'`,\n raw.where,\n `The only declared kind is \"${WEBHOOK}\". Leave it out for an ordinary contract.`,\n );\n }\n }\n return entries;\n }\n\n private errors(raw: JsonReader): ErrorsEntry | undefined {\n const errors = raw.object('errors');\n if (errors === undefined) {\n return undefined;\n }\n return new ErrorsEntry(\n errors.string('entry'),\n errors.string('type'),\n errors\n .objects('responses')\n .map(\n (response: JsonReader) =>\n new ErrorResponseEntry(\n response.string('status'),\n response.string('description'),\n response.optionalBoolean('requiresAuth') ?? false,\n ),\n ),\n );\n }\n\n private responseHeaders(raw: JsonReader): readonly ResponseHeaderEntry[] {\n return raw.objects('responseHeaders').map((header: JsonReader) => {\n // RETIRED (#1249): a header NAME is never a string constant any more — it is read off the\n // ContextKey that is the one definition of the header. Refused, never accepted beside the\n // new key: two spellings means the old one is never migrated.\n if (header.has(RETIRED_NAME_CONSTANT)) {\n throw new OpenApiGenerationError(\n `'${RETIRED_NAME_CONSTANT}' was removed from responseHeaders[]; it moved to 'contextKey'`,\n raw.where,\n `Replace \"${RETIRED_NAME_CONSTANT}\" with \"contextKey\" naming an exported ContextKey in ` +\n '\"entry\" (e.g. `export const REQUEST_ID_KEY = WebpiecesCoreHeaders.REQUEST_ID;`, ' +\n 'or a dotted path like \"OneTabletKey.TX_ID\"); the header name is read off its responseHeader.',\n );\n }\n return new ResponseHeaderEntry(\n header.string('entry'),\n header.string('contextKey'),\n header.optionalString('description'),\n header.optionalBoolean('required'),\n );\n });\n }\n\n /** A manifest-relative path, resolved against the manifest's own directory. */\n resolve(manifestPath: string, relative: string): string {\n return path.resolve(path.dirname(manifestPath), relative);\n }\n}\n"]}
1
+ {"version":3,"file":"ManifestLoader.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/manifest/ManifestLoader.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,wDAAkC;AAClC,sEAAmE;AACnE,6CAA0C;AAC1C,4DAA2D;AAC3D,uDAU2B;AAE3B,gGAAgG;AAChG,MAAM,OAAO,GAAG,SAAS,CAAC;AAE1B;;;GAGG;AACH,MAAM,UAAU,GAAG,YAAY,CAAC;AAEhC,gFAAgF;AAChF,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAE7C,sGAAsG;AACtG,MAAM,iBAAiB,GAAgC,IAAI,GAAG,CAAiB;IAC3E,CAAC,MAAM,EAAE,kFAAkF,CAAC;IAC5F;QACI,SAAS;QACT,sFAAsF;KACzF;IACD,CAAC,SAAS,EAAE,kDAAkD,CAAC;IAC/D,CAAC,QAAQ,EAAE,mDAAmD,CAAC;IAC/D,CAAC,iBAAiB,EAAE,gDAAgD,CAAC;IACrE,CAAC,qBAAqB,EAAE,yCAAyC,CAAC;IAClE,CAAC,cAAc,EAAE,iDAAiD,CAAC;CACtE,CAAC,CAAC;AAEH,kFAAkF;AAClF,MAAM,mBAAmB,GAAgC;IACrD,kCAAgB,CAAC,eAAe;IAChC,kCAAgB,CAAC,MAAM;CAC1B,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAa,cAAc;IACvB;;;OAGG;IACH,YAAY,CAAC,YAAoB;QAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QAC5D,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACrB,OAAO,KAAK,CAAC;QACjB,CAAC;QACD,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;YACtB,MAAM,IAAI,+CAAs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C,QAAoB,EAAE,EAAE,CACrB,IAAI,oCAAkB,CAClB,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,EACzB,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,EAC9B,QAAQ,CAAC,eAAe,CAAC,cAAc,CAAC,IAAI,KAAK,CACpD,CACR,CACR,CAAC;IACN,CAAC;IAEO,eAAe,CAAC,GAAe;QACnC,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,MAAkB,EAAE,EAAE;YAC7D,0FAA0F;YAC1F,0FAA0F;YAC1F,8DAA8D;YAC9D,IAAI,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAAE,CAAC;gBACpC,MAAM,IAAI,+CAAsB,CAC5B,IAAI,qBAAqB,gEAAgE,EACzF,GAAG,CAAC,KAAK,EACT,YAAY,qBAAqB,uDAAuD;oBACpF,kFAAkF;oBAClF,8FAA8F,CACrG,CAAC;YACN,CAAC;YACD,OAAO,IAAI,qCAAmB,CAC1B,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EACtB,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAC3B,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,EACpC,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CACrC,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;IAED,+EAA+E;IAC/E,OAAO,CAAC,YAAoB,EAAE,QAAgB;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACJ;AA1PD,wCA0PC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\nimport { JsonReader } from './JsonReader';\nimport { SchemaNameEntry } from '@webpieces/api-doc-model';\nimport {\n ApiEntry,\n ComponentsManifest,\n ErrorResponseEntry,\n ErrorsEntry,\n MANIFEST_SUMMARY_MAX_LENGTH,\n OpenApiManifest,\n OperationIdStyle,\n ResponseHeaderEntry,\n ServerEntry,\n} from './OpenApiManifest';\n\n/** The only `kind` an api entry may declare. Anything else is a typo, and typos are refused. */\nconst WEBHOOK = 'webhook';\n\n/**\n * The only `kind` a MANIFEST may declare (#1058): a DTO library's components-only document. A\n * manifest with no `kind` is a contract library's, exactly as before.\n */\nconst COMPONENTS = 'components';\n\n/** The deleted string-constant spelling of a response header's name (#1249). */\nconst RETIRED_NAME_CONSTANT = 'nameConstant';\n\n/** Keys a components manifest must not carry, each with why — a contract-manifest key is a mix-up. */\nconst NOT_IN_COMPONENTS: ReadonlyMap<string, string> = new Map<string, string>([\n ['apis', 'a components document has no paths; list the library\\'s entry files in \"entries\"'],\n [\n 'version',\n \"a library document's info.version is the package version, read from its package.json\",\n ],\n ['servers', 'a components document has no operations to serve'],\n ['errors', 'the error contract belongs to a contract document'],\n ['responseHeaders', 'response headers belong to a contract document'],\n ['securitySchemeNames', 'security belongs to a contract document'],\n ['operationIds', 'a components document has no operations to name'],\n]);\n\n/** Every spelling `operationIds` accepts, in the order the refusal lists them. */\nconst OPERATION_ID_STYLES: readonly OperationIdStyle[] = [\n OperationIdStyle.CONTRACT_METHOD,\n OperationIdStyle.METHOD,\n];\n\n/**\n * Read `openapi.manifest.json` into {@link OpenApiManifest}.\n *\n * It deals only in {@link JsonReader}, which is where the \"came off disk, not yet checked\" state is\n * concentrated — so nothing in this file, or anywhere downstream, handles an unnarrowed value.\n *\n * Every rejection is a HARD FAILURE naming the field. A published document quietly missing a section\n * is indistinguishable, from outside, from an API that genuinely has no error contract.\n */\nexport class ManifestLoader {\n /**\n * True for a DTO library's `\"kind\": \"components\"` manifest, false for a contract library's (no\n * `kind`). Any other `kind` is refused: a typo there would otherwise render the wrong document.\n */\n isComponents(manifestPath: string): boolean {\n const kind = this.read(manifestPath).optionalString('kind');\n if (kind === undefined) {\n return false;\n }\n if (kind !== COMPONENTS) {\n throw new OpenApiGenerationError(\n `unknown manifest kind '${kind}'`,\n manifestPath,\n `The only manifest kind is \"${COMPONENTS}\", for a DTO library's components document. ` +\n \"Leave it out for a contract library's manifest.\",\n );\n }\n return true;\n }\n\n /** A DTO library's components manifest. See {@link ComponentsManifest}. */\n loadComponents(manifestPath: string): ComponentsManifest {\n const raw = this.read(manifestPath);\n for (const key of NOT_IN_COMPONENTS.keys()) {\n const why = NOT_IN_COMPONENTS.get(key)!;\n if (raw.has(key)) {\n throw new OpenApiGenerationError(\n `a \"kind\": \"${COMPONENTS}\" manifest declares '${key}'`,\n raw.where,\n `Delete it — ${why}.`,\n );\n }\n }\n const entries = raw.strings('entries');\n if (entries.length === 0) {\n throw new OpenApiGenerationError(\n \"'entries' is empty\",\n raw.where,\n 'Name the library\\'s entry files, e.g. \"entries\": [\"src/index.ts\"]; the document holds every type they export.',\n );\n }\n return new ComponentsManifest(raw.string('title'), entries, this.schemaNames(raw));\n }\n\n private read(manifestPath: string): JsonReader {\n if (!fs.existsSync(manifestPath)) {\n throw new OpenApiGenerationError(\n 'no manifest at this path',\n manifestPath,\n 'Pass --manifest pointing at an openapi.manifest.json that exists.',\n );\n }\n return JsonReader.parseFile(fs.readFileSync(manifestPath, 'utf8'), manifestPath);\n }\n\n /** @param manifestPath absolute path to a CONTRACT library's `openapi.manifest.json`. */\n load(manifestPath: string): OpenApiManifest {\n if (this.isComponents(manifestPath)) {\n throw new OpenApiGenerationError(\n `this is a \"kind\": \"${COMPONENTS}\" manifest, not a contract manifest`,\n manifestPath,\n 'Render it as a components document (wp-openapi does so on its own when it reads the kind).',\n );\n }\n const raw = this.read(manifestPath);\n return new OpenApiManifest(\n raw.string('title'),\n this.summary(raw),\n raw.string('version'),\n this.servers(raw),\n raw.optionalString('descriptionFile'),\n this.apis(raw),\n raw.strings('securitySchemeNames'),\n this.errors(raw),\n this.responseHeaders(raw),\n this.schemaNames(raw),\n this.operationIds(raw),\n );\n }\n\n /**\n * REQUIRED (#1296): the API's one-line summary, published as `info.summary`. A heading's subtitle\n * and a directory listing's one-liner, so a second line or a paragraph is refused rather than\n * published.\n */\n private summary(raw: JsonReader): string {\n const cure =\n `Give \"summary\" one line of at most ${MANIFEST_SUMMARY_MAX_LENGTH} characters saying what the API ` +\n 'lets a caller do, e.g. \"summary\": \"Read and cancel the orders placed at your stores.\" It is ' +\n \"published as info.summary under the API's title; the long form stays in descriptionFile.\";\n if (!raw.has('summary')) {\n throw new OpenApiGenerationError(\"'summary' is missing\", raw.where, cure);\n }\n const value = raw.optionalString('summary');\n if (value === undefined || value.trim() === '') {\n throw new OpenApiGenerationError(\"'summary' is not a non-empty string\", raw.where, cure);\n }\n if (/[\\r\\n]/.test(value)) {\n throw new OpenApiGenerationError(\"'summary' spans more than one line\", raw.where, cure);\n }\n if (value.length > MANIFEST_SUMMARY_MAX_LENGTH) {\n throw new OpenApiGenerationError(\n `'summary' is ${value.length} characters, over the ${MANIFEST_SUMMARY_MAX_LENGTH}-character limit`,\n raw.where,\n cure,\n );\n }\n return value;\n }\n\n /**\n * OPTIONAL, defaulting to `\"contract_method\"` (#1283) — the spelling every release before #1270\n * published, and the one that is unique by construction, so a new contract gets the safe scheme\n * without writing anything. `\"method\"` is the opt-in for a document that already published bare\n * names. A value that is present but is neither choice is still refused.\n */\n private operationIds(raw: JsonReader): OperationIdStyle {\n if (!raw.has('operationIds')) {\n return OperationIdStyle.CONTRACT_METHOD;\n }\n const value = raw.optionalString('operationIds');\n const style = OPERATION_ID_STYLES.find((each: OperationIdStyle) => each === value);\n if (style !== undefined) {\n return style;\n }\n const choices = OPERATION_ID_STYLES.map((each: OperationIdStyle) => `\"${each}\"`).join(' or ');\n throw new OpenApiGenerationError(\n value === undefined\n ? \"'operationIds' is present but is not a non-empty string\"\n : `unknown operationIds style '${value}'`,\n raw.where,\n `Set \"operationIds\" to ${choices}, or omit it for \"${OperationIdStyle.CONTRACT_METHOD}\". ` +\n `\"${OperationIdStyle.CONTRACT_METHOD}\" publishes OrdersApi_fetchOrders; ` +\n `\"${OperationIdStyle.METHOD}\" publishes fetchOrders and fails generation when two ` +\n 'operations of one document would share it. Generated partner clients name their ' +\n 'methods from it, so changing it renames every method in their SDKs.',\n );\n }\n\n private servers(raw: JsonReader): readonly ServerEntry[] {\n return raw\n .objects('servers')\n .map(\n (server: JsonReader) =>\n new ServerEntry(server.string('url'), server.optionalString('description')),\n );\n }\n\n private schemaNames(raw: JsonReader): readonly SchemaNameEntry[] {\n return raw.objects('schemaNames').map((entry: JsonReader) => {\n const paths = entry.strings('paths');\n const suffixes = entry.strings('stripSuffixes');\n if (\n paths.length === 0 ||\n paths.some((glob: string) => glob.trim() === '') ||\n !entry.has('stripSuffixes') ||\n suffixes.some((suffix: string) => suffix.length === 0)\n ) {\n throw new OpenApiGenerationError(\n 'invalid schemaNames entry',\n raw.where,\n 'Provide non-empty paths and an explicit stripSuffixes array of non-empty suffixes (or [] to preserve names). First matching path wins.',\n );\n }\n return new SchemaNameEntry(\n paths.map((glob: string) => path.resolve(path.dirname(raw.where), glob)),\n suffixes,\n );\n });\n }\n\n private apis(raw: JsonReader): readonly ApiEntry[] {\n const entries = raw\n .objects('apis')\n .map(\n (api: JsonReader) =>\n new ApiEntry(\n api.string('entry'),\n api.string('tag'),\n api.optionalString('kind'),\n ),\n );\n if (entries.length === 0) {\n throw new OpenApiGenerationError(\n \"'apis' is empty\",\n raw.where,\n 'List at least one contract; a document with no operations publishes nothing.',\n );\n }\n for (const entry of entries) {\n if (entry.kind !== undefined && entry.kind !== WEBHOOK) {\n throw new OpenApiGenerationError(\n `unknown api kind '${entry.kind}' on '${entry.entry}'`,\n raw.where,\n `The only declared kind is \"${WEBHOOK}\". Leave it out for an ordinary contract.`,\n );\n }\n }\n return entries;\n }\n\n private errors(raw: JsonReader): ErrorsEntry | undefined {\n const errors = raw.object('errors');\n if (errors === undefined) {\n return undefined;\n }\n return new ErrorsEntry(\n errors.string('entry'),\n errors.string('type'),\n errors\n .objects('responses')\n .map(\n (response: JsonReader) =>\n new ErrorResponseEntry(\n response.string('status'),\n response.string('description'),\n response.optionalBoolean('requiresAuth') ?? false,\n ),\n ),\n );\n }\n\n private responseHeaders(raw: JsonReader): readonly ResponseHeaderEntry[] {\n return raw.objects('responseHeaders').map((header: JsonReader) => {\n // RETIRED (#1249): a header NAME is never a string constant any more — it is read off the\n // ContextKey that is the one definition of the header. Refused, never accepted beside the\n // new key: two spellings means the old one is never migrated.\n if (header.has(RETIRED_NAME_CONSTANT)) {\n throw new OpenApiGenerationError(\n `'${RETIRED_NAME_CONSTANT}' was removed from responseHeaders[]; it moved to 'contextKey'`,\n raw.where,\n `Replace \"${RETIRED_NAME_CONSTANT}\" with \"contextKey\" naming an exported ContextKey in ` +\n '\"entry\" (e.g. `export const REQUEST_ID_KEY = WebpiecesCoreHeaders.REQUEST_ID;`, ' +\n 'or a dotted path like \"OneTabletKey.TX_ID\"); the header name is read off its responseHeader.',\n );\n }\n return new ResponseHeaderEntry(\n header.string('entry'),\n header.string('contextKey'),\n header.optionalString('description'),\n header.optionalBoolean('required'),\n );\n });\n }\n\n /** A manifest-relative path, resolved against the manifest's own directory. */\n resolve(manifestPath: string, relative: string): string {\n return path.resolve(path.dirname(manifestPath), relative);\n }\n}\n"]}
@@ -6,7 +6,9 @@
6
6
  * The manifest carries exactly what is **not a property of the code**, and nothing else. Every field
7
7
  * below is a product decision, a deployment fact, or a NAME pointing at something the code owns:
8
8
  *
9
- * - `title`, `version` — product decisions.
9
+ * - `title`, `summary`, `version` — product decisions. `summary` is the API's one-line pitch (#1296),
10
+ * published as `info.summary`; REQUIRED, one line, at most 200 characters — the Claude Connectors
11
+ * Directory's one-liner limit, so the same text can be pasted there.
10
12
  * - `servers[]` — a deployment fact.
11
13
  * - `descriptionFile` — a teaching decision.
12
14
  * - `apis[]` — which contracts, in the order the published sidebar shows them.
@@ -27,6 +29,11 @@
27
29
  * Alphabetising this array is not a cleanup; it reorders partner-facing navigation.
28
30
  */
29
31
  import { SchemaNameEntry } from '@webpieces/api-doc-model';
32
+ /**
33
+ * The longest manifest `summary` (#1296): the Claude Connectors Directory's limit for a server's
34
+ * one-line description, so the line published as `info.summary` can be pasted there unchanged.
35
+ */
36
+ export declare const MANIFEST_SUMMARY_MAX_LENGTH = 200;
30
37
  /**
31
38
  * How every operation's `operationId` is spelled (#1270). OPTIONAL in a contract manifest, defaulting
32
39
  * to {@link CONTRACT_METHOD} (#1283) — the spelling every earlier release published, and the only one
@@ -149,6 +156,11 @@ export declare class ResponseHeaderEntry {
149
156
  }
150
157
  export declare class OpenApiManifest {
151
158
  readonly title: string;
159
+ /**
160
+ * The API's one-line summary (#1296) — OpenAPI 3.1 `info.summary`. REQUIRED: one line, at most
161
+ * {@link MANIFEST_SUMMARY_MAX_LENGTH} characters.
162
+ */
163
+ readonly summary: string;
152
164
  readonly version: string;
153
165
  readonly servers: readonly ServerEntry[];
154
166
  /** A markdown preamble, relative to the manifest. Rendered into `info.description`. */
@@ -159,7 +171,12 @@ export declare class OpenApiManifest {
159
171
  readonly responseHeaders: readonly ResponseHeaderEntry[];
160
172
  readonly schemaNames: readonly SchemaNameEntry[];
161
173
  readonly operationIds: OperationIdStyle;
162
- constructor(title: string, version: string, servers: readonly ServerEntry[],
174
+ constructor(title: string,
175
+ /**
176
+ * The API's one-line summary (#1296) — OpenAPI 3.1 `info.summary`. REQUIRED: one line, at most
177
+ * {@link MANIFEST_SUMMARY_MAX_LENGTH} characters.
178
+ */
179
+ summary: string, version: string, servers: readonly ServerEntry[],
163
180
  /** A markdown preamble, relative to the manifest. Rendered into `info.description`. */
164
181
  descriptionFile: string | undefined, apis: readonly ApiEntry[], securitySchemeNames: readonly string[], errors: ErrorsEntry | undefined, responseHeaders: readonly ResponseHeaderEntry[], schemaNames: readonly SchemaNameEntry[], operationIds: OperationIdStyle);
165
182
  }
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ComponentsManifest = exports.OpenApiManifest = exports.ResponseHeaderEntry = exports.ErrorsEntry = exports.ErrorResponseEntry = exports.ApiEntry = exports.ServerEntry = exports.OperationIdStyle = void 0;
3
+ exports.ComponentsManifest = exports.OpenApiManifest = exports.ResponseHeaderEntry = exports.ErrorsEntry = exports.ErrorResponseEntry = exports.ApiEntry = exports.ServerEntry = exports.OperationIdStyle = exports.MANIFEST_SUMMARY_MAX_LENGTH = void 0;
4
+ /**
5
+ * The longest manifest `summary` (#1296): the Claude Connectors Directory's limit for a server's
6
+ * one-line description, so the line published as `info.summary` can be pasted there unchanged.
7
+ */
8
+ exports.MANIFEST_SUMMARY_MAX_LENGTH = 200;
4
9
  /**
5
10
  * How every operation's `operationId` is spelled (#1270). OPTIONAL in a contract manifest, defaulting
6
11
  * to {@link CONTRACT_METHOD} (#1283) — the spelling every earlier release published, and the only one
@@ -129,6 +134,7 @@ class ResponseHeaderEntry {
129
134
  exports.ResponseHeaderEntry = ResponseHeaderEntry;
130
135
  class OpenApiManifest {
131
136
  title;
137
+ summary;
132
138
  version;
133
139
  servers;
134
140
  descriptionFile;
@@ -138,10 +144,16 @@ class OpenApiManifest {
138
144
  responseHeaders;
139
145
  schemaNames;
140
146
  operationIds;
141
- constructor(title, version, servers,
147
+ constructor(title,
148
+ /**
149
+ * The API's one-line summary (#1296) — OpenAPI 3.1 `info.summary`. REQUIRED: one line, at most
150
+ * {@link MANIFEST_SUMMARY_MAX_LENGTH} characters.
151
+ */
152
+ summary, version, servers,
142
153
  /** A markdown preamble, relative to the manifest. Rendered into `info.description`. */
143
154
  descriptionFile, apis, securitySchemeNames, errors, responseHeaders, schemaNames, operationIds) {
144
155
  this.title = title;
156
+ this.summary = summary;
145
157
  this.version = version;
146
158
  this.servers = servers;
147
159
  this.descriptionFile = descriptionFile;
@@ -1 +1 @@
1
- {"version":3,"file":"OpenApiManifest.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/manifest/OpenApiManifest.ts"],"names":[],"mappings":";;;AA8BA;;;;;;GAMG;AACH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IACxC;;;OAGG;IACM,QAA6B;QAP7B,UAAK,GAAL,KAAK,CAAQ;QACb,eAAU,GAAV,UAAU,CAAQ;QAClB,gBAAW,GAAX,WAAW,CAAoB;QAK/B,aAAQ,GAAR,QAAQ,CAAqB;IACvC,CAAC;CACP;AAXD,kDAWC;AAED,MAAa,eAAe;IAEX;IACA;IACA;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IAXb,YACa,KAAa,EACb,OAAe,EACf,OAA+B;IACxC,uFAAuF;IAC9E,eAAmC,EACnC,IAAyB,EACzB,mBAAsC,EACtC,MAA+B,EAC/B,eAA+C,EAC/C,WAAuC,EACvC,YAA8B;QAV9B,UAAK,GAAL,KAAK,CAAQ;QACb,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAwB;QAE/B,oBAAe,GAAf,eAAe,CAAoB;QACnC,SAAI,GAAJ,IAAI,CAAqB;QACzB,wBAAmB,GAAnB,mBAAmB,CAAmB;QACtC,WAAM,GAAN,MAAM,CAAyB;QAC/B,oBAAe,GAAf,eAAe,CAAgC;QAC/C,gBAAW,GAAX,WAAW,CAA4B;QACvC,iBAAY,GAAZ,YAAY,CAAkB;IACxC,CAAC;CACP;AAdD,0CAcC;AAED;;;;;;;;GAQG;AACH,MAAa,kBAAkB;IAEd;IAEA;IACA;IAJb,YACa,KAAa;IACtB,gGAAgG;IACvF,OAA0B,EAC1B,WAAuC;QAHvC,UAAK,GAAL,KAAK,CAAQ;QAEb,YAAO,GAAP,OAAO,CAAmB;QAC1B,gBAAW,GAAX,WAAW,CAA4B;IACjD,CAAC;CACP;AAPD,gDAOC","sourcesContent":["/**\n * `openapi.manifest.json`, as CLASSES.\n *\n * ## What is allowed in here, and what is not\n *\n * The manifest carries exactly what is **not a property of the code**, and nothing else. Every field\n * below is a product decision, a deployment fact, or a NAME pointing at something the code owns:\n *\n * - `title`, `version` — product decisions.\n * - `servers[]` — a deployment fact.\n * - `descriptionFile` — a teaching decision.\n * - `apis[]` — which contracts, in the order the published sidebar shows them.\n * - `securitySchemeNames[]` — the published scheme KEYS only. Everything else about the schemes, and\n * the AND-ed `security` requirement, is DERIVED from the contract's own `apiKey(...)`. A\n * `components.securitySchemes` block here would be a second copy of header names the running\n * server never reads, and nothing could contradict it.\n * - `errors` — the document-wide failure contract, with the BODY read from a real TS type so the\n * published shape cannot drift from the one on the wire.\n * - `responseHeaders[]` — declared by `contextKey` naming an exported ContextKey, never by a literal.\n * - `operationIds` — the published operationId spelling (#1270); optional, `contract_method` when omitted (#1283).\n *\n * Anything a renderer could read off the source instead belongs in the source.\n *\n * ## The ORDER of `apis[]` is published navigation\n *\n * It is rendered into `tags[]` in that order, and a docs theme builds its sidebar from `tags[]`.\n * Alphabetising this array is not a cleanup; it reorders partner-facing navigation.\n */\nimport { SchemaNameEntry } from '@webpieces/api-doc-model';\n\n/**\n * How every operation's `operationId` is spelled (#1270). OPTIONAL in a contract manifest, defaulting\n * to {@link CONTRACT_METHOD} (#1283) — the spelling every earlier release published, and the only one\n * unique by construction. `operationId` is what openapi-generator, Kiota, NSwag and friends name the\n * METHOD in every client a partner generates, so changing the spelling renames every method in every\n * partner's SDK; {@link METHOD} is the opt-in for a document that already published bare names.\n */\nexport enum OperationIdStyle {\n /** `OrdersApi_fetchOrders` — unique by construction across contracts. */\n CONTRACT_METHOD = 'contract_method',\n /**\n * `fetchOrders` — the bare method name. Two operations of one document sharing it is a HARD\n * FAILURE naming both, so the id is still unique.\n */\n METHOD = 'method',\n}\n\nexport class ServerEntry {\n constructor(\n readonly url: string,\n readonly description: string | undefined,\n ) {}\n}\n\n/** One contract file the generator reads. */\nexport class ApiEntry {\n constructor(\n /** Path to the contract `.ts`, relative to the manifest's own directory. */\n readonly entry: string,\n /** The tag every operation of this contract carries — and one `tags[]` entry, in order. */\n readonly tag: string,\n /**\n * `webhook` moves the contract into the top-level `webhooks:` block: these are calls WE\n * make to a partner's server, not routes on ours.\n *\n * DECLARED, never sniffed from a `*WebhookApi` filename. A name convention would hide a\n * partner-visible decision inside a rename, and a rename is the one edit nobody reviews for\n * contract impact.\n */\n readonly kind: string | undefined,\n ) {}\n\n isWebhook(): boolean {\n return this.kind === 'webhook';\n }\n}\n\n/** One status code of the document-wide failure contract. */\nexport class ErrorResponseEntry {\n constructor(\n readonly status: string,\n readonly description: string,\n /**\n * `true`: this failure can only happen to an AUTHENTICATED operation (a 401 for a bad\n * credential), so it is left OFF every operation whose resolved auth is public\n * (`@WpAuthPublic`) — a public endpoint cannot fail authentication. Omitted means `false`:\n * the response is listed on every operation.\n */\n readonly requiresAuth: boolean,\n ) {}\n}\n\n/**\n * The document-wide failure contract.\n *\n * Document-wide and not per-operation on purpose: per-operation codes would be a second hand-written\n * list to keep in step with the handlers, and stating them once tells a partner the truth — any\n * operation can fail these ways.\n */\nexport class ErrorsEntry {\n constructor(\n /** The `.ts` file declaring the error body, relative to the manifest. */\n readonly entry: string,\n /** The exported TYPE name of the body. Read with the compiler, so it cannot drift. */\n readonly type: string,\n readonly responses: readonly ErrorResponseEntry[],\n ) {}\n}\n\n/**\n * One response header every operation carries — on its success response AND on every failure the\n * document declares for it (#1270): a correlation id matters most on the response that FAILED, and\n * the server stamps it on every response, so declaring it on the 200 alone under-documents the wire.\n *\n * `contextKey` names an exported `ContextKey` in `entry` — the export's name, or a dotted path into\n * one (`OneTabletKey.TX_ID`) — and the generator reads the header name off that key's own\n * `ContextKey.trusted(...)` / `ContextKey.untrusted(...)` definition: its `responseHeader`, which is\n * what the server's response choke point actually writes (#1249). A literal here would be a copy of\n * the header name that a rename leaves silently stale — and JSON cannot import, so naming the key is\n * the only way for this file to point at the one definition. Failing to resolve it is a HARD\n * FAILURE for the same reason.\n */\nexport class ResponseHeaderEntry {\n constructor(\n readonly entry: string,\n readonly contextKey: string,\n readonly description: string | undefined,\n /**\n * Rendered verbatim as the OpenAPI header object's `required`. Omitted means the document\n * does not state it, which OpenAPI reads as `false`.\n */\n readonly required: boolean | undefined,\n ) {}\n}\n\nexport class OpenApiManifest {\n constructor(\n readonly title: string,\n readonly version: string,\n readonly servers: readonly ServerEntry[],\n /** A markdown preamble, relative to the manifest. Rendered into `info.description`. */\n readonly descriptionFile: string | undefined,\n readonly apis: readonly ApiEntry[],\n readonly securitySchemeNames: readonly string[],\n readonly errors: ErrorsEntry | undefined,\n readonly responseHeaders: readonly ResponseHeaderEntry[],\n readonly schemaNames: readonly SchemaNameEntry[],\n readonly operationIds: OperationIdStyle,\n ) {}\n}\n\n/**\n * A DTO library's `openapi.manifest.json` — `\"kind\": \"components\"` (#1058).\n *\n * It names the library's ENTRY FILES instead of contracts: the document it produces is\n * components-only — `openapi`, `info` and `components.schemas`, no paths — holding every type the\n * library exports and declares, which contract documents `$ref` instead of copying. There is no\n * `version` here: a library document's `info.version` IS the package version, read from its\n * `package.json`, so the two cannot disagree.\n */\nexport class ComponentsManifest {\n constructor(\n readonly title: string,\n /** The library's entry files (usually `src/index.ts`), relative to the manifest's directory. */\n readonly entries: readonly string[],\n readonly schemaNames: readonly SchemaNameEntry[],\n ) {}\n}\n"]}
1
+ {"version":3,"file":"OpenApiManifest.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/manifest/OpenApiManifest.ts"],"names":[],"mappings":";;;AAgCA;;;GAGG;AACU,QAAA,2BAA2B,GAAG,GAAG,CAAC;AAE/C;;;;;;GAMG;AACH,IAAY,gBAQX;AARD,WAAY,gBAAgB;IACxB,yEAAyE;IACzE,uDAAmC,CAAA;IACnC;;;OAGG;IACH,qCAAiB,CAAA;AACrB,CAAC,EARW,gBAAgB,gCAAhB,gBAAgB,QAQ3B;AAED,MAAa,WAAW;IAEP;IACA;IAFb,YACa,GAAW,EACX,WAA+B;QAD/B,QAAG,GAAH,GAAG,CAAQ;QACX,gBAAW,GAAX,WAAW,CAAoB;IACzC,CAAC;CACP;AALD,kCAKC;AAED,6CAA6C;AAC7C,MAAa,QAAQ;IAGJ;IAEA;IASA;IAbb;IACI,4EAA4E;IACnE,KAAa;IACtB,2FAA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EAC/B,eAA+C,EAC/C,WAAuC,EACvC,YAA8B;QAf9B,UAAK,GAAL,KAAK,CAAQ;QAKb,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAwB;QAE/B,oBAAe,GAAf,eAAe,CAAoB;QACnC,SAAI,GAAJ,IAAI,CAAqB;QACzB,wBAAmB,GAAnB,mBAAmB,CAAmB;QACtC,WAAM,GAAN,MAAM,CAAyB;QAC/B,oBAAe,GAAf,eAAe,CAAgC;QAC/C,gBAAW,GAAX,WAAW,CAA4B;QACvC,iBAAY,GAAZ,YAAY,CAAkB;IACxC,CAAC;CACP;AAnBD,0CAmBC;AAED;;;;;;;;GAQG;AACH,MAAa,kBAAkB;IAEd;IAEA;IACA;IAJb,YACa,KAAa;IACtB,gGAAgG;IACvF,OAA0B,EAC1B,WAAuC;QAHvC,UAAK,GAAL,KAAK,CAAQ;QAEb,YAAO,GAAP,OAAO,CAAmB;QAC1B,gBAAW,GAAX,WAAW,CAA4B;IACjD,CAAC;CACP;AAPD,gDAOC","sourcesContent":["/**\n * `openapi.manifest.json`, as CLASSES.\n *\n * ## What is allowed in here, and what is not\n *\n * The manifest carries exactly what is **not a property of the code**, and nothing else. Every field\n * below is a product decision, a deployment fact, or a NAME pointing at something the code owns:\n *\n * - `title`, `summary`, `version` — product decisions. `summary` is the API's one-line pitch (#1296),\n * published as `info.summary`; REQUIRED, one line, at most 200 characters — the Claude Connectors\n * Directory's one-liner limit, so the same text can be pasted there.\n * - `servers[]` — a deployment fact.\n * - `descriptionFile` — a teaching decision.\n * - `apis[]` — which contracts, in the order the published sidebar shows them.\n * - `securitySchemeNames[]` — the published scheme KEYS only. Everything else about the schemes, and\n * the AND-ed `security` requirement, is DERIVED from the contract's own `apiKey(...)`. A\n * `components.securitySchemes` block here would be a second copy of header names the running\n * server never reads, and nothing could contradict it.\n * - `errors` — the document-wide failure contract, with the BODY read from a real TS type so the\n * published shape cannot drift from the one on the wire.\n * - `responseHeaders[]` — declared by `contextKey` naming an exported ContextKey, never by a literal.\n * - `operationIds` — the published operationId spelling (#1270); optional, `contract_method` when omitted (#1283).\n *\n * Anything a renderer could read off the source instead belongs in the source.\n *\n * ## The ORDER of `apis[]` is published navigation\n *\n * It is rendered into `tags[]` in that order, and a docs theme builds its sidebar from `tags[]`.\n * Alphabetising this array is not a cleanup; it reorders partner-facing navigation.\n */\nimport { SchemaNameEntry } from '@webpieces/api-doc-model';\n\n/**\n * The longest manifest `summary` (#1296): the Claude Connectors Directory's limit for a server's\n * one-line description, so the line published as `info.summary` can be pasted there unchanged.\n */\nexport const MANIFEST_SUMMARY_MAX_LENGTH = 200;\n\n/**\n * How every operation's `operationId` is spelled (#1270). OPTIONAL in a contract manifest, defaulting\n * to {@link CONTRACT_METHOD} (#1283) — the spelling every earlier release published, and the only one\n * unique by construction. `operationId` is what openapi-generator, Kiota, NSwag and friends name the\n * METHOD in every client a partner generates, so changing the spelling renames every method in every\n * partner's SDK; {@link METHOD} is the opt-in for a document that already published bare names.\n */\nexport enum OperationIdStyle {\n /** `OrdersApi_fetchOrders` — unique by construction across contracts. */\n CONTRACT_METHOD = 'contract_method',\n /**\n * `fetchOrders` — the bare method name. Two operations of one document sharing it is a HARD\n * FAILURE naming both, so the id is still unique.\n */\n METHOD = 'method',\n}\n\nexport class ServerEntry {\n constructor(\n readonly url: string,\n readonly description: string | undefined,\n ) {}\n}\n\n/** One contract file the generator reads. */\nexport class ApiEntry {\n constructor(\n /** Path to the contract `.ts`, relative to the manifest's own directory. */\n readonly entry: string,\n /** The tag every operation of this contract carries — and one `tags[]` entry, in order. */\n readonly tag: string,\n /**\n * `webhook` moves the contract into the top-level `webhooks:` block: these are calls WE\n * make to a partner's server, not routes on ours.\n *\n * DECLARED, never sniffed from a `*WebhookApi` filename. A name convention would hide a\n * partner-visible decision inside a rename, and a rename is the one edit nobody reviews for\n * contract impact.\n */\n readonly kind: string | undefined,\n ) {}\n\n isWebhook(): boolean {\n return this.kind === 'webhook';\n }\n}\n\n/** One status code of the document-wide failure contract. */\nexport class ErrorResponseEntry {\n constructor(\n readonly status: string,\n readonly description: string,\n /**\n * `true`: this failure can only happen to an AUTHENTICATED operation (a 401 for a bad\n * credential), so it is left OFF every operation whose resolved auth is public\n * (`@WpAuthPublic`) — a public endpoint cannot fail authentication. Omitted means `false`:\n * the response is listed on every operation.\n */\n readonly requiresAuth: boolean,\n ) {}\n}\n\n/**\n * The document-wide failure contract.\n *\n * Document-wide and not per-operation on purpose: per-operation codes would be a second hand-written\n * list to keep in step with the handlers, and stating them once tells a partner the truth — any\n * operation can fail these ways.\n */\nexport class ErrorsEntry {\n constructor(\n /** The `.ts` file declaring the error body, relative to the manifest. */\n readonly entry: string,\n /** The exported TYPE name of the body. Read with the compiler, so it cannot drift. */\n readonly type: string,\n readonly responses: readonly ErrorResponseEntry[],\n ) {}\n}\n\n/**\n * One response header every operation carries — on its success response AND on every failure the\n * document declares for it (#1270): a correlation id matters most on the response that FAILED, and\n * the server stamps it on every response, so declaring it on the 200 alone under-documents the wire.\n *\n * `contextKey` names an exported `ContextKey` in `entry` — the export's name, or a dotted path into\n * one (`OneTabletKey.TX_ID`) — and the generator reads the header name off that key's own\n * `ContextKey.trusted(...)` / `ContextKey.untrusted(...)` definition: its `responseHeader`, which is\n * what the server's response choke point actually writes (#1249). A literal here would be a copy of\n * the header name that a rename leaves silently stale — and JSON cannot import, so naming the key is\n * the only way for this file to point at the one definition. Failing to resolve it is a HARD\n * FAILURE for the same reason.\n */\nexport class ResponseHeaderEntry {\n constructor(\n readonly entry: string,\n readonly contextKey: string,\n readonly description: string | undefined,\n /**\n * Rendered verbatim as the OpenAPI header object's `required`. Omitted means the document\n * does not state it, which OpenAPI reads as `false`.\n */\n readonly required: boolean | undefined,\n ) {}\n}\n\nexport class OpenApiManifest {\n constructor(\n readonly title: string,\n /**\n * The API's one-line summary (#1296) — OpenAPI 3.1 `info.summary`. REQUIRED: one line, at most\n * {@link MANIFEST_SUMMARY_MAX_LENGTH} characters.\n */\n readonly summary: string,\n readonly version: string,\n readonly servers: readonly ServerEntry[],\n /** A markdown preamble, relative to the manifest. Rendered into `info.description`. */\n readonly descriptionFile: string | undefined,\n readonly apis: readonly ApiEntry[],\n readonly securitySchemeNames: readonly string[],\n readonly errors: ErrorsEntry | undefined,\n readonly responseHeaders: readonly ResponseHeaderEntry[],\n readonly schemaNames: readonly SchemaNameEntry[],\n readonly operationIds: OperationIdStyle,\n ) {}\n}\n\n/**\n * A DTO library's `openapi.manifest.json` — `\"kind\": \"components\"` (#1058).\n *\n * It names the library's ENTRY FILES instead of contracts: the document it produces is\n * components-only — `openapi`, `info` and `components.schemas`, no paths — holding every type the\n * library exports and declares, which contract documents `$ref` instead of copying. There is no\n * `version` here: a library document's `info.version` IS the package version, read from its\n * `package.json`, so the two cannot disagree.\n */\nexport class ComponentsManifest {\n constructor(\n readonly title: string,\n /** The library's entry files (usually `src/index.ts`), relative to the manifest's directory. */\n readonly entries: readonly string[],\n readonly schemaNames: readonly SchemaNameEntry[],\n ) {}\n}\n"]}