@webpieces/openapi-generator 0.4.938 → 0.4.939

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.
@@ -1 +1 @@
1
- {"version":3,"file":"OpenApiGenerator.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/OpenApiGenerator.ts"],"names":[],"mappings":";;;AAAA,4DASkC;AAClC,mDAA2D;AAC3D,sEAAmE;AAEnE,yDAM4B;AAC5B,2DAAwD;AACxD,2DAA0E;AAC1E,uDAO2B;AAC3B,qDAAiE;AACjE,uDAAoD;AACpD,yDAAsD;AACtD,+DAA4D;AAC5D,iDAA8C;AAC9C,2DAAwD;AACxD,iDAA8C;AAC9C,uEAAoE;AAGpE,uGAAuG;AACvG,MAAM,gBAAgB;IAEL;IACA;IAFb,YACa,QAAoB,EACpB,OAAuB;QADvB,aAAQ,GAAR,QAAQ,CAAY;QACpB,YAAO,GAAP,OAAO,CAAgB;IACjC,CAAC;CACP;AAED,8FAA8F;AAC9F,MAAM,cAAc,GAAG,UAAU,CAAC;AAElC,2EAA2E;AAC3E,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,uBAAuB,GACzB,6FAA6F;IAC7F,oGAAoG;IACpG,6FAA6F;IAC7F,sGAAsG;IACtG,mGAAmG;IACnG,8EAA8E,CAAC;AAEnF,4FAA4F;AAC5F,MAAM,eAAe,GAAG,OAAO,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;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;IACnC,YAAY,GAAG,I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AM,CAAC,UAAU,EACjB,IAAI,uBAAU,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,wBAAwB,MAAM,CAAC,UAAU,EAAE,CAAC,CAC5E,CAAC;QACN,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACK,cAAc,CAClB,QAAkC,EAClC,QAAgB,EAChB,YAAoB;QAEpB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO;QACX,CAAC;QACD,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CACzB,CAAC,KAAoB,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,QAAQ,GAAG,CACnE,CAAC;QACF,MAAM,IAAI,+CAAsB,CAC5B,GAAG,QAAQ,CAAC,MAAM,gBAAgB,QAAQ,8BAA8B,EACxE,YAAY,EACZ,8EAA8E;YAC1E,uFAAuF,EAC3F,QAAQ,CACX,CAAC;IACN,CAAC;CACJ;AAlrBD,4CAkrBC","sourcesContent":["import {\n ApiDocModel,\n DocumentedApiKey,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedField,\n DocumentedType,\n TypeNameCollision,\n TypeRef,\n} from '@webpieces/api-doc-model';\nimport { JsonObject, JsonValue } from '../json/JsonObject';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\nimport { ErrorResponseEntry, ServerEntry } from '../manifest/OpenApiManifest';\nimport {\n ComponentsInputs,\n ContractModel,\n GeneratedDocument,\n GeneratedDocuments,\n GenerationInputs,\n} from './GenerationInputs';\nimport { DocumentSelection } from './DocumentSelection';\nimport { OperationRenderer, ResponseContract } from './OperationRenderer';\nimport {\n BundledNames,\n BundledPlacement,\n ComponentsReference,\n DiscoveryPlacement,\n SchemaPlacement,\n SplitPlacement,\n} from './SchemaPlacement';\nimport { SchemaRenderer, UnmappedField } from './SchemaRenderer';\nimport { SecurityDeriver } from './SecurityDeriver';\nimport { McpToolNameGuard } from './McpToolNameGuard';\nimport { MissingReturnsGuard } from './MissingReturnsGuard';\nimport { SummaryGuard } from './SummaryGuard';\nimport { StackedJsDocGuard } from './StackedJsDocGuard';\nimport { TagOwnership } from './TagOwnership';\nimport { UndocumentedSchemaGuard } from './UndocumentedSchemaGuard';\nimport { UpstreamComponentsIndex } from './UpstreamComponents';\n\n/** One rendered document, and the renderer that built its schemas — what it defined and referenced. */\nclass RenderedDocument {\n constructor(\n readonly document: JsonObject,\n readonly schemas: SchemaRenderer,\n ) {}\n}\n\n/** The suffix of a split document's self-contained sibling: `public-openapi.bundled.json`. */\nconst BUNDLED_SUFFIX = '.bundled';\n\n/** The document a DTO library publishes, without its extension (#1058). */\nconst COMPONENTS_DOCUMENT = 'components.openapi';\n\n/**\n * Every cure for a type reached in a package that publishes no components document.\n *\n * Tagging is offered ONLY for a package that is already a role:api-lib DTO library (#1064, D5): a\n * general library such as `company-core` is refused the tag by validate-nx-wiring and by the\n * openapi-components-generate executor, so \"tag the package\" is never a way out of moving the type.\n */\nconst PUBLISH_COMPONENTS_CURE =\n 'Move each type into a role:api-lib DTO library that publishes a components document — as a ' +\n '`…Dto` string enum when it is a string-literal union. Only when the declaring package is ITSELF a ' +\n 'role:api-lib DTO library, tag it \"generate:openapi-components\" so it publishes one (with a ' +\n '\"kind\": \"components\" openapi.manifest.json naming its entry files; outside nx, render that manifest ' +\n 'with wp-openapi into the directory the package is packed from); a general library is refused the ' +\n \"tag. A document references another package's schema; it never copies one in.\";\n\n/** The OpenAPI version this generator writes. See the class doc for why 3.1 and not 3.0. */\nconst OPENAPI_VERSION = '3.1.0';\n\n/**\n * {@link GenerationInputs} -> one OpenAPI 3.1.0 document per `@ApiType` some contract declares.\n *\n * ## 3.1, because it is what the model can state HONESTLY\n *\n * `type: [T, \"null\"]` instead of a `nullable` keyword; a `description` legal beside a `$ref`; a\n * top-level `webhooks:` block. Each of those is a fact the model holds that 3.0 would have forced\n * this renderer to drop or to lie about. 3.1's schema dialect is also JSON Schema 2020-12, which is\n * what MCP `tools/list` speaks.\n *\n * ## ONE render function, called once per document\n *\n * ```\n * ApiDocModel --> render(selection) --+--> full-private-openapi.json SVC_TO_SVC contracts\n * +--> public-openapi.json EXTERNAL_CUSTOMER contracts, minus hidden methods\n * +--> mcp-openapi.json MCP contracts\n * ```\n *\n * `components.schemas` is built by walking OUTWARD from the operations the selection accepted, so an\n * unselected operation's DTOs are never constructed. See {@link DocumentSelection} for why that\n * asymmetry — a bug emits nothing, rather than shipping an unreleased feature's schemas with only\n * its URL removed — decides the whole design.\n *\n * ## It REFUSES to write an unmapped field\n *\n * An unmapped type renders as an empty schema, which in JSON Schema means \"anything\". Publishing one\n * is a green build handing a partner a field with no shape, so the guard names the JSON pointer of\n * every one and exits non-zero. There is deliberately NO flag to switch it off: the cure is at the\n * contract, by naming the type.\n *\n * It refuses a declaration with stacked JSDoc the same way, and for the same reason — see\n * {@link StackedJsDocGuard} (#1286). And, in every document including the MCP projection and its tool\n * catalogs, an operation with a body but no `@returns` ({@link MissingReturnsGuard}) and a published\n * schema with no JSDoc description ({@link UndocumentedSchemaGuard}) — each naming every offender in\n * one run (#1292). Likewise an operation with no valid `@summary` ({@link SummaryGuard}) and an MCP\n * tool whose name the Claude Connectors Directory would refuse ({@link McpToolNameGuard}) (#1296).\n */\nexport class OpenApiGenerator {\n private readonly security = new SecurityDeriver();\n private readonly stackedJsDoc = new StackedJsDocGuard();\n private readonly missingReturns = new MissingReturnsGuard();\n private readonly summaries = new SummaryGuard();\n private readonly toolNames = new McpToolNameGuard();\n private readonly tagOwnership = new TagOwnership();\n\n /**\n * ONE document per `@ApiType` some contract declares, and no others.\n *\n * A document nobody asked for is not written empty — it is not written. That is the ONE\n * conditional in the whole pipeline, and it lives here rather than in three places: no contract\n * declaring `MCP` means no `mcp-openapi.json`, with no second \"is it empty?\" rule to keep in step\n * with the first.\n */\n generate(inputs: GenerationInputs): GeneratedDocuments {\n // Before ANY selection: a declaration's prose reaches every document it appears in, so the\n // refusal is about the contracts, not about one document (#1286).\n const models = inputs.contracts.map((each: ContractModel) => each.model);\n if (inputs.errorType !== undefined) {\n models.push(inputs.errorType);\n }\n this.stackedJsDoc.refuse(\n models.flatMap((model: ApiDocModel) => model.stackedJsDoc),\n inputs.manifestPath,\n );\n this.summaries.refuse(inputs.contracts, inputs.manifestPath);\n this.toolNames.refuse(inputs.contracts, inputs.manifestPath);\n this.missingReturns.refuse(inputs.contracts, inputs.manifestPath);\n this.tagOwnership.refuseSharedOwners(inputs.contracts, inputs.manifestPath);\n // Collected across EVERY OpenAPI document of the run and refused once, after them all, so an\n // author is handed every undocumented schema at once rather than one document at a time.\n const undocumented = new UndocumentedSchemaGuard();\n const documents: GeneratedDocument[] = [];\n for (const selection of DocumentSelection.all()) {\n const contracts = inputs.contracts.filter((each: ContractModel) =>\n selection.acceptsContract(each.model),\n );\n if (contracts.length === 0) {\n continue;\n }\n if (selection.inlinesEveryPackage) {\n documents.push(\n new GeneratedDocument(\n selection.fileName,\n this.bundled(inputs, contracts, selection, undocumented),\n ),\n );\n continue;\n }\n this.refuseCollisions(this.collisionsOf(inputs, contracts), inputs.manifestPath);\n const split = this.render(\n inputs,\n contracts,\n selection,\n new SplitPlacement(inputs.homePackage),\n );\n this.refuseUnpublished(\n split.schemas,\n this.mergedTypes(inputs),\n inputs.upstream,\n selection.fileName,\n inputs.manifestPath,\n );\n undocumented.collect(split.schemas.reachedTypes(), this.mergedTypes(inputs));\n documents.push(new GeneratedDocument(selection.fileName, split.document));\n documents.push(\n new GeneratedDocument(\n `${selection.fileName}${BUNDLED_SUFFIX}`,\n this.bundled(inputs, contracts, selection),\n ),\n );\n }\n undocumented.refuse(inputs.manifestPath);\n return new GeneratedDocuments(documents);\n }\n\n /**\n * A DTO library's COMPONENTS-ONLY document (#1058): `openapi`, `info`, `x-webpieces-id` and\n * `components.schemas` — every type the library exports and declares, with every OTHER package's\n * type a `$ref` into that package's own components document, so a chain of DTO libraries is a\n * chain of documents of any depth.\n *\n * `info.version` is the PACKAGE version. The package-qualified URI downstream documents reference\n * it by (`@scope/pkg/components.openapi.json`) is stated as `x-webpieces-id`, because OpenAPI 3.1's\n * root object admits no `$id` — a 3.1 validator rejects one — and the document must validate on its\n * own.\n */\n components(inputs: ComponentsInputs): GeneratedDocument {\n const model = inputs.model;\n const where = inputs.manifestPath;\n this.stackedJsDoc.refuse(model.stackedJsDoc, where);\n this.refuseCollisions(model.collisions, where);\n const schemas = new SchemaRenderer(model.types, new SplitPlacement(model.packageName));\n for (const key of model.exported) {\n schemas.define(key);\n }\n const rendered = schemas.components();\n this.refuseUnmapped(schemas.unmapped(), COMPONENTS_DOCUMENT, where);\n this.refuseUnpublished(schemas, model.types, inputs.upstream, COMPONENTS_DOCUMENT, where);\n const undocumented = new UndocumentedSchemaGuard();\n undocumented.collect(schemas.reachedTypes(), model.types);\n undocumented.refuse(where);\n if (rendered.isEmpty()) {\n throw new OpenApiGenerationError(\n `${model.packageName}'s entries export no type with a schema`,\n where,\n 'Name the entry files that export the library\\'s DTOs and enums — usually \"src/index.ts\".',\n );\n }\n return new GeneratedDocument(\n COMPONENTS_DOCUMENT,\n new JsonObject()\n .set('openapi', OPENAPI_VERSION)\n .set(\n 'info',\n new JsonObject()\n .set('title', inputs.manifest.title)\n .set('version', model.packageVersion),\n )\n .set('x-webpieces-id', ComponentsReference.documentUri(model.packageName))\n .set('components', new JsonObject().set('schemas', rendered)),\n );\n }\n\n /**\n * The SELF-CONTAINED form of a document: every reached schema defined locally, whichever package\n * declares it — the `*.bundled.json` sibling of a split document, and the MCP projection.\n *\n * Two passes, because a schema's NAME depends on which other schemas the document reaches: the\n * first renders with every type under its unique model key just to learn the reached set, and the\n * second renders with the names {@link BundledNames} assigns from it. Rendering is a pure walk of\n * the model, so the second pass reaches exactly what the first did.\n */\n private bundled(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n undocumented?: UndocumentedSchemaGuard,\n ): JsonObject {\n const discovery = this.render(inputs, contracts, selection, new DiscoveryPlacement());\n // The MCP projection inlines every type it reaches, from any package, so it is judged here\n // over that whole set (#1292). A split document's bundled sibling is not: each type in it is\n // judged by the document — or the components document — that defines it.\n undocumented?.collect(discovery.schemas.reachedTypes(), this.mergedTypes(inputs));\n const names = BundledNames.assign(\n discovery.schemas.reachedTypes(),\n this.mergedTypes(inputs),\n inputs.homePackage,\n );\n return this.render(inputs, contracts, selection, new BundledPlacement(names)).document;\n }\n\n /** ONE document, from the operations this selection accepts and nothing else. */\n private render(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n placement: SchemaPlacement,\n ): RenderedDocument {\n const types = this.mergedTypes(inputs);\n const schemas = new SchemaRenderer(types, placement);\n const operations = new OperationRenderer(\n schemas,\n selection.includeMcpExtensions,\n selection.internalNotice,\n inputs.manifest.operationIds,\n );\n this.refuseDuplicateOperationIds(contracts, selection, operations, inputs.manifestPath);\n const apiKey = this.singleApiKey(inputs, contracts, selection);\n const schemeNames = inputs.manifest.securitySchemeNames;\n const hoisted =\n apiKey !== undefined && this.everyOperationIsCovered(contracts, selection)\n ? this.security.requirement(schemeNames)\n : undefined;\n\n const contract = new ResponseContract(\n this.errorResponses(inputs),\n this.errorSchemaRef(inputs, schemas),\n this.headerRefs(inputs),\n );\n\n const paths = new JsonObject();\n const webhooks = new JsonObject();\n const tags = new Set<string>();\n for (const contractModel of contracts) {\n this.renderContract(\n contractModel,\n selection,\n operations,\n contract,\n this.webhookContract(),\n hoisted === undefined ? this.security.requirement(schemeNames) : undefined,\n paths,\n webhooks,\n tags,\n );\n }\n\n // The schemas are built HERE, after the operations, because building them is what walks a\n // DTO's fields — and an unmapped field can only be found by that walk. A guard that ran\n // before it would see only the top-level request and response refs and miss every one.\n const renderedSchemas = schemas.components().orUndefined();\n this.refuseUnmapped(schemas.unmapped(), selection.fileName, inputs.manifestPath);\n\n const components = new JsonObject()\n .set('schemas', renderedSchemas)\n .set(\n 'securitySchemes',\n this.renderSecuritySchemes(inputs, contracts, selection, apiKey),\n )\n .set('headers', this.headers(inputs));\n\n const document = new JsonObject()\n .set('openapi', OPENAPI_VERSION)\n .set('info', this.info(inputs, selection, !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 private renderSecuritySchemes(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n apiKey: DocumentedApiKey | undefined,\n ): JsonObject | undefined {\n const schemes =\n apiKey === undefined\n ? new JsonObject()\n : this.security.schemes(\n apiKey,\n inputs.manifest.securitySchemeNames,\n inputs.manifestPath,\n );\n return this.security\n .addBuiltinSchemes(schemes, this.selectedEndpoints(contracts, selection))\n .orUndefined();\n }\n\n /** Same-named, different declarations in one package, across every contract a document reads. */\n private collisionsOf(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n ): readonly TypeNameCollision[] {\n const models = contracts.map((each: ContractModel) => each.model);\n const all = inputs.errorType === undefined ? models : models.concat([inputs.errorType]);\n return all.flatMap((model: ApiDocModel) => Array.from(model.collisions));\n }\n\n /**\n * Two DIFFERENT declarations of one name in one package. A document defines each of its\n * package's schemas under its bare name, so one of the two would be published as the other's\n * shape. (Two packages' same-named types are not this: each is defined in its own package's\n * document — #1058's `LocalizedDescriptionsDto` case.)\n */\n private refuseCollisions(collisions: readonly TypeNameCollision[], where: string): void {\n if (collisions.length === 0) {\n return;\n }\n throw new OpenApiGenerationError(\n `${collisions.length} name(s) are declared twice in one package, so one document would ` +\n 'publish two different types under one name',\n where,\n 'Rename one declaration of each. Within one package a schema name is one type.',\n collisions.map(\n (each: TypeNameCollision) =>\n `${each.name} (${each.packageName ?? 'no package'}): ${each.firstLocation} and ${each.secondLocation}`,\n ),\n );\n }\n\n /**\n * OpenAPI requires every operationId to be unique among ALL operations of a document, webhooks\n * included. `\"operationIds\": \"method\"` publishes the bare method name, so two contracts with a\n * same-named method would publish one id twice — and a generated client would silently get one\n * method for two operations. Refused here, naming both, before anything renders (#1270). The ids\n * come from the renderer's own {@link OperationRenderer.operationIdOf}, so the check and the\n * published value cannot disagree.\n */\n private refuseDuplicateOperationIds(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n operations: OperationRenderer,\n where: string,\n ): void {\n const firstOwner = new Map<string, string>();\n const duplicates: string[] = [];\n for (const contractModel of contracts) {\n const model = contractModel.model;\n for (const endpoint of model.endpoints) {\n if (!selection.acceptsEndpoint(endpoint)) {\n continue;\n }\n const id = operations.operationIdOf(endpoint, model.contractName);\n const owner = `${model.contractName}.${endpoint.methodName} (${contractModel.file})`;\n const first = firstOwner.get(id);\n if (first === undefined) {\n firstOwner.set(id, owner);\n } else {\n duplicates.push(`operationId '${id}': ${first} and ${owner}`);\n }\n }\n }\n if (duplicates.length === 0) {\n return;\n }\n throw new OpenApiGenerationError(\n `${duplicates.length} operationId(s) would be published twice in ${selection.fileName}; ` +\n 'an operationId must be unique across every operation of one document',\n where,\n 'Rename one of each pair of methods, or set \"operationIds\": \"contract_method\" in the ' +\n 'manifest, which prefixes every id with its contract name (this renames every method ' +\n \"in partners' generated clients).\",\n duplicates,\n );\n }\n\n /**\n * FAIL CLOSED (#1058): every type this document references in another package must be a schema\n * of that package's published components document. A package that publishes none is refused —\n * naming the type, its package and the fix — rather than copied in, because silent copying is\n * exactly the duplication this replaces. A document that exists but lacks the schema is stale.\n */\n private refuseUnpublished(\n schemas: SchemaRenderer,\n types: ReadonlyMap<string, DocumentedType>,\n upstream: UpstreamComponentsIndex,\n fileName: string,\n where: string,\n ): void {\n const unpublished: string[] = [];\n const stale: string[] = [];\n for (const key of Array.from(schemas.externalTypes()).sort()) {\n const type = types.get(key)!;\n const owner = type.packageName;\n const declared = `${type.name} — declared in ${owner ?? 'no package'} (${type.location})`;\n if (owner === undefined) {\n unpublished.push(\n `${declared}: its file belongs to no package, so no document can own its schema`,\n );\n continue;\n }\n const published = upstream.publishedBy(owner);\n if (published === undefined) {\n const reason = upstream.missingFor(owner)?.reason ?? 'it was never located';\n unpublished.push(\n `${declared}: ${owner} publishes no components document — ${reason}`,\n );\n } else if (!published.schemaNames.has(type.schemaName)) {\n stale.push(\n `${declared}: ${published.documentPath} has no schema '${type.schemaName}'`,\n );\n }\n }\n if (unpublished.length > 0) {\n throw new OpenApiGenerationError(\n `${unpublished.length} type(s) ${fileName} reaches are declared in a package that ` +\n 'publishes no components document',\n where,\n PUBLISH_COMPONENTS_CURE,\n unpublished,\n );\n }\n if (stale.length > 0) {\n throw new OpenApiGenerationError(\n `${stale.length} type(s) ${fileName} references are missing from their package's components document`,\n where,\n 'Regenerate the upstream components document before this one — it is older than its ' +\n 'source (in nx, \"^openapi-components-generate\" in this target\\'s dependsOn orders it).',\n stale,\n );\n }\n }\n\n /**\n * A webhook is served by the PARTNER, so neither our failure envelope nor the header we stamp on\n * our own responses is true of it. Publishing either would document their server, not ours.\n */\n private webhookContract(): ResponseContract {\n return new ResponseContract([], undefined, undefined);\n }\n\n /** One contract's ACCEPTED endpoints, into `paths` or into `webhooks`. */\n private renderContract(\n contractModel: ContractModel,\n selection: DocumentSelection,\n operations: OperationRenderer,\n contract: ResponseContract,\n webhookContract: ResponseContract,\n perOperationSecurity: readonly JsonValue[] | undefined,\n paths: JsonObject,\n webhooks: JsonObject,\n tags: Set<string>,\n ): void {\n const model = contractModel.model;\n const tag = contractModel.entry.tag;\n for (const endpoint of model.endpoints) {\n if (!selection.acceptsEndpoint(endpoint)) {\n continue;\n }\n // A tag is added only by an operation that survived, so a document never advertises a\n // section of its sidebar that turns out to be empty.\n tags.add(tag);\n if (contractModel.entry.isWebhook()) {\n webhooks.set(\n this.eventName(endpoint),\n new JsonObject().set(\n 'post',\n operations.webhook(endpoint, model.contractName, tag, webhookContract),\n ),\n );\n continue;\n }\n const url = `${model.basePath}${endpoint.path}`;\n const existing = paths.get(url);\n const item = existing instanceof JsonObject ? existing : new JsonObject();\n item.set(\n endpoint.httpMethod.toLowerCase(),\n operations.operation(\n endpoint,\n model.contractName,\n tag,\n contract,\n this.security.operation(endpoint.auth, perOperationSecurity),\n ),\n );\n paths.set(url, item);\n }\n }\n\n /**\n * A webhook is keyed by the EVENT NAME, with the `@ApiPath` base deliberately NOT prepended.\n *\n * There is no url of ours here — the partner hosts the endpoint, at whatever path they choose —\n * so publishing `/our-base/delivered` would document a route that exists nowhere. What we are\n * naming is the event we will send.\n */\n private eventName(endpoint: DocumentedEndpoint): string {\n return endpoint.path.replace(/^\\/+/, '');\n }\n\n /**\n * Every named type from every contract, merged by MODEL KEY — which carries the declaring\n * package, so two packages' same-named types never meet here (#1058).\n *\n * Two contracts declaring DIFFERENT types under one key is a hard failure, not a first-wins\n * merge: `components.schemas` is keyed by name, so one of the two would be published as the\n * other's shape, and the operation referring to it would be quietly wrong.\n */\n private mergedTypes(inputs: GenerationInputs): ReadonlyMap<string, DocumentedType> {\n const merged = new Map<string, DocumentedType>();\n const published = new Map<string, DocumentedType>();\n const sources = inputs.contracts.map((each: ContractModel) => each.model);\n const all = inputs.errorType === undefined ? sources : sources.concat([inputs.errorType]);\n for (const model of all) {\n for (const name of Array.from(model.types.keys())) {\n const incoming = model.types.get(name)!;\n const previous = published.get(incoming.schemaName);\n if (\n previous !== undefined &&\n previous.location !== incoming.location &&\n (previous.name !== previous.schemaName || incoming.name !== incoming.schemaName)\n ) {\n throw new OpenApiGenerationError(\n `stripped schema name '${incoming.schemaName}' collides: '${previous.name}' at ${previous.location} and '${incoming.name}' at ${incoming.location}`,\n inputs.manifestPath,\n 'Change schemaNames so every reached declaration has a distinct published name.',\n );\n }\n published.set(incoming.schemaName, incoming);\n const existing = merged.get(name);\n if (\n existing !== undefined &&\n this.signature(existing) !== this.signature(incoming)\n ) {\n throw new OpenApiGenerationError(\n `two different types are both named '${incoming.name}'`,\n `${model.contractName} (${inputs.manifestPath})`,\n 'Rename one of them. `components.schemas` is keyed by name, so one shape ' +\n 'would be published as the other.',\n );\n }\n merged.set(name, incoming);\n }\n }\n return merged;\n }\n\n /** Enough of a type's shape to tell two same-named types apart without comparing prose. */\n private signature(type: DocumentedType): string {\n const fields = type.fields.map((field: DocumentedField) => field.name).join(',');\n return `${fields}|${type.enumValues.join(',')}|${type.unionRefNames.join(',')}`;\n }\n\n /**\n * The ONE api-key regime this document publishes.\n *\n * Two regimes in one document is a hard failure: `securitySchemeNames` is a single ordered list,\n * so there is no honest way to say which regime a given name belongs to, and a document that\n * guessed would publish one regime's header names under the other's scheme keys.\n */\n private singleApiKey(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): DocumentedApiKey | undefined {\n let found: DocumentedApiKey | undefined;\n for (const endpoint of this.selectedEndpoints(contracts, selection)) {\n const apiKey = endpoint.auth?.methods.find(\n (method: DocumentedAuthMethod) => method.apiKey !== undefined,\n )?.apiKey;\n if (apiKey === undefined) {\n continue;\n }\n if (found !== undefined && found.regime !== apiKey.regime) {\n throw new OpenApiGenerationError(\n `the ${selection.fileName} document mixes the api-key regimes ` +\n `'${found.regime}' ` +\n `and '${apiKey.regime}'`,\n inputs.manifestPath,\n 'Publish one regime per document — split the manifest, or move the ' +\n \"other regime's contract out of `apis`.\",\n );\n }\n found = apiKey;\n }\n return found;\n }\n\n /**\n * True when EVERY selected operation demands the credential, which is what licenses hoisting the\n * requirement to the document. A document that mixes credentialled and uncredentialled routes\n * stamps it per-operation instead — hoisting there would tell a partner that a public endpoint\n * needs a key.\n *\n * Judged per DOCUMENT, over the operations that document actually contains, because that is the\n * only question the document's own `security` block answers.\n */\n private everyOperationIsCovered(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): boolean {\n const served = this.selectedEndpoints(contracts, selection);\n return (\n served.length > 0 &&\n served.every(\n (e: DocumentedEndpoint) =>\n e.auth?.methods.length === 1 && e.auth.methods[0].apiKey !== undefined,\n )\n );\n }\n\n /**\n * The endpoints this selection accepts that are routes on OUR server. A webhook is somebody\n * else's route, so it never counts toward our security requirement or our regime.\n */\n private selectedEndpoints(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): readonly DocumentedEndpoint[] {\n const served: DocumentedEndpoint[] = [];\n for (const contract of contracts) {\n if (contract.entry.isWebhook()) {\n continue;\n }\n for (const endpoint of contract.model.endpoints) {\n if (selection.acceptsEndpoint(endpoint)) {\n served.push(endpoint);\n }\n }\n }\n return served;\n }\n\n /** `info`, whose `description` is the ONE piece of prose that differs between the documents. */\n private info(\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,4DASkC;AAClC,mDAA2D;AAC3D,sEAAmE;AAEnE,yDAM4B;AAC5B,2DAAwD;AACxD,2DAA0E;AAC1E,uDAO2B;AAC3B,qDAAiE;AACjE,uDAAoD;AACpD,yDAAsD;AACtD,+DAA4D;AAC5D,iDAA8C;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ameCollision,\n TypeRef,\n} from '@webpieces/api-doc-model';\nimport { JsonObject, JsonValue } from '../json/JsonObject';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\nimport { ErrorResponseEntry, ServerEntry } from '../manifest/OpenApiManifest';\nimport {\n ComponentsInputs,\n ContractModel,\n GeneratedDocument,\n GeneratedDocuments,\n GenerationInputs,\n} from './GenerationInputs';\nimport { DocumentSelection } from './DocumentSelection';\nimport { OperationRenderer, ResponseContract } from './OperationRenderer';\nimport {\n BundledNames,\n BundledPlacement,\n ComponentsReference,\n DiscoveryPlacement,\n SchemaPlacement,\n SplitPlacement,\n} from './SchemaPlacement';\nimport { SchemaRenderer, UnmappedField } from './SchemaRenderer';\nimport { SecurityDeriver } from './SecurityDeriver';\nimport { McpToolNameGuard } from './McpToolNameGuard';\nimport { MissingReturnsGuard } from './MissingReturnsGuard';\nimport { SummaryGuard } from './SummaryGuard';\nimport { StackedJsDocGuard } from './StackedJsDocGuard';\nimport { TagOwnership } from './TagOwnership';\nimport { UndocumentedSchemaGuard } from './UndocumentedSchemaGuard';\nimport { UpstreamComponentsIndex } from './UpstreamComponents';\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/**\n * Every cure for a type reached in a package that publishes no components document.\n *\n * Tagging is offered ONLY for a package that is already a role:api-lib DTO library (#1064, D5): a\n * general library such as `company-core` is refused the tag by validate-nx-wiring and by the\n * openapi-components-generate executor, so \"tag the package\" is never a way out of moving the type.\n */\nconst PUBLISH_COMPONENTS_CURE =\n 'Move each type into a role:api-lib DTO library that publishes a components document — as a ' +\n '`…Dto` string enum when it is a string-literal union. Only when the declaring package is ITSELF a ' +\n 'role:api-lib DTO library, tag it \"generate:openapi-components\" so it publishes one (with a ' +\n '\"kind\": \"components\" openapi.manifest.json naming its entry files; outside nx, render that manifest ' +\n 'with wp-openapi into the directory the package is packed from); a general library is refused the ' +\n \"tag. A document references another package's schema; it never copies one in.\";\n\n/** The OpenAPI version this generator writes. See the class doc for why 3.1 and not 3.0. */\nconst OPENAPI_VERSION = '3.1.0';\n\n/**\n * {@link GenerationInputs} -> one OpenAPI 3.1.0 document per `@ApiType` some contract declares.\n *\n * ## 3.1, because it is what the model can state HONESTLY\n *\n * `type: [T, \"null\"]` instead of a `nullable` keyword; a `description` legal beside a `$ref`; a\n * top-level `webhooks:` block. Each of those is a fact the model holds that 3.0 would have forced\n * this renderer to drop or to lie about. 3.1's schema dialect is also JSON Schema 2020-12, which is\n * what MCP `tools/list` speaks.\n *\n * ## ONE render function, called once per document\n *\n * ```\n * ApiDocModel --> render(selection) --+--> full-private-openapi.json SVC_TO_SVC contracts\n * +--> public-openapi.json EXTERNAL_CUSTOMER contracts, minus hidden methods\n * +--> mcp-openapi.json MCP contracts\n * ```\n *\n * `components.schemas` is built by walking OUTWARD from the operations the selection accepted, so an\n * unselected operation's DTOs are never constructed. See {@link DocumentSelection} for why that\n * asymmetry — a bug emits nothing, rather than shipping an unreleased feature's schemas with only\n * its URL removed — decides the whole design.\n *\n * ## It REFUSES to write an unmapped field\n *\n * An unmapped type renders as an empty schema, which in JSON Schema means \"anything\". Publishing one\n * is a green build handing a partner a field with no shape, so the guard names the JSON pointer of\n * every one and exits non-zero. There is deliberately NO flag to switch it off: the cure is at the\n * contract, by naming the type.\n *\n * It refuses a declaration with stacked JSDoc the same way, and for the same reason — see\n * {@link StackedJsDocGuard} (#1286). And, in every document including the MCP projection and its tool\n * catalogs, an operation with a body but no `@returns` ({@link MissingReturnsGuard}) and a published\n * schema with no JSDoc description ({@link UndocumentedSchemaGuard}) — each naming every offender in\n * one run (#1292). Likewise an operation with no valid `@summary` ({@link SummaryGuard}) and an MCP\n * tool whose name the Claude Connectors Directory would refuse ({@link McpToolNameGuard}) (#1296).\n */\nexport class OpenApiGenerator {\n private readonly security = new SecurityDeriver();\n private readonly stackedJsDoc = new StackedJsDocGuard();\n private readonly missingReturns = new MissingReturnsGuard();\n private readonly summaries = new SummaryGuard();\n private readonly toolNames = new McpToolNameGuard();\n private readonly tagOwnership = new TagOwnership();\n\n /**\n * ONE document per `@ApiType` some contract declares, and no others.\n *\n * A document nobody asked for is not written empty — it is not written. That is the ONE\n * conditional in the whole pipeline, and it lives here rather than in three places: no contract\n * declaring `MCP` means no `mcp-openapi.json`, with no second \"is it empty?\" rule to keep in step\n * with the first.\n */\n generate(inputs: GenerationInputs): GeneratedDocuments {\n // Before ANY selection: a declaration's prose reaches every document it appears in, so the\n // refusal is about the contracts, not about one document (#1286).\n const models = inputs.contracts.map((each: ContractModel) => each.model);\n if (inputs.errorType !== undefined) {\n models.push(inputs.errorType);\n }\n this.stackedJsDoc.refuse(\n models.flatMap((model: ApiDocModel) => model.stackedJsDoc),\n inputs.manifestPath,\n );\n this.summaries.refuse(inputs.contracts, inputs.manifestPath);\n this.toolNames.refuse(inputs.contracts, inputs.manifestPath);\n this.missingReturns.refuse(inputs.contracts, inputs.manifestPath);\n this.tagOwnership.refuseSharedOwners(inputs.contracts, inputs.manifestPath);\n // Collected across EVERY OpenAPI document of the run and refused once, after them all, so an\n // author is handed every undocumented schema at once rather than one document at a time.\n const undocumented = new UndocumentedSchemaGuard();\n const documents: GeneratedDocument[] = [];\n for (const selection of DocumentSelection.all()) {\n const contracts = inputs.contracts.filter((each: ContractModel) =>\n selection.acceptsContract(each.model),\n );\n if (contracts.length === 0) {\n continue;\n }\n if (selection.inlinesEveryPackage) {\n documents.push(\n new GeneratedDocument(\n selection.fileName,\n this.bundled(inputs, contracts, selection, undocumented),\n ),\n );\n continue;\n }\n this.refuseCollisions(this.collisionsOf(inputs, contracts), inputs.manifestPath);\n const split = this.render(\n inputs,\n contracts,\n selection,\n new SplitPlacement(inputs.homePackage),\n );\n this.refuseUnpublished(\n split.schemas,\n this.mergedTypes(inputs),\n inputs.upstream,\n selection.fileName,\n inputs.manifestPath,\n );\n undocumented.collect(split.schemas.reachedTypes(), this.mergedTypes(inputs));\n // 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),\n ),\n );\n }\n undocumented.refuse(inputs.manifestPath);\n return new GeneratedDocuments(documents);\n }\n\n /**\n * A DTO library's COMPONENTS-ONLY document (#1058): `openapi`, `info`, `x-webpieces-id` and\n * `components.schemas` — every type the library exports and declares, with every OTHER package's\n * type a `$ref` into that package's own components document, so a chain of DTO libraries is a\n * chain of documents of any depth.\n *\n * `info.version` is the PACKAGE version. The package-qualified URI downstream documents reference\n * it by (`@scope/pkg/components.openapi.json`) is stated as `x-webpieces-id`, because OpenAPI 3.1's\n * root object admits no `$id` — a 3.1 validator rejects one — and the document must validate on its\n * own.\n */\n components(inputs: ComponentsInputs): GeneratedDocument {\n const model = inputs.model;\n const where = inputs.manifestPath;\n this.stackedJsDoc.refuse(model.stackedJsDoc, where);\n this.refuseCollisions(model.collisions, where);\n const schemas = new SchemaRenderer(\n model.types,\n new SplitPlacement(model.packageName),\n InlinedWrappers.none(),\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.refuseUnpublished(schemas, model.types, inputs.upstream, COMPONENTS_DOCUMENT, where);\n const undocumented = new UndocumentedSchemaGuard();\n undocumented.collect(schemas.reachedTypes(), model.types);\n undocumented.refuse(where);\n if (rendered.isEmpty()) {\n throw new OpenApiGenerationError(\n `${model.packageName}'s entries export no type with a schema`,\n where,\n 'Name the entry files that export the library\\'s DTOs and enums — usually \"src/index.ts\".',\n );\n }\n return new GeneratedDocument(\n COMPONENTS_DOCUMENT,\n new JsonObject()\n .set('openapi', OPENAPI_VERSION)\n .set(\n 'info',\n new JsonObject()\n .set('title', inputs.manifest.title)\n .set('version', model.packageVersion),\n )\n .set('x-webpieces-id', ComponentsReference.documentUri(model.packageName))\n .set('components', new JsonObject().set('schemas', rendered)),\n );\n }\n\n /**\n * The SELF-CONTAINED form of a document: every reached schema defined locally, whichever package\n * declares it — the `*.bundled.json` sibling of a split document, and the MCP projection.\n *\n * Two passes, because a schema's NAME depends on which other schemas the document reaches: the\n * first renders with every type under its unique model key just to learn the reached set, and the\n * second renders with the names {@link BundledNames} assigns from it. Rendering is a pure walk of\n * the model, so the second pass reaches exactly what the first did.\n */\n private bundled(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n undocumented?: UndocumentedSchemaGuard,\n ): JsonObject {\n const discovery = this.render(inputs, contracts, selection, new DiscoveryPlacement());\n // The MCP projection inlines every type it reaches, from any package, so it is judged here\n // over that whole set (#1292). A split document's bundled sibling is not: each type in it is\n // judged by the document — or the components document — that defines it.\n undocumented?.collect(discovery.schemas.reachedTypes(), this.mergedTypes(inputs));\n const names = BundledNames.assign(\n discovery.schemas.reachedTypes(),\n this.mergedTypes(inputs),\n inputs.homePackage,\n );\n return this.render(inputs, contracts, selection, new BundledPlacement(names)).document;\n }\n\n /** ONE document, from the operations this selection accepts and nothing else. */\n private render(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n placement: SchemaPlacement,\n ): RenderedDocument {\n const types = this.mergedTypes(inputs);\n const schemas = new SchemaRenderer(types, placement, this.wrappers(inputs, selection, types));\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 /**\n * FAIL CLOSED (#1058): every type this document references in another package must be a schema\n * of that package's published components document. A package that publishes none is refused —\n * naming the type, its package and the fix — rather than copied in, because silent copying is\n * exactly the duplication this replaces. A document that exists but lacks the schema is stale.\n */\n private refuseUnpublished(\n schemas: SchemaRenderer,\n types: ReadonlyMap<string, DocumentedType>,\n upstream: UpstreamComponentsIndex,\n fileName: string,\n where: string,\n ): void {\n const unpublished: string[] = [];\n const stale: string[] = [];\n for (const key of Array.from(schemas.externalTypes()).sort()) {\n const type = types.get(key)!;\n const owner = type.packageName;\n const declared = `${type.name} — declared in ${owner ?? 'no package'} (${type.location})`;\n if (owner === undefined) {\n unpublished.push(\n `${declared}: its file belongs to no package, so no document can own its schema`,\n );\n continue;\n }\n const published = upstream.publishedBy(owner);\n if (published === undefined) {\n const reason = upstream.missingFor(owner)?.reason ?? 'it was never located';\n unpublished.push(\n `${declared}: ${owner} publishes no components document — ${reason}`,\n );\n } else if (!published.schemaNames.has(type.schemaName)) {\n stale.push(\n `${declared}: ${published.documentPath} has no schema '${type.schemaName}'`,\n );\n }\n }\n if (unpublished.length > 0) {\n throw new OpenApiGenerationError(\n `${unpublished.length} type(s) ${fileName} reaches are declared in a package that ` +\n 'publishes no components document',\n where,\n PUBLISH_COMPONENTS_CURE,\n unpublished,\n );\n }\n if (stale.length > 0) {\n throw new OpenApiGenerationError(\n `${stale.length} type(s) ${fileName} references are missing from their package's components document`,\n where,\n 'Regenerate the upstream components document before this one — it is older than its ' +\n 'source (in nx, \"^openapi-components-generate\" in this target\\'s dependsOn orders it).',\n stale,\n );\n }\n }\n\n /**\n * A webhook is served by the PARTNER, so neither our failure envelope nor the header we stamp on\n * our own responses is true of it. Publishing either would document their server, not ours.\n */\n private webhookContract(): ResponseContract {\n return new ResponseContract([], undefined, undefined);\n }\n\n /** One contract's ACCEPTED endpoints, into `paths` or into `webhooks`. */\n private renderContract(\n contractModel: ContractModel,\n selection: DocumentSelection,\n operations: OperationRenderer,\n contract: ResponseContract,\n webhookContract: ResponseContract,\n perOperationSecurity: readonly JsonValue[] | undefined,\n paths: JsonObject,\n webhooks: JsonObject,\n tags: Set<string>,\n ): void {\n const model = contractModel.model;\n const tag = contractModel.entry.tag;\n for (const endpoint of model.endpoints) {\n if (!selection.acceptsEndpoint(endpoint)) {\n continue;\n }\n // A tag is added only by an operation that survived, so a document never advertises a\n // section of its sidebar that turns out to be empty.\n tags.add(tag);\n if (contractModel.entry.isWebhook()) {\n webhooks.set(\n this.eventName(endpoint),\n new JsonObject().set(\n 'post',\n operations.webhook(endpoint, model.contractName, tag, webhookContract),\n ),\n );\n continue;\n }\n const url = `${model.basePath}${endpoint.path}`;\n const existing = paths.get(url);\n const item = existing instanceof JsonObject ? existing : new JsonObject();\n item.set(\n endpoint.httpMethod.toLowerCase(),\n operations.operation(\n endpoint,\n model.contractName,\n tag,\n contract,\n this.security.operation(endpoint.auth, perOperationSecurity),\n ),\n );\n paths.set(url, item);\n }\n }\n\n /**\n * A webhook is keyed by the EVENT NAME, with the `@ApiPath` base deliberately NOT prepended.\n *\n * There is no url of ours here — the partner hosts the endpoint, at whatever path they choose —\n * so publishing `/our-base/delivered` would document a route that exists nowhere. What we are\n * naming is the event we will send.\n */\n private eventName(endpoint: DocumentedEndpoint): string {\n return endpoint.path.replace(/^\\/+/, '');\n }\n\n /**\n * Every named type from every contract, merged by MODEL KEY — which carries the declaring\n * package, so two packages' same-named types never meet here (#1058).\n *\n * Two contracts declaring DIFFERENT types under one key is a hard failure, not a first-wins\n * merge: `components.schemas` is keyed by name, so one of the two would be published as the\n * other's shape, and the operation referring to it would be quietly wrong.\n */\n private mergedTypes(inputs: GenerationInputs): ReadonlyMap<string, DocumentedType> {\n const merged = new Map<string, DocumentedType>();\n const published = new Map<string, DocumentedType>();\n const sources = inputs.contracts.map((each: ContractModel) => each.model);\n const all = inputs.errorType === undefined ? sources : sources.concat([inputs.errorType]);\n for (const model of all) {\n for (const name of Array.from(model.types.keys())) {\n const incoming = model.types.get(name)!;\n const previous = published.get(incoming.schemaName);\n if (\n previous !== undefined &&\n previous.location !== incoming.location &&\n (previous.name !== previous.schemaName || incoming.name !== incoming.schemaName)\n ) {\n throw new OpenApiGenerationError(\n `stripped schema name '${incoming.schemaName}' collides: '${previous.name}' at ${previous.location} and '${incoming.name}' at ${incoming.location}`,\n inputs.manifestPath,\n 'Change schemaNames so every reached declaration has a distinct published name.',\n );\n }\n published.set(incoming.schemaName, incoming);\n const existing = merged.get(name);\n if (\n existing !== undefined &&\n this.signature(existing) !== this.signature(incoming)\n ) {\n throw new OpenApiGenerationError(\n `two different types are both named '${incoming.name}'`,\n `${model.contractName} (${inputs.manifestPath})`,\n 'Rename one of them. `components.schemas` is keyed by name, so one shape ' +\n 'would be published as the other.',\n );\n }\n merged.set(name, incoming);\n }\n }\n return merged;\n }\n\n /** Enough of a type's shape to tell two same-named types apart without comparing prose. */\n private signature(type: DocumentedType): string {\n const fields = type.fields.map((field: DocumentedField) => field.name).join(',');\n return `${fields}|${type.enumValues.join(',')}|${type.unionRefNames.join(',')}`;\n }\n\n /**\n * The ONE api-key regime this document publishes.\n *\n * Two regimes in one document is a hard failure: `securitySchemeNames` is a single ordered list,\n * so there is no honest way to say which regime a given name belongs to, and a document that\n * guessed would publish one regime's header names under the other's scheme keys.\n */\n private singleApiKey(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): DocumentedApiKey | undefined {\n let found: DocumentedApiKey | undefined;\n for (const endpoint of this.selectedEndpoints(contracts, selection)) {\n const apiKey = endpoint.auth?.methods.find(\n (method: DocumentedAuthMethod) => method.apiKey !== undefined,\n )?.apiKey;\n if (apiKey === undefined) {\n continue;\n }\n if (found !== undefined && found.regime !== apiKey.regime) {\n throw new OpenApiGenerationError(\n `the ${selection.fileName} document mixes the api-key regimes ` +\n `'${found.regime}' ` +\n `and '${apiKey.regime}'`,\n inputs.manifestPath,\n 'Publish one regime per document — split the manifest, or move the ' +\n \"other regime's contract out of `apis`.\",\n );\n }\n found = apiKey;\n }\n return found;\n }\n\n /**\n * True when EVERY selected operation demands the credential, which is what licenses hoisting the\n * requirement to the document. A document that mixes credentialled and uncredentialled routes\n * stamps it per-operation instead — hoisting there would tell a partner that a public endpoint\n * needs a key.\n *\n * Judged per DOCUMENT, over the operations that document actually contains, because that is the\n * only question the document's own `security` block answers.\n */\n private everyOperationIsCovered(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): boolean {\n const served = this.selectedEndpoints(contracts, selection);\n return (\n served.length > 0 &&\n served.every(\n (e: DocumentedEndpoint) =>\n e.auth?.methods.length === 1 && e.auth.methods[0].apiKey !== undefined,\n )\n );\n }\n\n /**\n * The endpoints this selection accepts that are routes on OUR server. A webhook is somebody\n * else's route, so it never counts toward our security requirement or our regime.\n */\n private selectedEndpoints(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): readonly DocumentedEndpoint[] {\n const served: DocumentedEndpoint[] = [];\n for (const contract of contracts) {\n if (contract.entry.isWebhook()) {\n continue;\n }\n for (const endpoint of contract.model.endpoints) {\n if (selection.acceptsEndpoint(endpoint)) {\n served.push(endpoint);\n }\n }\n }\n return served;\n }\n\n /** `info`, whose `description` is the ONE piece of prose that differs between the documents. */\n private info(\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"]}
@@ -57,6 +57,14 @@ export declare class OperationRenderer {
57
57
  private readonly includeMcp;
58
58
  /** True only for the private document — see {@link triggerSentence}. */
59
59
  private readonly includeTrigger;
60
+ /**
61
+ * False only for the PUBLIC document (#1303): `x-webpieces-authentication` (whose `arguments`
62
+ * are the TypeScript identifiers passed to `@WpAuth` — private names a partner cannot use) and
63
+ * `x-webpieces-webhook` are internal tooling's. A partner's authentication is already in the
64
+ * standard `components.securitySchemes` + `security`, and a webhook already sits in the
65
+ * standard `webhooks:` block.
66
+ */
67
+ private readonly includeWebpieces;
60
68
  /** The manifest's `operationIds` — see {@link operationIdOf}. */
61
69
  private readonly operationIds;
62
70
  private readonly body;
@@ -65,6 +73,14 @@ export declare class OperationRenderer {
65
73
  includeMcp: boolean,
66
74
  /** True only for the private document — see {@link triggerSentence}. */
67
75
  includeTrigger: boolean,
76
+ /**
77
+ * False only for the PUBLIC document (#1303): `x-webpieces-authentication` (whose `arguments`
78
+ * are the TypeScript identifiers passed to `@WpAuth` — private names a partner cannot use) and
79
+ * `x-webpieces-webhook` are internal tooling's. A partner's authentication is already in the
80
+ * standard `components.securitySchemes` + `security`, and a webhook already sits in the
81
+ * standard `webhooks:` block.
82
+ */
83
+ includeWebpieces: boolean,
68
84
  /** The manifest's `operationIds` — see {@link operationIdOf}. */
69
85
  operationIds: OperationIdStyle);
70
86
  /**
@@ -79,8 +95,8 @@ export declare class OperationRenderer {
79
95
  /**
80
96
  * A call WE make to a PARTNER's server.
81
97
  *
82
- * It carries `x-webpieces-webhook: true`, which is the one fact about it a document cannot state
83
- * any other way. It gets no trigger sentence and no security at all, because neither is true of
98
+ * It carries `x-webpieces-webhook: true` in every document but the public one (#1303), where the
99
+ * standard `webhooks:` block it sits in already says so. It gets no trigger sentence and no security at all, because neither is true of
84
100
  * it: nothing of ours triggers it and nothing of ours authenticates it — our api key must never
85
101
  * be published as a guard on somebody else's endpoint.
86
102
  *
@@ -92,6 +108,8 @@ export declare class OperationRenderer {
92
108
  */
93
109
  webhook(endpoint: DocumentedEndpoint, contractName: string, tag: string, contract: ResponseContract): JsonObject;
94
110
  private common;
111
+ /** The declared `@WpAuth` methods, verbatim — never in the public document (#1303). */
112
+ private authentication;
95
113
  /**
96
114
  * The JSDoc body, plus the sentences that are DERIVED rather than written.
97
115
  *
@@ -59,6 +59,7 @@ class OperationRenderer {
59
59
  schemas;
60
60
  includeMcp;
61
61
  includeTrigger;
62
+ includeWebpieces;
62
63
  operationIds;
63
64
  body = new SuccessBody_1.SuccessBody();
64
65
  constructor(schemas,
@@ -66,11 +67,20 @@ class OperationRenderer {
66
67
  includeMcp,
67
68
  /** True only for the private document — see {@link triggerSentence}. */
68
69
  includeTrigger,
70
+ /**
71
+ * False only for the PUBLIC document (#1303): `x-webpieces-authentication` (whose `arguments`
72
+ * are the TypeScript identifiers passed to `@WpAuth` — private names a partner cannot use) and
73
+ * `x-webpieces-webhook` are internal tooling's. A partner's authentication is already in the
74
+ * standard `components.securitySchemes` + `security`, and a webhook already sits in the
75
+ * standard `webhooks:` block.
76
+ */
77
+ includeWebpieces,
69
78
  /** The manifest's `operationIds` — see {@link operationIdOf}. */
70
79
  operationIds) {
71
80
  this.schemas = schemas;
72
81
  this.includeMcp = includeMcp;
73
82
  this.includeTrigger = includeTrigger;
83
+ this.includeWebpieces = includeWebpieces;
74
84
  this.operationIds = operationIds;
75
85
  }
