@webpieces/openapi-generator 0.4.930 → 0.4.931

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/openapi-generator",
3
- "version": "0.4.930",
3
+ "version": "0.4.931",
4
4
  "description": "Render an ApiDocModel to OpenAPI 3.1.0 — the canonical internal document and the customer-published one, JSON and YAML, from one generation pass. Ships the wp-openapi bin.",
5
5
  "type": "commonjs",
6
6
  "main": "./src/index.js",
@@ -23,8 +23,8 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@webpieces/api-doc-model": "0.4.930",
27
- "@webpieces/core-util": "0.4.930",
26
+ "@webpieces/api-doc-model": "0.4.931",
27
+ "@webpieces/core-util": "0.4.931",
28
28
  "typescript": "5.9.3"
29
29
  },
30
30
  "bin": {
@@ -28,9 +28,13 @@ import { ComponentsInputs, GeneratedDocument, GeneratedDocuments, GenerationInpu
28
28
  * is a green build handing a partner a field with no shape, so the guard names the JSON pointer of
29
29
  * every one and exits non-zero. There is deliberately NO flag to switch it off: the cure is at the
30
30
  * contract, by naming the type.
31
+ *
32
+ * It refuses a declaration with stacked JSDoc the same way, and for the same reason — see
33
+ * {@link StackedJsDocGuard} (#1286).
31
34
  */
32
35
  export declare class OpenApiGenerator {
33
36
  private readonly security;
37
+ private readonly stackedJsDoc;
34
38
  /**
35
39
  * ONE document per `@ApiType` some contract declares, and no others.
36
40
  *
@@ -10,6 +10,7 @@ const OperationRenderer_1 = require("./OperationRenderer");
10
10
  const SchemaPlacement_1 = require("./SchemaPlacement");
11
11
  const SchemaRenderer_1 = require("./SchemaRenderer");
12
12
  const SecurityDeriver_1 = require("./SecurityDeriver");
13
+ const StackedJsDocGuard_1 = require("./StackedJsDocGuard");
13
14
  /** One rendered document, and the renderer that built its schemas — what it defined and referenced. */
14
15
  class RenderedDocument {
15
16
  document;
@@ -67,9 +68,13 @@ const OPENAPI_VERSION = '3.1.0';
67
68
  * is a green build handing a partner a field with no shape, so the guard names the JSON pointer of
68
69
  * every one and exits non-zero. There is deliberately NO flag to switch it off: the cure is at the
69
70
  * contract, by naming the type.
71
+ *
72
+ * It refuses a declaration with stacked JSDoc the same way, and for the same reason — see
73
+ * {@link StackedJsDocGuard} (#1286).
70
74
  */
71
75
  class OpenApiGenerator {
72
76
  security = new SecurityDeriver_1.SecurityDeriver();
77
+ stackedJsDoc = new StackedJsDocGuard_1.StackedJsDocGuard();
73
78
  /**
74
79
  * ONE document per `@ApiType` some contract declares, and no others.
75
80
  *
@@ -79,6 +84,13 @@ class OpenApiGenerator {
79
84
  * with the first.
80
85
  */
81
86
  generate(inputs) {
87
+ // Before ANY selection: a declaration's prose reaches every document it appears in, so the
88
+ // refusal is about the contracts, not about one document (#1286).
89
+ const models = inputs.contracts.map((each) => each.model);
90
+ if (inputs.errorType !== undefined) {
91
+ models.push(inputs.errorType);
92
+ }
93
+ this.stackedJsDoc.refuse(models.flatMap((model) => model.stackedJsDoc), inputs.manifestPath);
82
94
  const documents = [];
83
95
  for (const selection of DocumentSelection_1.DocumentSelection.all()) {
84
96
  const contracts = inputs.contracts.filter((each) => selection.acceptsContract(each.model));
@@ -111,6 +123,7 @@ class OpenApiGenerator {
111
123
  components(inputs) {
112
124
  const model = inputs.model;
113
125
  const where = inputs.manifestPath;
126
+ this.stackedJsDoc.refuse(model.stackedJsDoc, where);
114
127
  this.refuseCollisions(model.collisions, where);
115
128
  const schemas = new SchemaRenderer_1.SchemaRenderer(model.types, new SchemaPlacement_1.SplitPlacement(model.packageName));
116
129
  for (const key of model.exported) {
@@ -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,2DAA0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AU,EAAE,MAAM,CAAC,QAAQ,CAAC;iBAChC,GAAG,CAAC,QAAQ,EAAE,IAAI,uBAAU,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,CAC7D,CAAC;QACN,CAAC;QACD,OAAO,OAAO,CAAC,WAAW,EAAE,CAAC;IACjC,CAAC;IAED,mEAAmE;IAC3D,UAAU,CAAC,MAAwB;QACvC,MAAM,IAAI,GAAG,IAAI,uBAAU,EAAE,CAAC;QAC9B,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,eAAe,EAAE,CAAC;YAC1C,IAAI,CAAC,GAAG,CACJ,MAAM,CAAC,UAAU,EACjB,IAAI,uBAAU,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,wBAAwB,MAAM,CAAC,UAAU,EAAE,CAAC,CAC5E,CAAC;QACN,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC;IAC9B,CAAC;IAED;;;OAGG;IACK,cAAc,CAClB,QAAkC,EAClC,QAAgB,EAChB,YAAoB;QAEpB,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO;QACX,CAAC;QACD,MAAM,QAAQ,GAAG,QAAQ,CAAC,GAAG,CACzB,CAAC,KAAoB,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,OAAO,KAAK,KAAK,CAAC,QAAQ,GAAG,CACnE,CAAC;QACF,MAAM,IAAI,+CAAsB,CAC5B,GAAG,QAAQ,CAAC,MAAM,gBAAgB,QAAQ,8BAA8B,EACxE,YAAY,EACZ,8EAA8E;YAC1E,uFAAuF,EAC3F,QAAQ,CACX,CAAC;IACN,CAAC;CACJ;AA7oBD,4CA6oBC","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 { 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 */\nexport class OpenApiGenerator {\n private readonly security = new SecurityDeriver();\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 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),\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 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 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.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 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 ): JsonObject {\n const discovery = this.render(inputs, contracts, selection, new DiscoveryPlacement());\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 JsonObject();\n for (const contractModel of contracts) {\n this.renderContract(\n contractModel,\n selection,\n operations,\n contract,\n this.webhookContract(),\n hoisted === undefined ? this.security.requirement(schemeNames) : undefined,\n paths,\n webhooks,\n tags,\n );\n }\n\n // The schemas are built HERE, after the operations, because building them is what walks a\n // DTO's fields — and an unmapped field can only be found by that walk. A guard that ran\n // before it would see only the top-level request and response refs and miss every one.\n const renderedSchemas = schemas.components().orUndefined();\n this.refuseUnmapped(schemas.unmapped(), selection.fileName, inputs.manifestPath);\n\n const components = new JsonObject()\n .set('schemas', renderedSchemas)\n .set(\n 'securitySchemes',\n this.renderSecuritySchemes(inputs, contracts, selection, apiKey),\n )\n .set('headers', this.headers(inputs));\n\n const document = new JsonObject()\n .set('openapi', OPENAPI_VERSION)\n .set('info', this.info(inputs, selection))\n .set('servers', this.servers(inputs))\n .set('tags', this.tagList(tags))\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: JsonObject,\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.set(tag, this.tagProse(model) ?? '');\n if (contractModel.entry.isWebhook()) {\n webhooks.set(\n this.eventName(endpoint),\n new JsonObject().set(\n 'post',\n operations.webhook(endpoint, model.contractName, tag, webhookContract),\n ),\n );\n continue;\n }\n const url = `${model.basePath}${endpoint.path}`;\n const existing = paths.get(url);\n const item = existing instanceof JsonObject ? existing : new JsonObject();\n item.set(\n endpoint.httpMethod.toLowerCase(),\n operations.operation(\n endpoint,\n model.contractName,\n tag,\n contract,\n this.security.operation(endpoint.auth, perOperationSecurity),\n ),\n );\n paths.set(url, item);\n }\n }\n\n /**\n * A webhook is keyed by the EVENT NAME, with the `@ApiPath` base deliberately NOT prepended.\n *\n * There is no url of ours here — the partner hosts the endpoint, at whatever path they choose —\n * so publishing `/our-base/delivered` would document a route that exists nowhere. What we are\n * naming is the event we will send.\n */\n private eventName(endpoint: DocumentedEndpoint): string {\n return endpoint.path.replace(/^\\/+/, '');\n }\n\n /**\n * Every named type from every contract, merged by MODEL KEY — which carries the declaring\n * package, so two packages' same-named types never meet here (#1058).\n *\n * Two contracts declaring DIFFERENT types under one key is a hard failure, not a first-wins\n * merge: `components.schemas` is keyed by name, so one of the two would be published as the\n * other's shape, and the operation referring to it would be quietly wrong.\n */\n private mergedTypes(inputs: GenerationInputs): ReadonlyMap<string, DocumentedType> {\n const merged = new Map<string, DocumentedType>();\n const published = new Map<string, DocumentedType>();\n const sources = inputs.contracts.map((each: ContractModel) => each.model);\n const all = inputs.errorType === undefined ? sources : sources.concat([inputs.errorType]);\n for (const model of all) {\n for (const name of Array.from(model.types.keys())) {\n const incoming = model.types.get(name)!;\n const previous = published.get(incoming.schemaName);\n if (\n previous !== undefined &&\n previous.location !== incoming.location &&\n (previous.name !== previous.schemaName || incoming.name !== incoming.schemaName)\n ) {\n throw new OpenApiGenerationError(\n `stripped schema name '${incoming.schemaName}' collides: '${previous.name}' at ${previous.location} and '${incoming.name}' at ${incoming.location}`,\n inputs.manifestPath,\n 'Change schemaNames so every reached declaration has a distinct published name.',\n );\n }\n published.set(incoming.schemaName, incoming);\n const existing = merged.get(name);\n if (\n existing !== undefined &&\n this.signature(existing) !== this.signature(incoming)\n ) {\n throw new OpenApiGenerationError(\n `two different types are both named '${incoming.name}'`,\n `${model.contractName} (${inputs.manifestPath})`,\n 'Rename one of them. `components.schemas` is keyed by name, so one shape ' +\n 'would be published as the other.',\n );\n }\n merged.set(name, incoming);\n }\n }\n return merged;\n }\n\n /** Enough of a type's shape to tell two same-named types apart without comparing prose. */\n private signature(type: DocumentedType): string {\n const fields = type.fields.map((field: DocumentedField) => field.name).join(',');\n return `${fields}|${type.enumValues.join(',')}|${type.unionRefNames.join(',')}`;\n }\n\n /**\n * The ONE api-key regime this document publishes.\n *\n * Two regimes in one document is a hard failure: `securitySchemeNames` is a single ordered list,\n * so there is no honest way to say which regime a given name belongs to, and a document that\n * guessed would publish one regime's header names under the other's scheme keys.\n */\n private singleApiKey(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): DocumentedApiKey | undefined {\n let found: DocumentedApiKey | undefined;\n for (const endpoint of this.selectedEndpoints(contracts, selection)) {\n const apiKey = endpoint.auth?.methods.find(\n (method: DocumentedAuthMethod) => method.apiKey !== undefined,\n )?.apiKey;\n if (apiKey === undefined) {\n continue;\n }\n if (found !== undefined && found.regime !== apiKey.regime) {\n throw new OpenApiGenerationError(\n `the ${selection.fileName} document mixes the api-key regimes ` +\n `'${found.regime}' ` +\n `and '${apiKey.regime}'`,\n inputs.manifestPath,\n 'Publish one regime per document — split the manifest, or move the ' +\n \"other regime's contract out of `apis`.\",\n );\n }\n found = apiKey;\n }\n return found;\n }\n\n /**\n * True when EVERY selected operation demands the credential, which is what licenses hoisting the\n * requirement to the document. A document that mixes credentialled and uncredentialled routes\n * stamps it per-operation instead — hoisting there would tell a partner that a public endpoint\n * needs a key.\n *\n * Judged per DOCUMENT, over the operations that document actually contains, because that is the\n * only question the document's own `security` block answers.\n */\n private everyOperationIsCovered(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): boolean {\n const served = this.selectedEndpoints(contracts, selection);\n return (\n served.length > 0 &&\n served.every(\n (e: DocumentedEndpoint) =>\n e.auth?.methods.length === 1 && e.auth.methods[0].apiKey !== undefined,\n )\n );\n }\n\n /**\n * The endpoints this selection accepts that are routes on OUR server. A webhook is somebody\n * else's route, so it never counts toward our security requirement or our regime.\n */\n private selectedEndpoints(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): readonly DocumentedEndpoint[] {\n const served: DocumentedEndpoint[] = [];\n for (const contract of contracts) {\n if (contract.entry.isWebhook()) {\n continue;\n }\n for (const endpoint of contract.model.endpoints) {\n if (selection.acceptsEndpoint(endpoint)) {\n served.push(endpoint);\n }\n }\n }\n return served;\n }\n\n /** `info`, whose `description` is the ONE piece of prose that differs between the documents. */\n private info(inputs: GenerationInputs, selection: DocumentSelection): JsonObject {\n return new JsonObject()\n .set('title', inputs.manifest.title)\n .set('version', inputs.manifest.version)\n .set('description', selection.description(inputs.description));\n }\n\n private servers(inputs: GenerationInputs): readonly JsonValue[] | undefined {\n if (inputs.manifest.servers.length === 0) {\n return undefined;\n }\n return inputs.manifest.servers.map((server: ServerEntry) =>\n new JsonObject().set('url', server.url).set('description', server.description),\n );\n }\n\n /**\n * `tags[]` in MANIFEST ORDER, because that order IS the published sidebar — one of the two\n * orders in this document that carries meaning and is therefore NOT sorted.\n */\n private tagList(tags: JsonObject): readonly JsonValue[] | undefined {\n const list: JsonValue[] = [];\n for (const name of tags.keys()) {\n const prose = tags.get(name);\n list.push(\n new JsonObject()\n .set('name', name)\n .set('description', prose === '' ? undefined : prose),\n );\n }\n return list.length === 0 ? undefined : list;\n }\n\n private tagProse(model: ApiDocModel): string | undefined {\n return model.description.trim() === '' ? undefined : model.description;\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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AAgB,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;AAzpBD,4CAypBC","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 { StackedJsDocGuard } from './StackedJsDocGuard';\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).\n */\nexport class OpenApiGenerator {\n private readonly security = new SecurityDeriver();\n private readonly stackedJsDoc = new StackedJsDocGuard();\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 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),\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 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 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 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 ): JsonObject {\n const discovery = this.render(inputs, contracts, selection, new DiscoveryPlacement());\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 JsonObject();\n for (const contractModel of contracts) {\n this.renderContract(\n contractModel,\n selection,\n operations,\n contract,\n this.webhookContract(),\n hoisted === undefined ? this.security.requirement(schemeNames) : undefined,\n paths,\n webhooks,\n tags,\n );\n }\n\n // The schemas are built HERE, after the operations, because building them is what walks a\n // DTO's fields — and an unmapped field can only be found by that walk. A guard that ran\n // before it would see only the top-level request and response refs and miss every one.\n const renderedSchemas = schemas.components().orUndefined();\n this.refuseUnmapped(schemas.unmapped(), selection.fileName, inputs.manifestPath);\n\n const components = new JsonObject()\n .set('schemas', renderedSchemas)\n .set(\n 'securitySchemes',\n this.renderSecuritySchemes(inputs, contracts, selection, apiKey),\n )\n .set('headers', this.headers(inputs));\n\n const document = new JsonObject()\n .set('openapi', OPENAPI_VERSION)\n .set('info', this.info(inputs, selection))\n .set('servers', this.servers(inputs))\n .set('tags', this.tagList(tags))\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: JsonObject,\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.set(tag, this.tagProse(model) ?? '');\n if (contractModel.entry.isWebhook()) {\n webhooks.set(\n this.eventName(endpoint),\n new JsonObject().set(\n 'post',\n operations.webhook(endpoint, model.contractName, tag, webhookContract),\n ),\n );\n continue;\n }\n const url = `${model.basePath}${endpoint.path}`;\n const existing = paths.get(url);\n const item = existing instanceof JsonObject ? existing : new JsonObject();\n item.set(\n endpoint.httpMethod.toLowerCase(),\n operations.operation(\n endpoint,\n model.contractName,\n tag,\n contract,\n this.security.operation(endpoint.auth, perOperationSecurity),\n ),\n );\n paths.set(url, item);\n }\n }\n\n /**\n * A webhook is keyed by the EVENT NAME, with the `@ApiPath` base deliberately NOT prepended.\n *\n * There is no url of ours here — the partner hosts the endpoint, at whatever path they choose —\n * so publishing `/our-base/delivered` would document a route that exists nowhere. What we are\n * naming is the event we will send.\n */\n private eventName(endpoint: DocumentedEndpoint): string {\n return endpoint.path.replace(/^\\/+/, '');\n }\n\n /**\n * Every named type from every contract, merged by MODEL KEY — which carries the declaring\n * package, so two packages' same-named types never meet here (#1058).\n *\n * Two contracts declaring DIFFERENT types under one key is a hard failure, not a first-wins\n * merge: `components.schemas` is keyed by name, so one of the two would be published as the\n * other's shape, and the operation referring to it would be quietly wrong.\n */\n private mergedTypes(inputs: GenerationInputs): ReadonlyMap<string, DocumentedType> {\n const merged = new Map<string, DocumentedType>();\n const published = new Map<string, DocumentedType>();\n const sources = inputs.contracts.map((each: ContractModel) => each.model);\n const all = inputs.errorType === undefined ? sources : sources.concat([inputs.errorType]);\n for (const model of all) {\n for (const name of Array.from(model.types.keys())) {\n const incoming = model.types.get(name)!;\n const previous = published.get(incoming.schemaName);\n if (\n previous !== undefined &&\n previous.location !== incoming.location &&\n (previous.name !== previous.schemaName || incoming.name !== incoming.schemaName)\n ) {\n throw new OpenApiGenerationError(\n `stripped schema name '${incoming.schemaName}' collides: '${previous.name}' at ${previous.location} and '${incoming.name}' at ${incoming.location}`,\n inputs.manifestPath,\n 'Change schemaNames so every reached declaration has a distinct published name.',\n );\n }\n published.set(incoming.schemaName, incoming);\n const existing = merged.get(name);\n if (\n existing !== undefined &&\n this.signature(existing) !== this.signature(incoming)\n ) {\n throw new OpenApiGenerationError(\n `two different types are both named '${incoming.name}'`,\n `${model.contractName} (${inputs.manifestPath})`,\n 'Rename one of them. `components.schemas` is keyed by name, so one shape ' +\n 'would be published as the other.',\n );\n }\n merged.set(name, incoming);\n }\n }\n return merged;\n }\n\n /** Enough of a type's shape to tell two same-named types apart without comparing prose. */\n private signature(type: DocumentedType): string {\n const fields = type.fields.map((field: DocumentedField) => field.name).join(',');\n return `${fields}|${type.enumValues.join(',')}|${type.unionRefNames.join(',')}`;\n }\n\n /**\n * The ONE api-key regime this document publishes.\n *\n * Two regimes in one document is a hard failure: `securitySchemeNames` is a single ordered list,\n * so there is no honest way to say which regime a given name belongs to, and a document that\n * guessed would publish one regime's header names under the other's scheme keys.\n */\n private singleApiKey(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): DocumentedApiKey | undefined {\n let found: DocumentedApiKey | undefined;\n for (const endpoint of this.selectedEndpoints(contracts, selection)) {\n const apiKey = endpoint.auth?.methods.find(\n (method: DocumentedAuthMethod) => method.apiKey !== undefined,\n )?.apiKey;\n if (apiKey === undefined) {\n continue;\n }\n if (found !== undefined && found.regime !== apiKey.regime) {\n throw new OpenApiGenerationError(\n `the ${selection.fileName} document mixes the api-key regimes ` +\n `'${found.regime}' ` +\n `and '${apiKey.regime}'`,\n inputs.manifestPath,\n 'Publish one regime per document — split the manifest, or move the ' +\n \"other regime's contract out of `apis`.\",\n );\n }\n found = apiKey;\n }\n return found;\n }\n\n /**\n * True when EVERY selected operation demands the credential, which is what licenses hoisting the\n * requirement to the document. A document that mixes credentialled and uncredentialled routes\n * stamps it per-operation instead — hoisting there would tell a partner that a public endpoint\n * needs a key.\n *\n * Judged per DOCUMENT, over the operations that document actually contains, because that is the\n * only question the document's own `security` block answers.\n */\n private everyOperationIsCovered(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): boolean {\n const served = this.selectedEndpoints(contracts, selection);\n return (\n served.length > 0 &&\n served.every(\n (e: DocumentedEndpoint) =>\n e.auth?.methods.length === 1 && e.auth.methods[0].apiKey !== undefined,\n )\n );\n }\n\n /**\n * The endpoints this selection accepts that are routes on OUR server. A webhook is somebody\n * else's route, so it never counts toward our security requirement or our regime.\n */\n private selectedEndpoints(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): readonly DocumentedEndpoint[] {\n const served: DocumentedEndpoint[] = [];\n for (const contract of contracts) {\n if (contract.entry.isWebhook()) {\n continue;\n }\n for (const endpoint of contract.model.endpoints) {\n if (selection.acceptsEndpoint(endpoint)) {\n served.push(endpoint);\n }\n }\n }\n return served;\n }\n\n /** `info`, whose `description` is the ONE piece of prose that differs between the documents. */\n private info(inputs: GenerationInputs, selection: DocumentSelection): JsonObject {\n return new JsonObject()\n .set('title', inputs.manifest.title)\n .set('version', inputs.manifest.version)\n .set('description', selection.description(inputs.description));\n }\n\n private servers(inputs: GenerationInputs): readonly JsonValue[] | undefined {\n if (inputs.manifest.servers.length === 0) {\n return undefined;\n }\n return inputs.manifest.servers.map((server: ServerEntry) =>\n new JsonObject().set('url', server.url).set('description', server.description),\n );\n }\n\n /**\n * `tags[]` in MANIFEST ORDER, because that order IS the published sidebar — one of the two\n * orders in this document that carries meaning and is therefore NOT sorted.\n */\n private tagList(tags: JsonObject): readonly JsonValue[] | undefined {\n const list: JsonValue[] = [];\n for (const name of tags.keys()) {\n const prose = tags.get(name);\n list.push(\n new JsonObject()\n .set('name', name)\n .set('description', prose === '' ? undefined : prose),\n );\n }\n return list.length === 0 ? undefined : list;\n }\n\n private tagProse(model: ApiDocModel): string | undefined {\n return model.description.trim() === '' ? undefined : model.description;\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"]}
@@ -0,0 +1,22 @@
1
+ import { StackedJsDoc } from '@webpieces/api-doc-model';
2
+ /**
3
+ * The refusal for a declaration with MORE THAN ONE JSDoc block stacked above it (#1286).
4
+ *
5
+ * The extractor records every such declaration it reaches — contract, method, DTO, enum, alias,
6
+ * property — and this guard refuses BEFORE anything is rendered, naming every one of them in a single
7
+ * run, so an author fixing thirty of them is not handed them one build at a time.
8
+ *
9
+ * ## Why a refusal and not "pick the right block"
10
+ *
11
+ * Any choice of block hides the mistake. "First wins" published a 69-line file header as an enum's
12
+ * description; "nearest wins" (TypeScript's own `getDocumentationComment`) still silently drops a doc
13
+ * a refactor stranded on top of a NEW declaration — the declaration it belonged to loses it, and
14
+ * nothing anywhere says so. Each shape has exactly one correct fix and only the author can tell which
15
+ * shape it is, so the cure names both. There is deliberately no flag to switch this off, the same as
16
+ * the unmapped-field refusal: a published description that belongs to something else is a contract
17
+ * telling a partner the wrong thing.
18
+ */
19
+ export declare class StackedJsDocGuard {
20
+ /** Refuse when any of `stacked` exists; `manifestPath` is where the generation was asked from. */
21
+ refuse(stacked: readonly StackedJsDoc[], manifestPath: string): void;
22
+ }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StackedJsDocGuard = void 0;
4
+ const OpenApiGenerationError_1 = require("../OpenApiGenerationError");
5
+ /**
6
+ * The refusal for a declaration with MORE THAN ONE JSDoc block stacked above it (#1286).
7
+ *
8
+ * The extractor records every such declaration it reaches — contract, method, DTO, enum, alias,
9
+ * property — and this guard refuses BEFORE anything is rendered, naming every one of them in a single
10
+ * run, so an author fixing thirty of them is not handed them one build at a time.
11
+ *
12
+ * ## Why a refusal and not "pick the right block"
13
+ *
14
+ * Any choice of block hides the mistake. "First wins" published a 69-line file header as an enum's
15
+ * description; "nearest wins" (TypeScript's own `getDocumentationComment`) still silently drops a doc
16
+ * a refactor stranded on top of a NEW declaration — the declaration it belonged to loses it, and
17
+ * nothing anywhere says so. Each shape has exactly one correct fix and only the author can tell which
18
+ * shape it is, so the cure names both. There is deliberately no flag to switch this off, the same as
19
+ * the unmapped-field refusal: a published description that belongs to something else is a contract
20
+ * telling a partner the wrong thing.
21
+ */
22
+ class StackedJsDocGuard {
23
+ /** Refuse when any of `stacked` exists; `manifestPath` is where the generation was asked from. */
24
+ refuse(stacked, manifestPath) {
25
+ const unique = new Map();
26
+ for (const each of stacked) {
27
+ if (!unique.has(each.location)) {
28
+ unique.set(each.location, each);
29
+ }
30
+ }
31
+ if (unique.size === 0) {
32
+ return;
33
+ }
34
+ const pointers = Array.from(unique.values()).map((each) => `${each.location} ${each.declaration} — ${each.blockLines.length} JSDoc blocks, ` +
35
+ `starting on lines ${each.blockLines.join(', ')}`);
36
+ throw new OpenApiGenerationError_1.OpenApiGenerationError(`${unique.size} declaration(s) have more than one JSDoc block stacked above them, so ` +
37
+ 'no description can be published for them', manifestPath, 'A section or file header must be a /* */ comment, never /** */; a doc stranded above ' +
38
+ 'another declaration must move back onto its own declaration. Leave exactly one ' +
39
+ '/** */ block on each declaration.', pointers);
40
+ }
41
+ }
42
+ exports.StackedJsDocGuard = StackedJsDocGuard;
43
+ //# sourceMappingURL=StackedJsDocGuard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StackedJsDocGuard.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/StackedJsDocGuard.ts"],"names":[],"mappings":";;;AACA,sEAAmE;AAEnE;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,iBAAiB;IAC1B,kGAAkG;IAClG,MAAM,CAAC,OAAgC,EAAE,YAAoB;QACzD,MAAM,MAAM,GAAG,IAAI,GAAG,EAAwB,CAAC;QAC/C,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YACzB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC7B,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACpC,CAAC;QACL,CAAC;QACD,IAAI,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,CAAC;YACpB,OAAO;QACX,CAAC;QACD,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAC5C,CAAC,IAAkB,EAAE,EAAE,CACnB,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,iBAAiB;YACjF,qBAAqB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACxD,CAAC;QACF,MAAM,IAAI,+CAAsB,CAC5B,GAAG,MAAM,CAAC,IAAI,wEAAwE;YAClF,0CAA0C,EAC9C,YAAY,EACZ,uFAAuF;YACnF,iFAAiF;YACjF,mCAAmC,EACvC,QAAQ,CACX,CAAC;IACN,CAAC;CACJ;AA3BD,8CA2BC","sourcesContent":["import { StackedJsDoc } from '@webpieces/api-doc-model';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\n\n/**\n * The refusal for a declaration with MORE THAN ONE JSDoc block stacked above it (#1286).\n *\n * The extractor records every such declaration it reaches — contract, method, DTO, enum, alias,\n * property — and this guard refuses BEFORE anything is rendered, naming every one of them in a single\n * run, so an author fixing thirty of them is not handed them one build at a time.\n *\n * ## Why a refusal and not \"pick the right block\"\n *\n * Any choice of block hides the mistake. \"First wins\" published a 69-line file header as an enum's\n * description; \"nearest wins\" (TypeScript's own `getDocumentationComment`) still silently drops a doc\n * a refactor stranded on top of a NEW declaration — the declaration it belonged to loses it, and\n * nothing anywhere says so. Each shape has exactly one correct fix and only the author can tell which\n * shape it is, so the cure names both. There is deliberately no flag to switch this off, the same as\n * the unmapped-field refusal: a published description that belongs to something else is a contract\n * telling a partner the wrong thing.\n */\nexport class StackedJsDocGuard {\n /** Refuse when any of `stacked` exists; `manifestPath` is where the generation was asked from. */\n refuse(stacked: readonly StackedJsDoc[], manifestPath: string): void {\n const unique = new Map<string, StackedJsDoc>();\n for (const each of stacked) {\n if (!unique.has(each.location)) {\n unique.set(each.location, each);\n }\n }\n if (unique.size === 0) {\n return;\n }\n const pointers = Array.from(unique.values()).map(\n (each: StackedJsDoc) =>\n `${each.location} ${each.declaration} — ${each.blockLines.length} JSDoc blocks, ` +\n `starting on lines ${each.blockLines.join(', ')}`,\n );\n throw new OpenApiGenerationError(\n `${unique.size} declaration(s) have more than one JSDoc block stacked above them, so ` +\n 'no description can be published for them',\n manifestPath,\n 'A section or file header must be a /* */ comment, never /** */; a doc stranded above ' +\n 'another declaration must move back onto its own declaration. Leave exactly one ' +\n '/** */ block on each declaration.',\n pointers,\n );\n }\n}\n"]}