@webpieces/openapi-generator 0.4.957 → 0.4.958

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/openapi-generator",
3
- "version": "0.4.957",
3
+ "version": "0.4.958",
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.957",
27
- "@webpieces/core-util": "0.4.957",
26
+ "@webpieces/api-doc-model": "0.4.958",
27
+ "@webpieces/core-util": "0.4.958",
28
28
  "typescript": "5.9.3"
29
29
  },
30
30
  "bin": {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.InlinedWrappers = void 0;
4
+ const core_util_1 = require("@webpieces/core-util");
4
5
  const SuccessBody_1 = require("./SuccessBody");
5
6
  /**
6
7
  * WHICH request/response wrappers an operation defines INLINE instead of in `components.schemas`
@@ -61,8 +62,9 @@ class WrapperUseCounter {
61
62
  this.types = types;
62
63
  }
63
64
  /**
64
- * Every body an operation of any document can render: a POST's request (the only method a body is
65
- * published for — see `OperationRenderer.requestBody`) and a non-void success response. A
65
+ * Every body an operation of any document can render: a POST/PUT/PATCH request (the verbs a body is
66
+ * published for — `verbCarriesBody`, see `OperationRenderer.requestBody`) and a non-void success
67
+ * response. A URL parameter's type is a NESTED use: a parameter schema is never an inlined wrapper. A
66
68
  * `@WpLocalOnly` endpoint is in no document, so it uses nothing.
67
69
  */
68
70
  countOperations(contracts) {
@@ -108,9 +110,14 @@ class WrapperUseCounter {
108
110
  if (endpoint.localOnly) {
109
111
  return;
110
112
  }
111
- if (endpoint.httpMethod === 'POST' && endpoint.request !== undefined) {
113
+ if ((0, core_util_1.verbCarriesBody)(endpoint.httpMethod) && endpoint.request !== undefined) {
112
114
  this.countBody(endpoint.request);
113
115
  }
116
+ for (const parameter of endpoint.parameters) {
117
+ if (parameter.type !== undefined) {
118
+ this.walk(parameter.type);
119
+ }
120
+ }
114
121
  if (!this.body.isVoid(endpoint.response)) {
115
122
  this.countBody(endpoint.response);
116
123
  }
@@ -1 +1 @@
1
- {"version":3,"file":"InlinedWrappers.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/InlinedWrappers.ts"],"names":[],"mappings":";;;AAEA,+CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,eAAe;IACa;IAArC,YAAqC,IAAyB;QAAzB,SAAI,GAAJ,IAAI,CAAqB;IAAG,CAAC;IAElE,0FAA0F;IAC1F,8EAA8E;IAC9E,MAAM,CAAC,IAAI;QACP,OAAO,IAAI,eAAe,CAAC,IAAI,GAAG,EAAU,CAAC,CAAC;IAClD,CAAC;IAED,yEAAyE;IACzE,8EAA8E;IAC9E,MAAM,CAAC,EAAE,CACL,SAAmC,EACnC,KAA0C,EAC1C,WAA+B,EAC/B,YAAgC;QAEhC,MAAM,OAAO,GAAG,IAAI,iBAAiB,CAAC,KAAK,CAAC,CAAC;QAC7C,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;QACnC,OAAO,CAAC,YAAY,EAAE,CAAC;QACvB,IAAI,YAAY,KAAK,SAAS,EAAE,CAAC;YAC7B,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;IAC/D,CAAC;IAED,GAAG,CAAC,GAAW;QACX,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;CACJ;AA7BD,0CA6BC;AAED,uG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G,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAC1D,OAAO;QACX,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnB,CAAC;IAEO,IAAI,CAAC,GAAY;QACrB,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;YACf,KAAK,KAAK;gBACN,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,OAAQ,CAAC,CAAC;gBAC9B,OAAO;YACX,KAAK,OAAO;gBACR,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAM,CAAC,CAAC;gBACtB,OAAO;YACX,KAAK,SAAS;gBACV,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAO,CAAC,CAAC;gBACvB,OAAO;YACX,KAAK,OAAO;gBACR,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,aAAa,EAAE,CAAC;oBACrC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBAC5B,CAAC;gBACD,OAAO;YACX;gBACI,OAAO;QACf,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { DocumentedEndpoint, DocumentedType, TypeRef } from '@webpieces/api-doc-model';\nimport { ContractModel } from './GenerationInputs';\nimport { SuccessBody } from './SuccessBody';\n\n/**\n * WHICH request/response wrappers an operation defines INLINE instead of in `components.schemas`\n * (#1303).\n *\n * A `…Request` body or `…Response` reply belongs to its one method: it changes when that method\n * changes, and nothing else may refer to it without tying two methods together. As a component it got\n * a schema page of its own on the docs site that nothing linked to. So a wrapper is inlined at its\n * operation — keeping `title: \"<PublishedName>\"`, which is what client generators (openapi-generator,\n * NSwag, Kiota) name an inline model from — when ALL of these hold:\n *\n * - it is the TOP-LEVEL type of exactly ONE request body or ONE success response, counted over every\n * operation of every contract in the manifest (routes and webhooks, every document — not per\n * document: a wrapper two operations share is shared, whichever documents each lands in);\n * - no named type in the model refers to it — as a field, an array item, a map value or a union\n * branch — and it is not the manifest's error body;\n * - it is an OBJECT (an enum or a union alias is a shared noun, not a wrapper);\n * - it is declared in the document's OWN package. A type another package declares is defined by that\n * package's `components.openapi.json` and referenced from here (#1058's one-owner rule); inlining it\n * would define one schema in two documents.\n *\n * Everything else — a wrapper two operations share, one nested in another schema, every shared noun —\n * stays a component exactly as before.\n */\nexport class InlinedWrappers {\n private constructor(private readonly keys: ReadonlySet<string>) {}\n\n /** No wrapper is inlined — the MCP projection and a DTO library's components document. */\n // webpieces-disable no-function-outside-class -- static factory of this class\n static none(): InlinedWrappers {\n return new InlinedWrappers(new Set<string>());\n }\n\n /** The wrappers of a manifest, by model key (`DocumentedType.keyOf`). */\n // webpieces-disable no-function-outside-class -- static factory of this class\n static of(\n contracts: readonly ContractModel[],\n types: ReadonlyMap<string, DocumentedType>,\n homePackage: string | undefined,\n errorTypeKey: string | undefined,\n ): InlinedWrappers {\n const counter = new WrapperUseCounter(types);\n counter.countOperations(contracts);\n counter.countSchemas();\n if (errorTypeKey !== undefined) {\n counter.markNested(errorTypeKey);\n }\n return new InlinedWrappers(counter.singleUse(homePackage));\n }\n\n has(key: string): boolean {\n return this.keys.has(key);\n }\n}\n\n/** The tally {@link InlinedWrappers.of} decides from: top-level uses per key, and every nested one. */\nclass WrapperUseCounter {\n private readonly topLevel = new Map<string, number>();\n private readonly nested = new Set<string>();\n private readonly body = new SuccessBody();\n\n constructor(private readonly types: ReadonlyMap<string, DocumentedType>) {}\n\n /**\n * Every body an operation of any document can render: a POST's request (the only method a body is\n * published for — see `OperationRenderer.requestBody`) and a non-void success response. A\n * `@WpLocalOnly` endpoint is in no document, so it uses nothing.\n */\n countOperations(contracts: readonly ContractModel[]): void {\n for (const contract of contracts) {\n for (const endpoint of contract.model.endpoints) {\n this.countEndpoint(endpoint);\n }\n }\n }\n\n /** Every reference one named type makes to another — which makes the target a shared noun. */\n countSchemas(): void {\n for (const type of Array.from(this.types.values())) {\n for (const field of type.fields) {\n this.walk(field.type);\n }\n if (type.indexSignatureValue !== undefined) {\n this.walk(type.indexSignatureValue);\n }\n for (const branch of type.unionRefNames) {\n this.markNested(branch);\n }\n }\n }\n\n markNested(key: string): void {\n this.nested.add(key);\n }\n\n singleUse(homePackage: string | undefined): ReadonlySet<string> {\n const keys = new Set<string>();\n for (const key of Array.from(this.topLevel.keys())) {\n const type = this.types.get(key);\n if (\n this.topLevel.get(key) === 1 &&\n !this.nested.has(key) &&\n type !== undefined &&\n type.packageName === homePackage &&\n type.enumValues.length === 0 &&\n type.unionRefNames.length === 0\n ) {\n keys.add(key);\n }\n }\n return keys;\n }\n\n private countEndpoint(endpoint: DocumentedEndpoint): void {\n if (endpoint.localOnly) {\n return;\n }\n if (endpoint.httpMethod === 'POST' && endpoint.request !== undefined) {\n this.countBody(endpoint.request);\n }\n if (!this.body.isVoid(endpoint.response)) {\n this.countBody(endpoint.response!);\n }\n }\n\n /** A body that IS a named type is a top-level use; anything else (`X[]`, a map) nests it. */\n private countBody(ref: TypeRef): void {\n if (ref.kind === 'ref') {\n const key = ref.refName!;\n this.topLevel.set(key, (this.topLevel.get(key) ?? 0) + 1);\n return;\n }\n this.walk(ref);\n }\n\n private walk(ref: TypeRef): void {\n switch (ref.kind) {\n case 'ref':\n this.markNested(ref.refName!);\n return;\n case 'array':\n this.walk(ref.items!);\n return;\n case 'openMap':\n this.walk(ref.values!);\n return;\n case 'union':\n for (const branch of ref.unionRefNames) {\n this.markNested(branch);\n }\n return;\n default:\n return;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"InlinedWrappers.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/InlinedWrappers.ts"],"names":[],"mappings":";;;AACA,oDAAuD;AAEvD,+CAA4C;AAE5C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAa,eAAe;IACa;IAArC,YAAqC,IAAyB;QAAzB,SAAI,GAAJ,IAAI,CAAqB;IAAG,CAAC;IAElE,0FAA0F;IAC1F,8EAA8E;IAC9E,MAAM,CAAC,IAAI;QACP,OAAO,IAAI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C;gBACtB,OAAO;YACX,KAAK,SAAS;gBACV,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAO,CAAC,CAAC;gBACvB,OAAO;YACX,KAAK,OAAO;gBACR,KAAK,MAAM,MAAM,IAAI,GAAG,CAAC,aAAa,EAAE,CAAC;oBACrC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;gBAC5B,CAAC;gBACD,OAAO;YACX;gBACI,OAAO;QACf,CAAC;IACL,CAAC;CACJ","sourcesContent":["import { DocumentedEndpoint, DocumentedType, TypeRef } from '@webpieces/api-doc-model';\nimport { verbCarriesBody } from '@webpieces/core-util';\nimport { ContractModel } from './GenerationInputs';\nimport { SuccessBody } from './SuccessBody';\n\n/**\n * WHICH request/response wrappers an operation defines INLINE instead of in `components.schemas`\n * (#1303).\n *\n * A `…Request` body or `…Response` reply belongs to its one method: it changes when that method\n * changes, and nothing else may refer to it without tying two methods together. As a component it got\n * a schema page of its own on the docs site that nothing linked to. So a wrapper is inlined at its\n * operation — keeping `title: \"<PublishedName>\"`, which is what client generators (openapi-generator,\n * NSwag, Kiota) name an inline model from — when ALL of these hold:\n *\n * - it is the TOP-LEVEL type of exactly ONE request body or ONE success response, counted over every\n * operation of every contract in the manifest (routes and webhooks, every document — not per\n * document: a wrapper two operations share is shared, whichever documents each lands in);\n * - no named type in the model refers to it — as a field, an array item, a map value or a union\n * branch — and it is not the manifest's error body;\n * - it is an OBJECT (an enum or a union alias is a shared noun, not a wrapper);\n * - it is declared in the document's OWN package. A type another package declares is defined by that\n * package's `components.openapi.json` and referenced from here (#1058's one-owner rule); inlining it\n * would define one schema in two documents.\n *\n * Everything else — a wrapper two operations share, one nested in another schema, every shared noun —\n * stays a component exactly as before.\n */\nexport class InlinedWrappers {\n private constructor(private readonly keys: ReadonlySet<string>) {}\n\n /** No wrapper is inlined — the MCP projection and a DTO library's components document. */\n // webpieces-disable no-function-outside-class -- static factory of this class\n static none(): InlinedWrappers {\n return new InlinedWrappers(new Set<string>());\n }\n\n /** The wrappers of a manifest, by model key (`DocumentedType.keyOf`). */\n // webpieces-disable no-function-outside-class -- static factory of this class\n static of(\n contracts: readonly ContractModel[],\n types: ReadonlyMap<string, DocumentedType>,\n homePackage: string | undefined,\n errorTypeKey: string | undefined,\n ): InlinedWrappers {\n const counter = new WrapperUseCounter(types);\n counter.countOperations(contracts);\n counter.countSchemas();\n if (errorTypeKey !== undefined) {\n counter.markNested(errorTypeKey);\n }\n return new InlinedWrappers(counter.singleUse(homePackage));\n }\n\n has(key: string): boolean {\n return this.keys.has(key);\n }\n}\n\n/** The tally {@link InlinedWrappers.of} decides from: top-level uses per key, and every nested one. */\nclass WrapperUseCounter {\n private readonly topLevel = new Map<string, number>();\n private readonly nested = new Set<string>();\n private readonly body = new SuccessBody();\n\n constructor(private readonly types: ReadonlyMap<string, DocumentedType>) {}\n\n /**\n * Every body an operation of any document can render: a POST/PUT/PATCH request (the verbs a body is\n * published for — `verbCarriesBody`, see `OperationRenderer.requestBody`) and a non-void success\n * response. A URL parameter's type is a NESTED use: a parameter schema is never an inlined wrapper. A\n * `@WpLocalOnly` endpoint is in no document, so it uses nothing.\n */\n countOperations(contracts: readonly ContractModel[]): void {\n for (const contract of contracts) {\n for (const endpoint of contract.model.endpoints) {\n this.countEndpoint(endpoint);\n }\n }\n }\n\n /** Every reference one named type makes to another — which makes the target a shared noun. */\n countSchemas(): void {\n for (const type of Array.from(this.types.values())) {\n for (const field of type.fields) {\n this.walk(field.type);\n }\n if (type.indexSignatureValue !== undefined) {\n this.walk(type.indexSignatureValue);\n }\n for (const branch of type.unionRefNames) {\n this.markNested(branch);\n }\n }\n }\n\n markNested(key: string): void {\n this.nested.add(key);\n }\n\n singleUse(homePackage: string | undefined): ReadonlySet<string> {\n const keys = new Set<string>();\n for (const key of Array.from(this.topLevel.keys())) {\n const type = this.types.get(key);\n if (\n this.topLevel.get(key) === 1 &&\n !this.nested.has(key) &&\n type !== undefined &&\n type.packageName === homePackage &&\n type.enumValues.length === 0 &&\n type.unionRefNames.length === 0\n ) {\n keys.add(key);\n }\n }\n return keys;\n }\n\n private countEndpoint(endpoint: DocumentedEndpoint): void {\n if (endpoint.localOnly) {\n return;\n }\n if (verbCarriesBody(endpoint.httpMethod) && endpoint.request !== undefined) {\n this.countBody(endpoint.request);\n }\n for (const parameter of endpoint.parameters) {\n if (parameter.type !== undefined) {\n this.walk(parameter.type);\n }\n }\n if (!this.body.isVoid(endpoint.response)) {\n this.countBody(endpoint.response!);\n }\n }\n\n /** A body that IS a named type is a top-level use; anything else (`X[]`, a map) nests it. */\n private countBody(ref: TypeRef): void {\n if (ref.kind === 'ref') {\n const key = ref.refName!;\n this.topLevel.set(key, (this.topLevel.get(key) ?? 0) + 1);\n return;\n }\n this.walk(ref);\n }\n\n private walk(ref: TypeRef): void {\n switch (ref.kind) {\n case 'ref':\n this.markNested(ref.refName!);\n return;\n case 'array':\n this.walk(ref.items!);\n return;\n case 'openMap':\n this.walk(ref.values!);\n return;\n case 'union':\n for (const branch of ref.unionRefNames) {\n this.markNested(branch);\n }\n return;\n default:\n return;\n }\n }\n}\n"]}
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OpenApiGenerator = void 0;
4
4
  const api_doc_model_1 = require("@webpieces/api-doc-model");
5
+ const core_util_1 = require("@webpieces/core-util");
5
6
  const JsonObject_1 = require("../json/JsonObject");
6
7
  const OpenApiGenerationError_1 = require("../OpenApiGenerationError");
7
8
  const GenerationInputs_1 = require("./GenerationInputs");
@@ -370,6 +371,10 @@ class OpenApiGenerator {
370
371
  }
371
372
  // A tag is added only by an operation that survived, so a document never advertises a
372
373
  // section of its sidebar that turns out to be empty.
374
+ if (endpoint.kind === core_util_1.EXTERNAL_OUTBOUND && !contractModel.entry.isWebhook()) {
375
+ throw new OpenApiGenerationError_1.OpenApiGenerationError(`${model.contractName}.${endpoint.methodName} is EXTERNAL_OUTBOUND: an outside system serves it, ` +
376
+ 'so it is not a route of ours to publish', contractModel.entry.entry, 'List the contract with "kind": "webhook" in the manifest when partners host it, or remove it from the manifest.');
377
+ }
373
378
  tags.add(tag);
374
379
  if (contractModel.entry.isWebhook()) {
375
380
  webhooks.set(this.eventName(endpoint), new JsonObject_1.JsonObject().set('post', operations.webhook(endpoint, model.contractName, tag, webhookContract)));
@@ -1 +1 @@
1
- {"version":3,"file":"OpenApiGenerator.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/OpenApiGenerator.ts"],"names":[],"mappings":";;;AAAA,4DAUkC;AAClC,mDAA2D;AAC3D,sEAAmE;AAEnE,yDAM4B;AAC5B,iDAAkE;AAClE,2DAAwD;AACxD,2DAA0E;AAC1E,uDAO2B;AAC3B,qDAAiE;AACjE,uDAAoD;AACpD,yDAAsD;AACtD,6EAA0E;AAC1E,yDAAsD;AACtD,+DAA4D;AAC5D,iDAA8C;AAC9C,2DAAwD;AACxD,iDAA8C;AAC9C,uEAAoE;AACpE,uDAAoD;AAEpD,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,UAAU,CAAC;AAElC,2EAA2E;AAC3E,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAEjD,4FAA4F;AAC5F,MAAM,eAAe,GAAG,OAAO,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAa,gBAAgB;IACR,QAAQ,GAAG,IAAI,iCAAe,EAAE,CAAC;IACjC,YAAY,GAAG,IAAI,qCAAiB,EAAE,CAAC;IACvC,cAAc,GAAG,IAAI,yCAAmB,EAAE,CAAC;IAC3C,SAAS,GAAG,IAAI,2BAAY,EAAE,CAAC;IAC/B,SAAS,GAAG,IAAI,mCAAgB,EAAE,CAAC;IAC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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;AAtvBD,4CAsvBC","sourcesContent":["import {\n ApiDocModel,\n DocumentedApiKey,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedField,\n DocumentedType,\n OperationIds,\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 { DocLinkGuard, DocumentLinkNaming } from './DocLinkGuard';\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 { HiddenFieldGuard } from './HiddenFieldGuard';\nimport { UnpublishedComponentsGuard } from './UnpublishedComponentsGuard';\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 { InlinedWrappers } from './InlinedWrappers';\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/** 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 * And a JSDoc `{@link}` the document cannot publish under its target's published name\n * ({@link DocLinkGuard}) (#1284) — a `@hidden` field's included, in the customer document. And a\n * `@hidden` field that is required, or a type whose every field is `@hidden` ({@link HiddenFieldGuard})\n * (#1246).\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 private readonly hiddenFields = new HiddenFieldGuard();\n private readonly unpublished = new UnpublishedComponentsGuard();\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 this.hiddenFields.refuse(this.mergedTypes(inputs), 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 links = new DocLinkGuard();\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, links, undocumented),\n ),\n );\n continue;\n }\n this.refuseCollisions(this.collisionsOf(inputs, contracts), inputs.manifestPath);\n const placement = new SplitPlacement(inputs.homePackage);\n const split = this.render(inputs, contracts, selection, placement);\n this.resolveLinks(links, split, inputs, contracts, selection, placement);\n this.refuseExternalReferences(split.schemas, inputs, selection);\n undocumented.collect(split.schemas.reachedTypes(), this.mergedTypes(inputs));\n // An inlined wrapper is still a published schema, so it still needs its description.\n undocumented.collect(split.schemas.inlinedTypes(), 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, links),\n ),\n );\n }\n undocumented.refuse(inputs.manifestPath);\n links.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 this.hiddenFields.refuse(model.types, where);\n // Every field, `@hidden` ones included: one components document serves every audience, and a\n // customer document that would have to withhold one of its fields refuses instead (#1246).\n const schemas = new SchemaRenderer(\n model.types,\n new SplitPlacement(model.packageName),\n InlinedWrappers.none(),\n false,\n );\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.unpublished.refuse(\n schemas.externalTypes(),\n model.types,\n inputs.upstream,\n COMPONENTS_DOCUMENT,\n where,\n );\n const undocumented = new UndocumentedSchemaGuard();\n undocumented.collect(schemas.reachedTypes(), model.types);\n undocumented.refuse(where);\n const links = new DocLinkGuard();\n links.resolve(\n rendered,\n new DocumentLinkNaming(\n model.types,\n schemas,\n new SplitPlacement(model.packageName),\n new Map(),\n false,\n ),\n COMPONENTS_DOCUMENT,\n );\n links.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 links: DocLinkGuard,\n undocumented?: UndocumentedSchemaGuard,\n ): JsonObject {\n // The discovery pass publishes nothing, so its links are not judged: the named pass below\n // reaches exactly the same prose.\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 const placement = new BundledPlacement(names);\n const rendered = this.render(inputs, contracts, selection, placement);\n this.resolveLinks(links, rendered, inputs, contracts, selection, placement);\n return rendered.document;\n }\n\n /**\n * Publish every `{@link}` in a rendered document under its target's name in THAT document (#1284),\n * recording the ones it cannot name — see {@link DocLinkGuard}.\n */\n private resolveLinks(\n links: DocLinkGuard,\n rendered: RenderedDocument,\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n placement: SchemaPlacement,\n ): void {\n const naming = new DocumentLinkNaming(\n this.mergedTypes(inputs),\n rendered.schemas,\n placement,\n this.publishedOperationIds(contracts, selection, inputs),\n selection.dropHidden,\n );\n links.resolve(rendered.document, naming, selection.fileName);\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(\n types,\n placement,\n this.wrappers(inputs, selection, types),\n selection.dropHidden,\n );\n const operations = this.operationRenderer(inputs, selection, schemas);\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, !paths.isEmpty()))\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 /** The operation renderer, carrying what this selection stamps on each operation. */\n private operationRenderer(\n inputs: GenerationInputs,\n selection: DocumentSelection,\n schemas: SchemaRenderer,\n ): OperationRenderer {\n return new OperationRenderer(\n schemas,\n selection.includeMcpExtensions,\n selection.internalNotice,\n selection.includeWebpiecesExtensions,\n inputs.manifest.operationIds,\n );\n }\n\n /**\n * The single-use request/response wrappers this document defines inline (#1303), counted over\n * EVERY contract of the manifest so a wrapper is inline or a component in every document alike.\n */\n private wrappers(\n inputs: GenerationInputs,\n selection: DocumentSelection,\n types: ReadonlyMap<string, DocumentedType>,\n ): InlinedWrappers {\n if (!selection.inlinesWrappers) {\n return InlinedWrappers.none();\n }\n const errorKey = inputs.errorType === undefined ? undefined : inputs.manifest.errors?.type;\n return InlinedWrappers.of(inputs.contracts, types, inputs.homePackage, errorKey);\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 /** `Contract.method` -> operationId, for every operation this document publishes. */\n private publishedOperationIds(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n inputs: GenerationInputs,\n ): ReadonlyMap<string, string> {\n const operationIds = new OperationIds(inputs.manifest.operationIds);\n const ids = new Map<string, 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 ids.set(\n `${model.contractName}.${endpoint.methodName}`,\n operationIds.of(model.contractName, endpoint.methodName),\n );\n }\n }\n }\n return ids;\n }\n\n /**\n * A split document's references into other packages' components documents: each must be\n * published there (#1058), and — in the customer document — none may carry a `@hidden` field,\n * which a shared components document cannot withhold (#1246).\n */\n private refuseExternalReferences(\n schemas: SchemaRenderer,\n inputs: GenerationInputs,\n selection: DocumentSelection,\n ): void {\n const external = schemas.externalTypes();\n const types = this.mergedTypes(inputs);\n const where = inputs.manifestPath;\n this.unpublished.refuse(external, types, inputs.upstream, selection.fileName, where);\n if (selection.dropHidden) {\n this.hiddenFields.refuseExternal(external, types, selection.fileName, where);\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(\n inputs: GenerationInputs,\n selection: DocumentSelection,\n hasRoutes: boolean,\n ): 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, hasRoutes));\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,4DAUkC;AAClC,oDAAyD;AACzD,mDAA2D;AAC3D,sEAAmE;AAEnE,yDAM4B;AAC5B,iDAAkE;AAClE,2DAAwD;AACxD,2DAA0E;AAC1E,uDAO2B;AAC3B,qDAAiE;AACjE,uDAAoD;AACpD,yDAAsD;AACtD,6EAA0E;AAC1E,yDAAsD;AACtD,+DAA4D;AAC5D,iDAA8C;AAC9C,2DAAwD;AACxD,iDAA8C;AAC9C,uEAAoE;AACpE,uDAAoD;AAEpD,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,UAAU,CAAC;AAElC,2EAA2E;AAC3E,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAEjD,4FAA4F;AAC5F,MAAM,eAAe,GAAG,OAAO,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAa,gBAAgB;IACR,QAAQ,GAAG,IAAI,iCAAe,EAAE,CAAC;IACjC,YAAY,GAAG,IAAI,qCAAiB,EAAE,CAAC;IACvC,cAAc,GAAG,IAAI,yCAAmB,EAAE,CAAC;IAC3C,SA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G,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;AA9vBD,4CA8vBC","sourcesContent":["import {\n ApiDocModel,\n DocumentedApiKey,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedField,\n DocumentedType,\n OperationIds,\n TypeNameCollision,\n TypeRef,\n} from '@webpieces/api-doc-model';\nimport { EXTERNAL_OUTBOUND } from '@webpieces/core-util';\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 { DocLinkGuard, DocumentLinkNaming } from './DocLinkGuard';\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 { HiddenFieldGuard } from './HiddenFieldGuard';\nimport { UnpublishedComponentsGuard } from './UnpublishedComponentsGuard';\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 { InlinedWrappers } from './InlinedWrappers';\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/** 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 * And a JSDoc `{@link}` the document cannot publish under its target's published name\n * ({@link DocLinkGuard}) (#1284) — a `@hidden` field's included, in the customer document. And a\n * `@hidden` field that is required, or a type whose every field is `@hidden` ({@link HiddenFieldGuard})\n * (#1246).\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 private readonly hiddenFields = new HiddenFieldGuard();\n private readonly unpublished = new UnpublishedComponentsGuard();\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 this.hiddenFields.refuse(this.mergedTypes(inputs), 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 links = new DocLinkGuard();\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, links, undocumented),\n ),\n );\n continue;\n }\n this.refuseCollisions(this.collisionsOf(inputs, contracts), inputs.manifestPath);\n const placement = new SplitPlacement(inputs.homePackage);\n const split = this.render(inputs, contracts, selection, placement);\n this.resolveLinks(links, split, inputs, contracts, selection, placement);\n this.refuseExternalReferences(split.schemas, inputs, selection);\n undocumented.collect(split.schemas.reachedTypes(), this.mergedTypes(inputs));\n // An inlined wrapper is still a published schema, so it still needs its description.\n undocumented.collect(split.schemas.inlinedTypes(), 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, links),\n ),\n );\n }\n undocumented.refuse(inputs.manifestPath);\n links.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 this.hiddenFields.refuse(model.types, where);\n // Every field, `@hidden` ones included: one components document serves every audience, and a\n // customer document that would have to withhold one of its fields refuses instead (#1246).\n const schemas = new SchemaRenderer(\n model.types,\n new SplitPlacement(model.packageName),\n InlinedWrappers.none(),\n false,\n );\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.unpublished.refuse(\n schemas.externalTypes(),\n model.types,\n inputs.upstream,\n COMPONENTS_DOCUMENT,\n where,\n );\n const undocumented = new UndocumentedSchemaGuard();\n undocumented.collect(schemas.reachedTypes(), model.types);\n undocumented.refuse(where);\n const links = new DocLinkGuard();\n links.resolve(\n rendered,\n new DocumentLinkNaming(\n model.types,\n schemas,\n new SplitPlacement(model.packageName),\n new Map(),\n false,\n ),\n COMPONENTS_DOCUMENT,\n );\n links.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 links: DocLinkGuard,\n undocumented?: UndocumentedSchemaGuard,\n ): JsonObject {\n // The discovery pass publishes nothing, so its links are not judged: the named pass below\n // reaches exactly the same prose.\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 const placement = new BundledPlacement(names);\n const rendered = this.render(inputs, contracts, selection, placement);\n this.resolveLinks(links, rendered, inputs, contracts, selection, placement);\n return rendered.document;\n }\n\n /**\n * Publish every `{@link}` in a rendered document under its target's name in THAT document (#1284),\n * recording the ones it cannot name — see {@link DocLinkGuard}.\n */\n private resolveLinks(\n links: DocLinkGuard,\n rendered: RenderedDocument,\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n placement: SchemaPlacement,\n ): void {\n const naming = new DocumentLinkNaming(\n this.mergedTypes(inputs),\n rendered.schemas,\n placement,\n this.publishedOperationIds(contracts, selection, inputs),\n selection.dropHidden,\n );\n links.resolve(rendered.document, naming, selection.fileName);\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(\n types,\n placement,\n this.wrappers(inputs, selection, types),\n selection.dropHidden,\n );\n const operations = this.operationRenderer(inputs, selection, schemas);\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, !paths.isEmpty()))\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 /** The operation renderer, carrying what this selection stamps on each operation. */\n private operationRenderer(\n inputs: GenerationInputs,\n selection: DocumentSelection,\n schemas: SchemaRenderer,\n ): OperationRenderer {\n return new OperationRenderer(\n schemas,\n selection.includeMcpExtensions,\n selection.internalNotice,\n selection.includeWebpiecesExtensions,\n inputs.manifest.operationIds,\n );\n }\n\n /**\n * The single-use request/response wrappers this document defines inline (#1303), counted over\n * EVERY contract of the manifest so a wrapper is inline or a component in every document alike.\n */\n private wrappers(\n inputs: GenerationInputs,\n selection: DocumentSelection,\n types: ReadonlyMap<string, DocumentedType>,\n ): InlinedWrappers {\n if (!selection.inlinesWrappers) {\n return InlinedWrappers.none();\n }\n const errorKey = inputs.errorType === undefined ? undefined : inputs.manifest.errors?.type;\n return InlinedWrappers.of(inputs.contracts, types, inputs.homePackage, errorKey);\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 /** `Contract.method` -> operationId, for every operation this document publishes. */\n private publishedOperationIds(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n inputs: GenerationInputs,\n ): ReadonlyMap<string, string> {\n const operationIds = new OperationIds(inputs.manifest.operationIds);\n const ids = new Map<string, 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 ids.set(\n `${model.contractName}.${endpoint.methodName}`,\n operationIds.of(model.contractName, endpoint.methodName),\n );\n }\n }\n }\n return ids;\n }\n\n /**\n * A split document's references into other packages' components documents: each must be\n * published there (#1058), and — in the customer document — none may carry a `@hidden` field,\n * which a shared components document cannot withhold (#1246).\n */\n private refuseExternalReferences(\n schemas: SchemaRenderer,\n inputs: GenerationInputs,\n selection: DocumentSelection,\n ): void {\n const external = schemas.externalTypes();\n const types = this.mergedTypes(inputs);\n const where = inputs.manifestPath;\n this.unpublished.refuse(external, types, inputs.upstream, selection.fileName, where);\n if (selection.dropHidden) {\n this.hiddenFields.refuseExternal(external, types, selection.fileName, where);\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 if (endpoint.kind === EXTERNAL_OUTBOUND && !contractModel.entry.isWebhook()) {\n throw new OpenApiGenerationError(\n `${model.contractName}.${endpoint.methodName} is EXTERNAL_OUTBOUND: an outside system serves it, ` +\n 'so it is not a route of ours to publish',\n contractModel.entry.entry,\n 'List the contract with \"kind\": \"webhook\" in the manifest when partners host it, or remove it from the manifest.',\n );\n }\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(\n inputs: GenerationInputs,\n selection: DocumentSelection,\n hasRoutes: boolean,\n ): 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, hasRoutes));\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"]}
@@ -170,16 +170,25 @@ export declare class OperationRenderer {
170
170
  */
171
171
  private operationOf;
172
172
  /**
173
- * The request DTO as a body. Only for `POST`: OpenAPI gives a `GET` body no defined semantics and
174
- * most tooling drops it, so publishing one would document a request no generated client sends.
173
+ * Every `@PathParam` / `@QueryParam` argument as an OpenAPI Parameter Object, in declaration order.
174
+ * A list query argument is `style: form, explode: true` — repeated keys (`a=1&a=2`), which is what
175
+ * the webpieces client sends. Absent (not `[]`) when the endpoint binds nothing to the URL, so a
176
+ * contract with no URL parameters renders byte-identically to before.
177
+ */
178
+ private parameters;
179
+ /**
180
+ * The request DTO as a body. Only for a verb that carries one (`verbCarriesBody`: POST, PUT,
181
+ * PATCH): OpenAPI gives a `GET`/`DELETE` body no defined semantics and most tooling drops it, so
182
+ * publishing one would document a request no generated client sends.
175
183
  */
176
184
  private requestBody;
177
185
  private responses;
178
186
  private success;
179
187
  private failure;
180
188
  /**
181
- * The method's `@returns` text (#1292). With none, a `void` operation keeps the derived
182
- * acknowledgement sentence — there is no body for `@returns` to describe. A body-carrying
189
+ * The method's `@returns` text (#1292). With none, a `void` operation gets a derived sentence —
190
+ * there is no body for `@returns` to describe: "no body" for a served route (a 204), and the
191
+ * acknowledgement sentence for a webhook the partner answers. A body-carrying
183
192
  * operation with none never gets here: {@link MissingReturnsGuard} refuses it before any document
184
193
  * renders, so there is no filler fallback to publish.
185
194
  */
@@ -8,6 +8,11 @@ const SuccessBody_1 = require("./SuccessBody");
8
8
  const OpenApiGenerationError_1 = require("../OpenApiGenerationError");
9
9
  /** What a webhook's `void` return means on the wire, said once. */
10
10
  const ACKNOWLEDGE = 'Return any 2xx to acknowledge delivery. The body is ignored.';
11
+ /**
12
+ * What a served route's `void` return (`responseBody: NONE`) means on the wire: our server answers
13
+ * `204` with 0 bytes (#1339). Only a WEBHOOK keeps {@link ACKNOWLEDGE} — there the PARTNER answers.
14
+ */
15
+ const NO_CONTENT = 'Success. The response has no body.';
11
16
  /** The response document, and the responses a document-wide failure contract adds to it. */
12
17
  class ResponseContract {
13
18
  errors;
@@ -127,8 +132,9 @@ class OperationRenderer {
127
132
  .set('summary', endpoint.summary)
128
133
  .set('description', this.describe(endpoint, isRoute))
129
134
  .set('tags', [tag])
135
+ .set('parameters', this.parameters(endpoint, contractName))
130
136
  .set('requestBody', this.requestBody(endpoint, contractName))
131
- .set('responses', this.responses(endpoint, contractName, contract));
137
+ .set('responses', this.responses(endpoint, contractName, contract, isRoute));
132
138
  }
133
139
  /** The declared `@WpAuth` methods, verbatim — never in the public document (#1303). */
134
140
  authentication(endpoint) {
@@ -184,7 +190,7 @@ class OperationRenderer {
184
190
  if (endpoint.kind === core_util_1.CRON) {
185
191
  return 'Triggered on a schedule, not by a caller.';
186
192
  }
187
- if (endpoint.kind === core_util_1.EXTERNAL) {
193
+ if (endpoint.kind === core_util_1.EXTERNAL_INBOUND) {
188
194
  const caller = endpoint.options.calledBy;
189
195
  return caller === undefined
190
196
  ? 'Triggered by an outside system.'
@@ -264,11 +270,37 @@ class OperationRenderer {
264
270
  return endpoint.operation === core_util_1.WRITE_IDEMPOTENT ? core_util_1.WRITE_IDEMPOTENT : core_util_1.WRITE;
265
271
  }
266
272
  /**
267
- * The request DTO as a body. Only for `POST`: OpenAPI gives a `GET` body no defined semantics and
268
- * most tooling drops it, so publishing one would document a request no generated client sends.
273
+ * Every `@PathParam` / `@QueryParam` argument as an OpenAPI Parameter Object, in declaration order.
274
+ * A list query argument is `style: form, explode: true` — repeated keys (`a=1&a=2`), which is what
275
+ * the webpieces client sends. Absent (not `[]`) when the endpoint binds nothing to the URL, so a
276
+ * contract with no URL parameters renders byte-identically to before.
277
+ */
278
+ parameters(endpoint, contractName) {
279
+ if (endpoint.parameters.length === 0) {
280
+ return undefined;
281
+ }
282
+ return endpoint.parameters.map((parameter, index) => {
283
+ const pointer = `#/paths/${contractName}_${endpoint.methodName}/parameters/${index}`;
284
+ const schema = parameter.type === undefined
285
+ ? new JsonObject_1.JsonObject().set('type', 'string')
286
+ : this.schemas.type(parameter.type, pointer);
287
+ const isList = parameter.type?.kind === 'array';
288
+ return new JsonObject_1.JsonObject()
289
+ .set('name', parameter.name)
290
+ .set('in', parameter.location)
291
+ .set('required', parameter.required)
292
+ .set('style', isList ? 'form' : undefined)
293
+ .set('explode', isList ? true : undefined)
294
+ .set('schema', schema);
295
+ });
296
+ }
297
+ /**
298
+ * The request DTO as a body. Only for a verb that carries one (`verbCarriesBody`: POST, PUT,
299
+ * PATCH): OpenAPI gives a `GET`/`DELETE` body no defined semantics and most tooling drops it, so
300
+ * publishing one would document a request no generated client sends.
269
301
  */
270
302
  requestBody(endpoint, contractName) {
271
- if (endpoint.httpMethod !== 'POST' || endpoint.request === undefined) {
303
+ if (!(0, core_util_1.verbCarriesBody)(endpoint.httpMethod) || endpoint.request === undefined) {
272
304
  return undefined;
273
305
  }
274
306
  const pointer = `#/paths/${contractName}_${endpoint.methodName}/requestBody`;
@@ -279,9 +311,12 @@ class OperationRenderer {
279
311
  .set('required', true)
280
312
  .set('content', new JsonObject_1.JsonObject().set(media, new JsonObject_1.JsonObject().set('schema', this.schemas.body(endpoint.request, pointer))));
281
313
  }
282
- responses(endpoint, contractName, contract) {
314
+ responses(endpoint, contractName, contract, isRoute) {
283
315
  const responses = new JsonObject_1.JsonObject();
284
- responses.set('200', this.success(endpoint, contractName, contract));
316
+ // A void ROUTE is 204 with 0 bytes, exactly what our server sends. A void WEBHOOK stays a
317
+ // `200` the partner returns — any 2xx acknowledges, and its body is ignored.
318
+ const status = isRoute && this.body.isVoid(endpoint.response) ? '204' : '200';
319
+ responses.set(status, this.success(endpoint, contractName, contract, isRoute));
285
320
  for (const error of contract.errors) {
286
321
  // A failure only an AUTHENTICATED operation can have (a 401) is not one a public
287
322
  // endpoint can return, so it is not documented there.
@@ -292,10 +327,10 @@ class OperationRenderer {
292
327
  }
293
328
  return responses;
294
329
  }
295
- success(endpoint, contractName, contract) {
330
+ success(endpoint, contractName, contract, isRoute) {
296
331
  const isVoid = this.body.isVoid(endpoint.response);
297
332
  const response = new JsonObject_1.JsonObject()
298
- .set('description', this.successDescription(endpoint, contractName, isVoid))
333
+ .set('description', this.successDescription(endpoint, contractName, isVoid, isRoute))
299
334
  .set('headers', contract.headers);
300
335
  if (isVoid) {
301
336
  return response;
@@ -313,12 +348,13 @@ class OperationRenderer {
313
348
  return response.set('content', new JsonObject_1.JsonObject().set('application/json', new JsonObject_1.JsonObject().set('schema', contract.errorSchemaRef)));
314
349
  }
315
350
  /**
316
- * The method's `@returns` text (#1292). With none, a `void` operation keeps the derived
317
- * acknowledgement sentence — there is no body for `@returns` to describe. A body-carrying
351
+ * The method's `@returns` text (#1292). With none, a `void` operation gets a derived sentence —
352
+ * there is no body for `@returns` to describe: "no body" for a served route (a 204), and the
353
+ * acknowledgement sentence for a webhook the partner answers. A body-carrying
318
354
  * operation with none never gets here: {@link MissingReturnsGuard} refuses it before any document
319
355
  * renders, so there is no filler fallback to publish.
320
356
  */
321
- successDescription(endpoint, contractName, isVoid) {
357
+ successDescription(endpoint, contractName, isVoid, isRoute) {
322
358
  const returns = this.prose(endpoint.returnsDescription);
323
359
  if (returns !== undefined) {
324
360
  return returns;
@@ -327,7 +363,7 @@ class OperationRenderer {
327
363
  throw new OpenApiGenerationError_1.OpenApiGenerationError(`${endpoint.methodName} has a response body but no @returns`, `${contractName}.${endpoint.methodName} (the contract method's JSDoc)`, 'Add a `@returns` line to its JSDoc. MissingReturnsGuard should have refused this ' +
328
364
  'before rendering; reaching here is a generator defect.');
329
365
  }
330
- return ACKNOWLEDGE;
366
+ return isRoute ? NO_CONTENT : ACKNOWLEDGE;
331
367
  }
332
368
  prose(text) {
333
369
  return text === undefined || text.trim() === '' ? undefined : text;
@@ -1 +1 @@
1
- {"version":3,"file":"OperationRenderer.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/OperationRenderer.ts"],"names":[],"mappings":";;;AAAA,4DAKkC;AAClC,oDAU8B;AAC9B,mDAA2D;AAG3D,+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,O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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;AAnWD,8CAmWC","sourcesContent":["import {\n DocumentedAuthMethod,\n DocumentedEndpoint,\n OperationIds,\n OperationIdStyle,\n} 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 } 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 private readonly ids: OperationIds;\n\n constructor(\n private readonly schemas: SchemaRenderer,\n /** True only for the MCP document — see {@link withMcp}. */\n private readonly includeMcp: boolean,\n /** True only for the private document — see {@link triggerSentence}. */\n private readonly includeTrigger: boolean,\n /**\n * False only for the PUBLIC document (#1303): `x-webpieces-authentication` (whose `arguments`\n * are the TypeScript identifiers passed to `@WpAuth` — private names a partner cannot use) and\n * `x-webpieces-webhook` are internal tooling's. A partner's authentication is already in the\n * standard `components.securitySchemes` + `security`, and a webhook already sits in the\n * standard `webhooks:` block.\n */\n private readonly includeWebpieces: boolean,\n /** The manifest's `operationIds` — see {@link operationIdOf}. */\n operationIds: OperationIdStyle,\n ) {\n this.ids = new OperationIds(operationIds);\n }\n\n /**\n * The published `operationId`, in the manifest's chosen style (#1270).\n *\n * Public because the generator checks uniqueness with the SAME function before rendering: a\n * second spelling of the id there could pass a collision this one then publishes.\n */\n operationIdOf(endpoint: DocumentedEndpoint, contractName: string): string {\n return this.ids.of(contractName, endpoint.methodName);\n }\n\n /** An ordinary served route. */\n operation(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n security: readonly JsonValue[] | undefined,\n ): JsonObject {\n const operation = this.common(endpoint, contractName, tag, contract, true);\n // An endpoint that authenticates NOBODY says so explicitly: `security: []` is OpenAPI's\n // spelling of \"no credential required\", and leaving the key off instead means \"inherit the\n // document's\", which is a different statement that happens to coincide today.\n const explicit = this.isPublic(endpoint) ? [] : security;\n operation.set('security', explicit === undefined ? undefined : explicit.slice());\n return this.withMcp(operation, endpoint);\n }\n\n /**\n * A call WE make to a PARTNER's server.\n *\n * It carries `x-webpieces-webhook: true` in every document but the public one (#1303), where the\n * standard `webhooks:` block it sits in already says so. It gets no trigger sentence and no security at all, because neither is true of\n * it: nothing of ours triggers it and nothing of ours authenticates it — our api key must never\n * be published as a guard on somebody else's endpoint.\n *\n * It gets no retry sentence either (#1302). That sentence tells a CALLER whether it may repeat\n * the call, and the partner never calls a webhook — WE do, and we retry delivery ourselves. The\n * `@Endpoint` operation on a webhook method is an inert value the decorator requires (the\n * contract is never mounted as a route), so on a webhook \"NOT safe to retry\" would be backwards:\n * the receiver's concern is that one event can arrive more than once.\n */\n webhook(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n ): JsonObject {\n const operation = this.common(endpoint, contractName, tag, contract, false);\n return this.withMcp(\n operation.set('x-webpieces-webhook', this.includeWebpieces ? true : undefined),\n endpoint,\n );\n }\n\n private common(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n isRoute: boolean,\n ): JsonObject {\n return new JsonObject()\n .set('operationId', this.operationIdOf(endpoint, contractName))\n .set('x-webpieces-authentication', this.authentication(endpoint))\n .set('summary', endpoint.summary)\n .set('description', this.describe(endpoint, isRoute))\n .set('tags', [tag])\n .set('requestBody', this.requestBody(endpoint, contractName))\n .set('responses', this.responses(endpoint, contractName, contract));\n }\n\n /** The declared `@WpAuth` methods, verbatim — never in the public document (#1303). */\n private authentication(endpoint: DocumentedEndpoint): readonly JsonValue[] | undefined {\n if (!this.includeWebpieces) {\n return undefined;\n }\n return endpoint.auth?.methods.map((method: DocumentedAuthMethod) =>\n new JsonObject().set('kind', method.kind).set('arguments', method.argumentTexts),\n );\n }\n\n /**\n * The JSDoc body, plus the sentences that are DERIVED rather than written.\n *\n * The retry sentence comes from the endpoint's declared `operation`, which every integration\n * wants to know and most APIs state nowhere. It is a SENTENCE and not a vendor extension because\n * Swagger UI and most themes do not render `x-` extensions and no standard generator reads\n * `x-webpieces-*`: an extension would be invisible to the human and unread by the machine. The\n * mapping it is derived from is published once, in `info.description`, so the rule is stated and\n * not only its consequences. It is stated on ROUTES only — a webhook is a call we make, so the\n * caller-facing retry sentence does not apply to it (see {@link webhook}).\n */\n private describe(endpoint: DocumentedEndpoint, isRoute: boolean): string | undefined {\n const parts: string[] = [];\n const body = this.prose(endpoint.description);\n if (body !== undefined) {\n parts.push(body);\n }\n // Both derived sentences are about a call the READER makes to us (may I repeat it? what\n // fires it?). A webhook is a call WE make to the reader, so neither applies (#1302).\n if (isRoute) {\n parts.push(this.retrySentence(endpoint));\n if (this.includeTrigger) {\n parts.push(this.triggerSentence(endpoint));\n }\n }\n if (endpoint.openWorld) {\n parts.push(\n 'Reaches beyond this service: it may act on an external system, so its effects ' +\n 'are not all visible here.',\n );\n }\n return parts.length === 0 ? undefined : parts.join('\\n\\n');\n }\n\n /**\n * WHAT FIRES this endpoint, in the private document only.\n *\n * A customer calls what they are given a url for; whether ours runs off a queue or a clock is our\n * business and would only invite a question they cannot act on. It is a SENTENCE and not\n * `x-webpieces-trigger` for the same reason the retry sentence is: Swagger UI and most themes do\n * not render `x-` extensions, and no standard generator reads `x-webpieces-*`, so an extension is\n * invisible to the human and unread by the machine.\n */\n private triggerSentence(endpoint: DocumentedEndpoint): string {\n if (endpoint.kind === CLOUDTASKS) {\n return 'Triggered by a queued task, delivered asynchronously.';\n }\n if (endpoint.kind === CRON) {\n return 'Triggered on a schedule, not by a caller.';\n }\n if (endpoint.kind === EXTERNAL) {\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.body(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.body(endpoint.response!, pointer)),\n ),\n );\n }\n\n private failure(description: string, contract: ResponseContract): JsonObject {\n const response = new JsonObject()\n .set('description', description)\n .set('headers', contract.headers);\n if (contract.errorSchemaRef === undefined) {\n return response;\n }\n return response.set(\n 'content',\n new JsonObject().set(\n 'application/json',\n new JsonObject().set('schema', contract.errorSchemaRef),\n ),\n );\n }\n\n /**\n * The method's `@returns` text (#1292). With none, a `void` operation 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":";;;AAAA,4DAMkC;AAClC,oDAU8B;AAC9B,mDAA2D;AAG3D,+CAA4C;AAC5C,sEAAmE;AAEnE,mEAAmE;AACnE,MAAM,WAAW,GAAG,8DAA8D,CAAC;AAEnF;;;GAGG;AACH,MAAM,UAAU,GAAG,oCAAoC,CAAC;AAExD,4FAA4F;AAC5F,MAAa,gBAAgB;IAGZ;IAEA;IAMA;IAVb;IACI,4DAA4D;IACnD,MAAqC;IAC9C,uEAAuE;IAC9D,cAAsC;IAC/C;;;;OAIG;IACM,OAA+B;QAR/B,WAAM,GAAN,MAAM,CAA+B;QAErC,mBAAc,GAAd,cAAc,CAAwB;QAMtC,YAAO,GAAP,OAAO,CAAwB;IACzC,CAAC;CACP;AAbD,4CAaC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAa,iBAAiB;IAKL;IAEA;IAEA;IAQA;IAhBJ,IAAI,GAAG,IAAI,yBAAW,EAAE,CAAC;IACzB,GAAG,CAAe;IAEnC,YACqB,OAAuB;IACxC,4DAA4D;IAC3C,UAAmB;IACpC,wEAAwE;IACvD,cAAuB;IACxC;;;;;;OAMG;IACc,gBAAyB;IAC1C,iEAAiE;IACjE,YAA8B;QAdb,YAAO,GAAP,OAAO,CAAgB;QAEvB,eAAU,GAAV,UAAU,CAAS;QAEnB,mBAAc,GAAd,cAAc,CAAS;QAQvB,qBAAgB,GAAhB,gBAAgB,CAAS;QAI1C,IAAI,CAAC,GAAG,GAAG,IAAI,4BAAY,CAAC,YAAY,CAAC,CAAC;IAC9C,CAAC;IAED;;;;;OAKG;IACH,aAAa,CAAC,QAA4B,EAAE,YAAoB;QAC5D,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,YAAY,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC1D,CAAC;IAED,gCAAgC;IAChC,SAAS,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AAC;aAC/B,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;QACtC,IAAI,QAAQ,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;YACxC,OAAO,QAAQ,CAAC;QACpB,CAAC;QACD,OAAO,QAAQ,CAAC,GAAG,CACf,SAAS,EACT,IAAI,uBAAU,EAAE,CAAC,GAAG,CAChB,kBAAkB,EAClB,IAAI,uBAAU,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,cAAc,CAAC,CAC1D,CACJ,CAAC;IACN,CAAC;IAED;;;;;;OAMG;IACK,kBAAkB,CACtB,QAA4B,EAC5B,YAAoB,EACpB,MAAe,EACf,OAAgB;QAEhB,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;QACxD,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO,OAAO,CAAC;QACnB,CAAC;QACD,IAAI,CAAC,MAAM,EAAE,CAAC;YACV,MAAM,IAAI,+CAAsB,CAC5B,GAAG,QAAQ,CAAC,UAAU,sCAAsC,EAC5D,GAAG,YAAY,IAAI,QAAQ,CAAC,UAAU,gCAAgC,EACtE,mFAAmF;gBAC/E,wDAAwD,CAC/D,CAAC;QACN,CAAC;QACD,OAAO,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC;IAC9C,CAAC;IAEO,KAAK,CAAC,IAAwB;QAClC,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IACvE,CAAC;CACJ;AA1YD,8CA0YC","sourcesContent":["import {\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedParameter,\n OperationIds,\n OperationIdStyle,\n} from '@webpieces/api-doc-model';\nimport {\n CLOUDTASKS,\n CRON,\n EXTERNAL_INBOUND,\n mcpHintsForOperation,\n READ,\n RPC,\n WRITE,\n WRITE_IDEMPOTENT,\n verbCarriesBody,\n} from '@webpieces/core-util';\nimport { JsonObject, JsonValue } from '../json/JsonObject';\nimport { ErrorResponseEntry } from '../manifest/OpenApiManifest';\nimport { SchemaRenderer } from './SchemaRenderer';\nimport { SuccessBody } from './SuccessBody';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\n\n/** What a webhook's `void` return means on the wire, said once. */\nconst ACKNOWLEDGE = 'Return any 2xx to acknowledge delivery. The body is ignored.';\n\n/**\n * What a served route's `void` return (`responseBody: NONE`) means on the wire: our server answers\n * `204` with 0 bytes (#1339). Only a WEBHOOK keeps {@link ACKNOWLEDGE} — there the PARTNER answers.\n */\nconst NO_CONTENT = 'Success. The response has no body.';\n\n/** The response document, and the responses a document-wide failure contract adds to it. */\nexport class ResponseContract {\n constructor(\n /** The manifest's `errors.responses`, in declared order. */\n readonly errors: readonly ErrorResponseEntry[],\n /** `$ref` at the error body schema, when the manifest declared one. */\n readonly errorSchemaRef: JsonObject | undefined,\n /**\n * Header name -> its `components.headers` `$ref`, on the success response AND on every\n * failure listed for the operation (#1270). The server stamps the header on every response,\n * and the failing one is the response a partner most needs to quote back.\n */\n readonly headers: JsonObject | undefined,\n ) {}\n}\n\n/**\n * ONE {@link DocumentedEndpoint} -> one OpenAPI Operation Object.\n *\n * ## `summary` is the method's `@summary` JSDoc tag — a short title, never a sentence (#1296)\n *\n * A docs theme titles the endpoint's page from `summary` and labels its sidebar with it, and puts\n * `description` in the body. It used to be the bare method name, which put code identifiers in every\n * heading. It is now the `@summary` line the author wrote — one line, at most 100 characters,\n * REQUIRED on every published operation by {@link SummaryGuard} — and the tag is not part of\n * `description`, so the page does not repeat its own heading. The code identifier stays published as\n * `operationId`, which is what a generated client names the method. The same line is the MCP tool's\n * `title`, so a partner's docs page and an agent's tool list name the endpoint identically.\n *\n * ## The MCP extensions ride HERE, on the operation\n *\n * `x-mcp-tool`, `x-mcp-hints`, `x-mcp-description` and `x-mcp-auth` are stamped on every operation\n * carrying the tool decorator, hidden or not: an internal endpoint that is an agent tool is a\n * legitimate agent tool, and requiring it to be published to partners in order to be one would be\n * exactly the wrong coupling.\n *\n * They are stamped on the BASE, which every published document is derived from, and\n * {@link DocumentDeriver} STRIPS them from the customer document. Stamping-then-stripping rather than\n * rendering the customer document without them is the same choice the whole deriver rests on: one\n * render of one operation, so two documents holding it cannot disagree about anything else in it.\n */\nexport class OperationRenderer {\n private readonly body = new SuccessBody();\n private readonly ids: OperationIds;\n\n constructor(\n private readonly schemas: SchemaRenderer,\n /** True only for the MCP document — see {@link withMcp}. */\n private readonly includeMcp: boolean,\n /** True only for the private document — see {@link triggerSentence}. */\n private readonly includeTrigger: boolean,\n /**\n * False only for the PUBLIC document (#1303): `x-webpieces-authentication` (whose `arguments`\n * are the TypeScript identifiers passed to `@WpAuth` — private names a partner cannot use) and\n * `x-webpieces-webhook` are internal tooling's. A partner's authentication is already in the\n * standard `components.securitySchemes` + `security`, and a webhook already sits in the\n * standard `webhooks:` block.\n */\n private readonly includeWebpieces: boolean,\n /** The manifest's `operationIds` — see {@link operationIdOf}. */\n operationIds: OperationIdStyle,\n ) {\n this.ids = new OperationIds(operationIds);\n }\n\n /**\n * The published `operationId`, in the manifest's chosen style (#1270).\n *\n * Public because the generator checks uniqueness with the SAME function before rendering: a\n * second spelling of the id there could pass a collision this one then publishes.\n */\n operationIdOf(endpoint: DocumentedEndpoint, contractName: string): string {\n return this.ids.of(contractName, endpoint.methodName);\n }\n\n /** An ordinary served route. */\n operation(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n security: readonly JsonValue[] | undefined,\n ): JsonObject {\n const operation = this.common(endpoint, contractName, tag, contract, true);\n // An endpoint that authenticates NOBODY says so explicitly: `security: []` is OpenAPI's\n // spelling of \"no credential required\", and leaving the key off instead means \"inherit the\n // document's\", which is a different statement that happens to coincide today.\n const explicit = this.isPublic(endpoint) ? [] : security;\n operation.set('security', explicit === undefined ? undefined : explicit.slice());\n return this.withMcp(operation, endpoint);\n }\n\n /**\n * A call WE make to a PARTNER's server.\n *\n * It carries `x-webpieces-webhook: true` in every document but the public one (#1303), where the\n * standard `webhooks:` block it sits in already says so. It gets no trigger sentence and no security at all, because neither is true of\n * it: nothing of ours triggers it and nothing of ours authenticates it — our api key must never\n * be published as a guard on somebody else's endpoint.\n *\n * It gets no retry sentence either (#1302). That sentence tells a CALLER whether it may repeat\n * the call, and the partner never calls a webhook — WE do, and we retry delivery ourselves. The\n * `@Endpoint` operation on a webhook method is an inert value the decorator requires (the\n * contract is never mounted as a route), so on a webhook \"NOT safe to retry\" would be backwards:\n * the receiver's concern is that one event can arrive more than once.\n */\n webhook(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n ): JsonObject {\n const operation = this.common(endpoint, contractName, tag, contract, false);\n return this.withMcp(\n operation.set('x-webpieces-webhook', this.includeWebpieces ? true : undefined),\n endpoint,\n );\n }\n\n private common(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n isRoute: boolean,\n ): JsonObject {\n return new JsonObject()\n .set('operationId', this.operationIdOf(endpoint, contractName))\n .set('x-webpieces-authentication', this.authentication(endpoint))\n .set('summary', endpoint.summary)\n .set('description', this.describe(endpoint, isRoute))\n .set('tags', [tag])\n .set('parameters', this.parameters(endpoint, contractName))\n .set('requestBody', this.requestBody(endpoint, contractName))\n .set('responses', this.responses(endpoint, contractName, contract, isRoute));\n }\n\n /** The declared `@WpAuth` methods, verbatim — never in the public document (#1303). */\n private authentication(endpoint: DocumentedEndpoint): readonly JsonValue[] | undefined {\n if (!this.includeWebpieces) {\n return undefined;\n }\n return endpoint.auth?.methods.map((method: DocumentedAuthMethod) =>\n new JsonObject().set('kind', method.kind).set('arguments', method.argumentTexts),\n );\n }\n\n /**\n * The JSDoc body, plus the sentences that are DERIVED rather than written.\n *\n * The retry sentence comes from the endpoint's declared `operation`, which every integration\n * wants to know and most APIs state nowhere. It is a SENTENCE and not a vendor extension because\n * Swagger UI and most themes do not render `x-` extensions and no standard generator reads\n * `x-webpieces-*`: an extension would be invisible to the human and unread by the machine. The\n * mapping it is derived from is published once, in `info.description`, so the rule is stated and\n * not only its consequences. It is stated on ROUTES only — a webhook is a call we make, so the\n * caller-facing retry sentence does not apply to it (see {@link webhook}).\n */\n private describe(endpoint: DocumentedEndpoint, isRoute: boolean): string | undefined {\n const parts: string[] = [];\n const body = this.prose(endpoint.description);\n if (body !== undefined) {\n parts.push(body);\n }\n // Both derived sentences are about a call the READER makes to us (may I repeat it? what\n // fires it?). A webhook is a call WE make to the reader, so neither applies (#1302).\n if (isRoute) {\n parts.push(this.retrySentence(endpoint));\n if (this.includeTrigger) {\n parts.push(this.triggerSentence(endpoint));\n }\n }\n if (endpoint.openWorld) {\n parts.push(\n 'Reaches beyond this service: it may act on an external system, so its effects ' +\n 'are not all visible here.',\n );\n }\n return parts.length === 0 ? undefined : parts.join('\\n\\n');\n }\n\n /**\n * WHAT FIRES this endpoint, in the private document only.\n *\n * A customer calls what they are given a url for; whether ours runs off a queue or a clock is our\n * business and would only invite a question they cannot act on. It is a SENTENCE and not\n * `x-webpieces-trigger` for the same reason the retry sentence is: Swagger UI and most themes do\n * not render `x-` extensions, and no standard generator reads `x-webpieces-*`, so an extension is\n * invisible to the human and unread by the machine.\n */\n private triggerSentence(endpoint: DocumentedEndpoint): string {\n if (endpoint.kind === CLOUDTASKS) {\n return 'Triggered by a queued task, delivered asynchronously.';\n }\n if (endpoint.kind === CRON) {\n return 'Triggered on a schedule, not by a caller.';\n }\n if (endpoint.kind === EXTERNAL_INBOUND) {\n const caller = endpoint.options.calledBy;\n return caller === undefined\n ? 'Triggered by an outside system.'\n : `Triggered by an outside system: ${caller}.`;\n }\n return endpoint.kind === RPC\n ? 'Triggered by a direct call.'\n : `Triggered by: ${endpoint.kind}.`;\n }\n\n /** An endpoint whose declared credential is \"none\", said out loud rather than left absent. */\n private isPublic(endpoint: DocumentedEndpoint): boolean {\n return endpoint.auth?.publicReason !== undefined;\n }\n\n private retrySentence(endpoint: DocumentedEndpoint): string {\n if (endpoint.operation === READ) {\n return 'Safe to retry: this operation is read-only and idempotent.';\n }\n if (endpoint.operation === WRITE_IDEMPOTENT) {\n return 'Safe to retry: this operation changes state but is idempotent.';\n }\n return 'NOT safe to retry: this operation changes state and is not idempotent.';\n }\n\n /**\n * The MCP extensions, stamped only on the document that has an agent for a reader.\n *\n * ## The three side-effect hints are COMPUTED, never declared\n *\n * `mcpHintsForOperation` in `@webpieces/core-util` is the one place the mapping from\n * `READ | WRITE_IDEMPOTENT | WRITE` to `readOnlyHint` / `destructiveHint` / `idempotentHint`\n * lives, and this calls it rather than reimplementing it. The endpoint's `operation` already\n * states whether repeating the call is safe; a hand-declared hint would be a second answer to a\n * question the contract has answered, and the two could disagree. `openWorldHint` is the only one\n * a human declares, because it is a judgement about the world rather than a consequence of the\n * operation.\n *\n * ## The title is the operation's `summary`, published as the Tool's `title` AND `annotations.title`\n *\n * `x-mcp-title` and `x-mcp-hints.title` carry the `@summary` line exactly as `tools/list` serves it:\n * `Tool.title` for clients on the 2025-06-18+ spec and `annotations.title` (the block `x-mcp-hints`\n * mirrors) for older clients and the Claude Connectors Directory (#1296). One source, so they cannot\n * differ from the operation's own `summary`.\n *\n * ## There is no separate MCP description\n *\n * The agent reads the operation's `description` — the method's JSDoc — byte-identical to what the\n * partner reads. `x-mcp-description` appears ONLY when the author wrote an explicit `@mcp` JSDoc\n * tag, which is a deliberate act rather than a second copy of the same paragraph.\n */\n private withMcp(operation: JsonObject, endpoint: DocumentedEndpoint): JsonObject {\n if (!this.includeMcp || endpoint.mcpTool === undefined) {\n return operation;\n }\n const hints = mcpHintsForOperation(this.operationOf(endpoint), endpoint.openWorld);\n return operation\n .set('x-mcp-tool', endpoint.mcpTool.name)\n .set('x-mcp-title', endpoint.summary)\n .set(\n 'x-mcp-hints',\n new JsonObject()\n .set('title', endpoint.summary)\n .set('readOnlyHint', hints.readOnlyHint)\n .set('destructiveHint', hints.destructiveHint)\n .set('idempotentHint', hints.idempotentHint)\n .set('openWorldHint', hints.openWorldHint),\n )\n .set('x-mcp-description', this.prose(endpoint.mcpDescription))\n .set('x-webpieces-authorization', endpoint.authorizationText);\n }\n\n /**\n * The endpoint's operation as the REAL exported constant.\n *\n * The model carries it as a string, verbatim from the source, because the model invents no\n * taxonomy. Matching it back to the constant here — rather than casting — is what makes a rename\n * of `WRITE_IDEMPOTENT` in `core-util` a compile error in this file.\n */\n private operationOf(\n endpoint: DocumentedEndpoint,\n ): typeof READ | typeof WRITE_IDEMPOTENT | typeof WRITE {\n if (endpoint.operation === READ) {\n return READ;\n }\n return endpoint.operation === WRITE_IDEMPOTENT ? WRITE_IDEMPOTENT : WRITE;\n }\n\n /**\n * Every `@PathParam` / `@QueryParam` argument as an OpenAPI Parameter Object, in declaration order.\n * A list query argument is `style: form, explode: true` — repeated keys (`a=1&a=2`), which is what\n * the webpieces client sends. Absent (not `[]`) when the endpoint binds nothing to the URL, so a\n * contract with no URL parameters renders byte-identically to before.\n */\n private parameters(\n endpoint: DocumentedEndpoint,\n contractName: string,\n ): readonly JsonValue[] | undefined {\n if (endpoint.parameters.length === 0) {\n return undefined;\n }\n return endpoint.parameters.map((parameter: DocumentedParameter, index: number) => {\n const pointer = `#/paths/${contractName}_${endpoint.methodName}/parameters/${index}`;\n const schema =\n parameter.type === undefined\n ? new JsonObject().set('type', 'string')\n : this.schemas.type(parameter.type, pointer);\n const isList = parameter.type?.kind === 'array';\n return new JsonObject()\n .set('name', parameter.name)\n .set('in', parameter.location)\n .set('required', parameter.required)\n .set('style', isList ? 'form' : undefined)\n .set('explode', isList ? true : undefined)\n .set('schema', schema);\n });\n }\n\n /**\n * The request DTO as a body. Only for a verb that carries one (`verbCarriesBody`: POST, PUT,\n * PATCH): OpenAPI gives a `GET`/`DELETE` body no defined semantics and most tooling drops it, so\n * publishing one would document a request no generated client sends.\n */\n private requestBody(\n endpoint: DocumentedEndpoint,\n contractName: string,\n ): JsonObject | undefined {\n if (!verbCarriesBody(endpoint.httpMethod) || endpoint.request === undefined) {\n return undefined;\n }\n const pointer = `#/paths/${contractName}_${endpoint.methodName}/requestBody`;\n const media = endpoint.options.formPost\n ? 'application/x-www-form-urlencoded'\n : 'application/json';\n return new JsonObject()\n .set('required', true)\n .set(\n 'content',\n new JsonObject().set(\n media,\n new JsonObject().set('schema', this.schemas.body(endpoint.request, pointer)),\n ),\n );\n }\n\n private responses(\n endpoint: DocumentedEndpoint,\n contractName: string,\n contract: ResponseContract,\n isRoute: boolean,\n ): JsonObject {\n const responses = new JsonObject();\n // A void ROUTE is 204 with 0 bytes, exactly what our server sends. A void WEBHOOK stays a\n // `200` the partner returns — any 2xx acknowledges, and its body is ignored.\n const status = isRoute && this.body.isVoid(endpoint.response) ? '204' : '200';\n responses.set(status, this.success(endpoint, contractName, contract, isRoute));\n for (const error of contract.errors) {\n // A failure only an AUTHENTICATED operation can have (a 401) is not one a public\n // endpoint can return, so it is not documented there.\n if (error.requiresAuth && this.isPublic(endpoint)) {\n continue;\n }\n responses.set(error.status, this.failure(error.description, contract));\n }\n return responses;\n }\n\n private success(\n endpoint: DocumentedEndpoint,\n contractName: string,\n contract: ResponseContract,\n isRoute: boolean,\n ): JsonObject {\n const isVoid = this.body.isVoid(endpoint.response);\n const response = new JsonObject()\n .set('description', this.successDescription(endpoint, contractName, isVoid, isRoute))\n .set('headers', contract.headers);\n if (isVoid) {\n return response;\n }\n const pointer = `#/paths/${contractName}_${endpoint.methodName}/responses/200`;\n return response.set(\n 'content',\n new JsonObject().set(\n 'application/json',\n new JsonObject().set('schema', this.schemas.body(endpoint.response!, pointer)),\n ),\n );\n }\n\n private failure(description: string, contract: ResponseContract): JsonObject {\n const response = new JsonObject()\n .set('description', description)\n .set('headers', contract.headers);\n if (contract.errorSchemaRef === undefined) {\n return response;\n }\n return response.set(\n 'content',\n new JsonObject().set(\n 'application/json',\n new JsonObject().set('schema', contract.errorSchemaRef),\n ),\n );\n }\n\n /**\n * The method's `@returns` text (#1292). With none, a `void` operation gets a derived sentence —\n * there is no body for `@returns` to describe: \"no body\" for a served route (a 204), and the\n * acknowledgement sentence for a webhook the partner answers. A body-carrying\n * operation with none never gets here: {@link MissingReturnsGuard} refuses it before any document\n * renders, so there is no filler fallback to publish.\n */\n private successDescription(\n endpoint: DocumentedEndpoint,\n contractName: string,\n isVoid: boolean,\n isRoute: boolean,\n ): string {\n const returns = this.prose(endpoint.returnsDescription);\n if (returns !== undefined) {\n return returns;\n }\n if (!isVoid) {\n throw new OpenApiGenerationError(\n `${endpoint.methodName} has a response body but no @returns`,\n `${contractName}.${endpoint.methodName} (the contract method's JSDoc)`,\n 'Add a `@returns` line to its JSDoc. MissingReturnsGuard should have refused this ' +\n 'before rendering; reaching here is a generator defect.',\n );\n }\n return isRoute ? NO_CONTENT : ACKNOWLEDGE;\n }\n\n private prose(text: string | undefined): string | undefined {\n return text === undefined || text.trim() === '' ? undefined : text;\n }\n}\n"]}