76
86
  /**
@@ -97,8 +107,8 @@ class OperationRenderer {
97
107
  /**
98
108
  * A call WE make to a PARTNER's server.
99
109
  *
100
- * It carries `x-webpieces-webhook: true`, which is the one fact about it a document cannot state
101
- * any other way. It gets no trigger sentence and no security at all, because neither is true of
110
+ * It carries `x-webpieces-webhook: true` in every document but the public one (#1303), where the
111
+ * standard `webhooks:` block it sits in already says so. It gets no trigger sentence and no security at all, because neither is true of
102
112
  * it: nothing of ours triggers it and nothing of ours authenticates it — our api key must never
103
113
  * be published as a guard on somebody else's endpoint.
104
114
  *
@@ -110,18 +120,25 @@ class OperationRenderer {
110
120
  */
111
121
  webhook(endpoint, contractName, tag, contract) {
112
122
  const operation = this.common(endpoint, contractName, tag, contract, false);
113
- return this.withMcp(operation.set('x-webpieces-webhook', true), endpoint);
123
+ return this.withMcp(operation.set('x-webpieces-webhook', this.includeWebpieces ? true : undefined), endpoint);
114
124
  }
115
125
  common(endpoint, contractName, tag, contract, isRoute) {
116
126
  return new JsonObject_1.JsonObject()
117
127
  .set('operationId', this.operationIdOf(endpoint, contractName))
118
- .set('x-webpieces-authentication', endpoint.auth?.methods.map((method) => new JsonObject_1.JsonObject().set('kind', method.kind).set('arguments', method.argumentTexts)))
128
+ .set('x-webpieces-authentication', this.authentication(endpoint))
119
129
  .set('summary', endpoint.summary)
120
130
  .set('description', this.describe(endpoint, isRoute))
121
131
  .set('tags', [tag])
122
132
  .set('requestBody', this.requestBody(endpoint, contractName))
123
133
  .set('responses', this.responses(endpoint, contractName, contract));
124
134
  }
135
+ /** The declared `@WpAuth` methods, verbatim — never in the public document (#1303). */
136
+ authentication(endpoint) {
137
+ if (!this.includeWebpieces) {
138
+ return undefined;
139
+ }
140
+ return endpoint.auth?.methods.map((method) => new JsonObject_1.JsonObject().set('kind', method.kind).set('arguments', method.argumentTexts));
141
+ }
125
142
  /**
126
143
  * The JSDoc body, plus the sentences that are DERIVED rather than written.
127
144
  *
@@ -262,7 +279,7 @@ class OperationRenderer {
262
279
  : 'application/json';
263
280
  return new JsonObject_1.JsonObject()
264
281
  .set('required', true)
265
- .set('content', new JsonObject_1.JsonObject().set(media, new JsonObject_1.JsonObject().set('schema', this.schemas.type(endpoint.request, pointer))));
282
+ .set('content', new JsonObject_1.JsonObject().set(media, new JsonObject_1.JsonObject().set('schema', this.schemas.body(endpoint.request, pointer))));
266
283
  }
267
284
  responses(endpoint, contractName, contract) {
268
285
  const responses = new JsonObject_1.JsonObject();
@@ -286,7 +303,7 @@ class OperationRenderer {
286
303
  return response;
287
304
  }
288
305
  const pointer = `#/paths/${contractName}_${endpoint.methodName}/responses/200`;
289
- return response.set('content', new JsonObject_1.JsonObject().set('application/json', new JsonObject_1.JsonObject().set('schema', this.schemas.type(endpoint.response, pointer))));
306
+ return response.set('content', new JsonObject_1.JsonObject().set('application/json', new JsonObject_1.JsonObject().set('schema', this.schemas.body(endpoint.response, pointer))));
290
307
  }
291
308
  failure(description, contract) {
292
309
  const response = new JsonObject_1.JsonObject()
@@ -1 +1 @@
1
- {"version":3,"file":"OperationRenderer.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/OperationRenderer.ts"],"names":[],"mappings":";;;AACA,oDAU8B;AAC9B,mDAA2D;AAC3D,iEAAmF;AAEnF,+CAA4C;AAC5C,sEAAmE;AAEnE,mEAA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,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;AA7UD,8CA6UC","sourcesContent":["import { DocumentedAuthMethod, DocumentedEndpoint } from '@webpieces/api-doc-model';\nimport {\n CLOUDTASKS,\n CRON,\n EXTERNAL,\n mcpHintsForOperation,\n POST,\n READ,\n RPC,\n WRITE,\n WRITE_IDEMPOTENT,\n} from '@webpieces/core-util';\nimport { JsonObject, JsonValue } from '../json/JsonObject';\nimport { ErrorResponseEntry, OperationIdStyle } from '../manifest/OpenApiManifest';\nimport { SchemaRenderer } from './SchemaRenderer';\nimport { SuccessBody } from './SuccessBody';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\n\n/** What a webhook's `void` return means on the wire, said once. */\nconst ACKNOWLEDGE = 'Return any 2xx to acknowledge delivery. The body is ignored.';\n\n/** The response document, and the responses a document-wide failure contract adds to it. */\nexport class ResponseContract {\n constructor(\n /** The manifest's `errors.responses`, in declared order. */\n readonly errors: readonly ErrorResponseEntry[],\n /** `$ref` at the error body schema, when the manifest declared one. */\n readonly errorSchemaRef: JsonObject | undefined,\n /**\n * Header name -> its `components.headers` `$ref`, on the success response AND on every\n * failure listed for the operation (#1270). The server stamps the header on every response,\n * and the failing one is the response a partner most needs to quote back.\n */\n readonly headers: JsonObject | undefined,\n ) {}\n}\n\n/**\n * ONE {@link DocumentedEndpoint} -> one OpenAPI Operation Object.\n *\n * ## `summary` is the method's `@summary` JSDoc tag — a short title, never a sentence (#1296)\n *\n * A docs theme titles the endpoint's page from `summary` and labels its sidebar with it, and puts\n * `description` in the body. It used to be the bare method name, which put code identifiers in every\n * heading. It is now the `@summary` line the author wrote — one line, at most 100 characters,\n * REQUIRED on every published operation by {@link SummaryGuard} — and the tag is not part of\n * `description`, so the page does not repeat its own heading. The code identifier stays published as\n * `operationId`, which is what a generated client names the method. The same line is the MCP tool's\n * `title`, so a partner's docs page and an agent's tool list name the endpoint identically.\n *\n * ## The MCP extensions ride HERE, on the operation\n *\n * `x-mcp-tool`, `x-mcp-hints`, `x-mcp-description` and `x-mcp-auth` are stamped on every operation\n * carrying the tool decorator, hidden or not: an internal endpoint that is an agent tool is a\n * legitimate agent tool, and requiring it to be published to partners in order to be one would be\n * exactly the wrong coupling.\n *\n * They are stamped on the BASE, which every published document is derived from, and\n * {@link DocumentDeriver} STRIPS them from the customer document. Stamping-then-stripping rather than\n * rendering the customer document without them is the same choice the whole deriver rests on: one\n * render of one operation, so two documents holding it cannot disagree about anything else in it.\n */\nexport class OperationRenderer {\n private readonly body = new SuccessBody();\n\n constructor(\n private readonly schemas: SchemaRenderer,\n /** True only for the MCP document — see {@link withMcp}. */\n private readonly includeMcp: boolean,\n /** True only for the private document — see {@link triggerSentence}. */\n private readonly includeTrigger: boolean,\n /** The manifest's `operationIds` — see {@link operationIdOf}. */\n private readonly operationIds: OperationIdStyle,\n ) {}\n\n /**\n * The published `operationId`, in the manifest's chosen style (#1270).\n *\n * Public because the generator checks uniqueness with the SAME function before rendering: a\n * second spelling of the id there could pass a collision this one then publishes.\n */\n operationIdOf(endpoint: DocumentedEndpoint, contractName: string): string {\n return this.operationIds === OperationIdStyle.METHOD\n ? endpoint.methodName\n : `${contractName}_${endpoint.methodName}`;\n }\n\n /** An ordinary served route. */\n operation(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n security: readonly JsonValue[] | undefined,\n ): JsonObject {\n const operation = this.common(endpoint, contractName, tag, contract, 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`, which is the one fact about it a document cannot state\n * any other way. It gets no trigger sentence and no security at all, because neither is true of\n * it: nothing of ours triggers it and nothing of ours authenticates it — our api key must never\n * be published as a guard on somebody else's endpoint.\n *\n * 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(operation.set('x-webpieces-webhook', true), endpoint);\n }\n\n private common(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n isRoute: boolean,\n ): JsonObject {\n return new JsonObject()\n .set('operationId', this.operationIdOf(endpoint, contractName))\n .set('x-webpieces-authentication', endpoint.auth?.methods.map((method: DocumentedAuthMethod) => new JsonObject().set('kind', method.kind).set('arguments', method.argumentTexts)))\n .set('summary', endpoint.summary)\n .set('description', this.describe(endpoint, isRoute))\n .set('tags', [tag])\n .set('requestBody', this.requestBody(endpoint, contractName))\n .set('responses', this.responses(endpoint, contractName, contract));\n }\n\n /**\n * The JSDoc body, plus the sentences that are DERIVED rather than written.\n *\n * The retry sentence comes from the endpoint's declared `operation`, which every integration\n * wants to know and most APIs state nowhere. It is a SENTENCE and not a vendor extension because\n * Swagger UI and most themes do not render `x-` extensions and no standard generator reads\n * `x-webpieces-*`: an extension would be invisible to the human and unread by the machine. The\n * mapping it is derived from is published once, in `info.description`, so the rule is stated and\n * not only its consequences. 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.type(endpoint.request, pointer)),\n ),\n );\n }\n\n private responses(\n endpoint: DocumentedEndpoint,\n contractName: string,\n contract: ResponseContract,\n ): JsonObject {\n const responses = new JsonObject();\n responses.set('200', this.success(endpoint, contractName, contract));\n for (const error of contract.errors) {\n // A failure only an AUTHENTICATED operation can have (a 401) is not one a public\n // endpoint can return, so it is not documented there.\n if (error.requiresAuth && this.isPublic(endpoint)) {\n continue;\n }\n responses.set(error.status, this.failure(error.description, contract));\n }\n return responses;\n }\n\n private success(\n endpoint: DocumentedEndpoint,\n contractName: string,\n contract: ResponseContract,\n ): JsonObject {\n const isVoid = this.body.isVoid(endpoint.response);\n const response = new JsonObject()\n .set('description', this.successDescription(endpoint, contractName, isVoid))\n .set('headers', contract.headers);\n if (isVoid) {\n return response;\n }\n const pointer = `#/paths/${contractName}_${endpoint.methodName}/responses/200`;\n return response.set(\n 'content',\n new JsonObject().set(\n 'application/json',\n new JsonObject().set('schema', this.schemas.type(endpoint.response!, pointer)),\n ),\n );\n }\n\n private failure(description: string, contract: ResponseContract): JsonObject {\n const response = new JsonObject()\n .set('description', description)\n .set('headers', contract.headers);\n if (contract.errorSchemaRef === undefined) {\n return response;\n }\n return response.set(\n 'content',\n new JsonObject().set(\n 'application/json',\n new JsonObject().set('schema', contract.errorSchemaRef),\n ),\n );\n }\n\n /**\n * The method's `@returns` text (#1292). With none, a `void` operation keeps the derived\n * acknowledgement sentence — there is no body for `@returns` to describe. A body-carrying\n * operation with none never gets here: {@link MissingReturnsGuard} refuses it before any document\n * renders, so there is no filler fallback to publish.\n */\n private successDescription(\n endpoint: DocumentedEndpoint,\n contractName: string,\n isVoid: boolean,\n ): string {\n const returns = this.prose(endpoint.returnsDescription);\n if (returns !== undefined) {\n return returns;\n }\n if (!isVoid) {\n throw new OpenApiGenerationError(\n `${endpoint.methodName} has a response body but no @returns`,\n `${contractName}.${endpoint.methodName} (the contract method's JSDoc)`,\n 'Add a `@returns` line to its JSDoc. MissingReturnsGuard should have refused this ' +\n 'before rendering; reaching here is a generator defect.',\n );\n }\n return ACKNOWLEDGE;\n }\n\n private prose(text: string | undefined): string | undefined {\n return text === undefined || text.trim() === '' ? undefined : text;\n }\n}\n"]}
1
+ {"version":3,"file":"OperationRenderer.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/OperationRenderer.ts"],"names":[],"mappings":";;;AACA,oDAU8B;AAC9B,mDAA2D;AAC3D,iEAAmF;AAEnF,+CAA4C;AAC5C,sEAAmE;AAEnE,mEAAmE;AACnE,MAAM,WAAW,GAAG,8DAA8D,CAAC;AAEnF,4FAA4F;AAC5F,MAAa,gBAAgB;IAGZ;IAEA;IAMA;IAVb;IACI,4DAA4D;IACnD,MAAqC;IAC9C,uEAAuE;IAC9D,cAAsC;IAC/C;;;;OAIG;IACM,OAA+B;QAR/B,WAAM,GAAN,MAAM,CAA+B;QAErC,mBAAc,GAAd,cAAc,CAAwB;QAMtC,YAAO,GAA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AY,IAAI,QAAQ,CAAC,UAAU,gCAAgC,EACtE,mFAAmF;gBAC/E,wDAAwD,CAC/D,CAAC;QACN,CAAC;QACD,OAAO,WAAW,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,IAAwB;QAClC,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IACvE,CAAC;CACJ;AAlWD,8CAkWC","sourcesContent":["import { DocumentedAuthMethod, DocumentedEndpoint } from '@webpieces/api-doc-model';\nimport {\n CLOUDTASKS,\n CRON,\n EXTERNAL,\n mcpHintsForOperation,\n POST,\n READ,\n RPC,\n WRITE,\n WRITE_IDEMPOTENT,\n} from '@webpieces/core-util';\nimport { JsonObject, JsonValue } from '../json/JsonObject';\nimport { ErrorResponseEntry, OperationIdStyle } from '../manifest/OpenApiManifest';\nimport { SchemaRenderer } from './SchemaRenderer';\nimport { SuccessBody } from './SuccessBody';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\n\n/** What a webhook's `void` return means on the wire, said once. */\nconst ACKNOWLEDGE = 'Return any 2xx to acknowledge delivery. The body is ignored.';\n\n/** The response document, and the responses a document-wide failure contract adds to it. */\nexport class ResponseContract {\n constructor(\n /** The manifest's `errors.responses`, in declared order. */\n readonly errors: readonly ErrorResponseEntry[],\n /** `$ref` at the error body schema, when the manifest declared one. */\n readonly errorSchemaRef: JsonObject | undefined,\n /**\n * Header name -> its `components.headers` `$ref`, on the success response AND on every\n * failure listed for the operation (#1270). The server stamps the header on every response,\n * and the failing one is the response a partner most needs to quote back.\n */\n readonly headers: JsonObject | undefined,\n ) {}\n}\n\n/**\n * ONE {@link DocumentedEndpoint} -> one OpenAPI Operation Object.\n *\n * ## `summary` is the method's `@summary` JSDoc tag — a short title, never a sentence (#1296)\n *\n * A docs theme titles the endpoint's page from `summary` and labels its sidebar with it, and puts\n * `description` in the body. It used to be the bare method name, which put code identifiers in every\n * heading. It is now the `@summary` line the author wrote — one line, at most 100 characters,\n * REQUIRED on every published operation by {@link SummaryGuard} — and the tag is not part of\n * `description`, so the page does not repeat its own heading. The code identifier stays published as\n * `operationId`, which is what a generated client names the method. The same line is the MCP tool's\n * `title`, so a partner's docs page and an agent's tool list name the endpoint identically.\n *\n * ## The MCP extensions ride HERE, on the operation\n *\n * `x-mcp-tool`, `x-mcp-hints`, `x-mcp-description` and `x-mcp-auth` are stamped on every operation\n * carrying the tool decorator, hidden or not: an internal endpoint that is an agent tool is a\n * legitimate agent tool, and requiring it to be published to partners in order to be one would be\n * exactly the wrong coupling.\n *\n * They are stamped on the BASE, which every published document is derived from, and\n * {@link DocumentDeriver} STRIPS them from the customer document. Stamping-then-stripping rather than\n * rendering the customer document without them is the same choice the whole deriver rests on: one\n * render of one operation, so two documents holding it cannot disagree about anything else in it.\n */\nexport class OperationRenderer {\n private readonly body = new SuccessBody();\n\n constructor(\n private readonly schemas: SchemaRenderer,\n /** True only for the MCP document — see {@link withMcp}. */\n private readonly includeMcp: boolean,\n /** True only for the private document — see {@link triggerSentence}. */\n private readonly includeTrigger: boolean,\n /**\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 private readonly operationIds: OperationIdStyle,\n ) {}\n\n /**\n * The published `operationId`, in the manifest's chosen style (#1270).\n *\n * Public because the generator checks uniqueness with the SAME function before rendering: a\n * second spelling of the id there could pass a collision this one then publishes.\n */\n operationIdOf(endpoint: DocumentedEndpoint, contractName: string): string {\n return this.operationIds === OperationIdStyle.METHOD\n ? endpoint.methodName\n : `${contractName}_${endpoint.methodName}`;\n }\n\n /** An ordinary served route. */\n operation(\n endpoint: DocumentedEndpoint,\n contractName: string,\n tag: string,\n contract: ResponseContract,\n security: readonly JsonValue[] | undefined,\n ): JsonObject {\n const operation = this.common(endpoint, contractName, tag, contract, 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,5 +1,6 @@
1
1
  import { DocumentedField, DocumentedType, TypeRef } from '@webpieces/api-doc-model';
2
2
  import { JsonObject } from '../json/JsonObject';
3
+ import { InlinedWrappers } from './InlinedWrappers';
3
4
  import { SchemaPlacement } from './SchemaPlacement';
4
5
  /** ONE field the renderer could not give a shape to, and WHERE in the document it would have sat. */
5
6
  export declare class UnmappedField {
@@ -40,19 +41,34 @@ export declare class UnmappedField {
40
41
  * `components.schemas` (and under which name) or referenced in another package's components
41
42
  * document. Every `$ref` — a field, an array item, a union branch, a discriminator `mapping` entry —
42
43
  * is written through it, so the split, the bundled and the MCP document are one renderer.
44
+ *
45
+ * ## A single-use request/response wrapper is written INLINE at its operation (#1303)
46
+ *
47
+ * {@link body} is how an operation asks for its request or success-response schema. A wrapper
48
+ * {@link InlinedWrappers} names is rendered right there — `title` set to its published name, its
49
+ * description, and `properties` even when empty — instead of as a `$ref`; it is never added to
50
+ * `components.schemas`. It is recorded in {@link inlinedTypes} so the description guard still judges
51
+ * it: inlining is never a way around a missing JSDoc.
43
52
  */
44
53
  export declare class SchemaRenderer {
45
54
  /** The model's named types, by key (`DocumentedType.keyOf`). */
46
55
  private readonly types;
47
56
  private readonly placement;
57
+ /** The wrappers an operation defines inline rather than by `$ref` (#1303). */
58
+ private readonly wrappers;
48
59
  private readonly reached;
60
+ private readonly inlined;
49
61
  private readonly external;
50
62
  private readonly unmappedFields;
51
63
  constructor(
52
64
  /** The model's named types, by key (`DocumentedType.keyOf`). */
53
- types: ReadonlyMap<string, DocumentedType>, placement: SchemaPlacement);
65
+ types: ReadonlyMap<string, DocumentedType>, placement: SchemaPlacement,
66
+ /** The wrappers an operation defines inline rather than by `$ref` (#1303). */
67
+ wrappers: InlinedWrappers);
54
68
  /** Keys of the named types this document DEFINES, reached directly or through another schema. */
55
69
  reachedTypes(): ReadonlySet<string>;
70
+ /** Keys of the wrappers this document defined INLINE at their one operation (#1303). */
71
+ inlinedTypes(): ReadonlySet<string>;
56
72
  /** Keys of the named types this document REFERENCES in another package's components document. */
57
73
  externalTypes(): ReadonlySet<string>;
58
74
  /** Every field with no shape, with its pointer. Empty means the document is fully typed. */
@@ -71,8 +87,22 @@ export declare class SchemaRenderer {
71
87
  * components document of a DTO library publishes every type the library exports (#1058).
72
88
  */
73
89
  define(key: string): void;
90
+ /**
91
+ * An operation's request body or success-response schema: the wrapper itself, INLINE, when
92
+ * {@link InlinedWrappers} names it — else exactly what {@link type} writes.
93
+ *
94
+ * The inline form is an object schema carrying `title` (the PUBLISHED name, which client
95
+ * generators name the model from) and `properties` even when the class is empty, which a client
96
+ * generator needs in order to emit an empty class rather than an untyped map.
97
+ */
98
+ body(ref: TypeRef, pointer: string): JsonObject;
74
99
  /** One named type: an object DTO, a string enum, or a union with its DERIVED discriminator. */
75
100
  private namedType;
101
+ /**
102
+ * An object DTO. `title` is set only on an INLINED wrapper, and then `properties` is written even
103
+ * when empty (#1303); a component keeps its name as its key and omits an empty `properties`.
104
+ */
105
+ private objectType;
76
106
  /**
77
107
  * A union, with a `discriminator` ONLY when the model derived one — which it does only when every
78
108
  * branch carries the same property typed as string values (a literal, a string-enum member, or a