@webpieces/openapi-generator 0.4.945 → 0.4.946
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +37 -1
- package/package.json +3 -3
- package/src/generate/DocLinkGuard.d.ts +13 -1
- package/src/generate/DocLinkGuard.js +22 -1
- package/src/generate/DocLinkGuard.js.map +1 -1
- package/src/generate/DocumentSelection.d.ts +12 -3
- package/src/generate/DocumentSelection.js +12 -3
- package/src/generate/DocumentSelection.js.map +1 -1
- package/src/generate/HiddenFieldGuard.d.ts +41 -0
- package/src/generate/HiddenFieldGuard.js +103 -0
- package/src/generate/HiddenFieldGuard.js.map +1 -0
- package/src/generate/OpenApiGenerator.d.ts +9 -6
- package/src/generate/OpenApiGenerator.js +27 -51
- package/src/generate/OpenApiGenerator.js.map +1 -1
- package/src/generate/SchemaRenderer.d.ts +19 -1
- package/src/generate/SchemaRenderer.js +18 -1
- package/src/generate/SchemaRenderer.js.map +1 -1
- package/src/generate/UnpublishedComponentsGuard.d.ts +15 -0
- package/src/generate/UnpublishedComponentsGuard.js +60 -0
- package/src/generate/UnpublishedComponentsGuard.js.map +1 -0
|
@@ -11,6 +11,8 @@ const OperationRenderer_1 = require("./OperationRenderer");
|
|
|
11
11
|
const SchemaPlacement_1 = require("./SchemaPlacement");
|
|
12
12
|
const SchemaRenderer_1 = require("./SchemaRenderer");
|
|
13
13
|
const SecurityDeriver_1 = require("./SecurityDeriver");
|
|
14
|
+
const HiddenFieldGuard_1 = require("./HiddenFieldGuard");
|
|
15
|
+
const UnpublishedComponentsGuard_1 = require("./UnpublishedComponentsGuard");
|
|
14
16
|
const McpToolNameGuard_1 = require("./McpToolNameGuard");
|
|
15
17
|
const MissingReturnsGuard_1 = require("./MissingReturnsGuard");
|
|
16
18
|
const SummaryGuard_1 = require("./SummaryGuard");
|
|
@@ -31,19 +33,6 @@ class RenderedDocument {
|
|
|
31
33
|
const BUNDLED_SUFFIX = '.bundled';
|
|
32
34
|
/** The document a DTO library publishes, without its extension (#1058). */
|
|
33
35
|
const COMPONENTS_DOCUMENT = 'components.openapi';
|
|
34
|
-
/**
|
|
35
|
-
* Every cure for a type reached in a package that publishes no components document.
|
|
36
|
-
*
|
|
37
|
-
* Tagging is offered ONLY for a package that is already a role:api-lib DTO library (#1064, D5): a
|
|
38
|
-
* general library such as `company-core` is refused the tag by validate-nx-wiring and by the
|
|
39
|
-
* openapi-components-generate executor, so "tag the package" is never a way out of moving the type.
|
|
40
|
-
*/
|
|
41
|
-
const PUBLISH_COMPONENTS_CURE = 'Move each type into a role:api-lib DTO library that publishes a components document — as a ' +
|
|
42
|
-
'`…Dto` string enum when it is a string-literal union. Only when the declaring package is ITSELF a ' +
|
|
43
|
-
'role:api-lib DTO library, tag it "generate:openapi-components" so it publishes one (with a ' +
|
|
44
|
-
'"kind": "components" openapi.manifest.json naming its entry files; outside nx, render that manifest ' +
|
|
45
|
-
'with wp-openapi into the directory the package is packed from); a general library is refused the ' +
|
|
46
|
-
"tag. A document references another package's schema; it never copies one in.";
|
|
47
36
|
/** The OpenAPI version this generator writes. See the class doc for why 3.1 and not 3.0. */
|
|
48
37
|
const OPENAPI_VERSION = '3.1.0';
|
|
49
38
|
/**
|
|
@@ -83,7 +72,9 @@ const OPENAPI_VERSION = '3.1.0';
|
|
|
83
72
|
* one run (#1292). Likewise an operation with no valid `@summary` ({@link SummaryGuard}) and an MCP
|
|
84
73
|
* tool whose name the Claude Connectors Directory would refuse ({@link McpToolNameGuard}) (#1296).
|
|
85
74
|
* And a JSDoc `{@link}` the document cannot publish under its target's published name
|
|
86
|
-
* ({@link DocLinkGuard}) (#1284).
|
|
75
|
+
* ({@link DocLinkGuard}) (#1284) — a `@hidden` field's included, in the customer document. And a
|
|
76
|
+
* `@hidden` field that is required, or a type whose every field is `@hidden` ({@link HiddenFieldGuard})
|
|
77
|
+
* (#1246).
|
|
87
78
|
*/
|
|
88
79
|
class OpenApiGenerator {
|
|
89
80
|
security = new SecurityDeriver_1.SecurityDeriver();
|
|
@@ -92,6 +83,8 @@ class OpenApiGenerator {
|
|
|
92
83
|
summaries = new SummaryGuard_1.SummaryGuard();
|
|
93
84
|
toolNames = new McpToolNameGuard_1.McpToolNameGuard();
|
|
94
85
|
tagOwnership = new TagOwnership_1.TagOwnership();
|
|
86
|
+
hiddenFields = new HiddenFieldGuard_1.HiddenFieldGuard();
|
|
87
|
+
unpublished = new UnpublishedComponentsGuard_1.UnpublishedComponentsGuard();
|
|
95
88
|
/**
|
|
96
89
|
* ONE document per `@ApiType` some contract declares, and no others.
|
|
97
90
|
*
|
|
@@ -112,6 +105,7 @@ class OpenApiGenerator {
|
|
|
112
105
|
this.toolNames.refuse(inputs.contracts, inputs.manifestPath);
|
|
113
106
|
this.missingReturns.refuse(inputs.contracts, inputs.manifestPath);
|
|
114
107
|
this.tagOwnership.refuseSharedOwners(inputs.contracts, inputs.manifestPath);
|
|
108
|
+
this.hiddenFields.refuse(this.mergedTypes(inputs), inputs.manifestPath);
|
|
115
109
|
// Collected across EVERY OpenAPI document of the run and refused once, after them all, so an
|
|
116
110
|
// author is handed every undocumented schema at once rather than one document at a time.
|
|
117
111
|
const undocumented = new UndocumentedSchemaGuard_1.UndocumentedSchemaGuard();
|
|
@@ -130,7 +124,7 @@ class OpenApiGenerator {
|
|
|
130
124
|
const placement = new SchemaPlacement_1.SplitPlacement(inputs.homePackage);
|
|
131
125
|
const split = this.render(inputs, contracts, selection, placement);
|
|
132
126
|
this.resolveLinks(links, split, inputs, contracts, selection, placement);
|
|
133
|
-
this.
|
|
127
|
+
this.refuseExternalReferences(split.schemas, inputs, selection);
|
|
134
128
|
undocumented.collect(split.schemas.reachedTypes(), this.mergedTypes(inputs));
|
|
135
129
|
// An inlined wrapper is still a published schema, so it still needs its description.
|
|
136
130
|
undocumented.collect(split.schemas.inlinedTypes(), this.mergedTypes(inputs));
|
|
@@ -157,18 +151,21 @@ class OpenApiGenerator {
|
|
|
157
151
|
const where = inputs.manifestPath;
|
|
158
152
|
this.stackedJsDoc.refuse(model.stackedJsDoc, where);
|
|
159
153
|
this.refuseCollisions(model.collisions, where);
|
|
160
|
-
|
|
154
|
+
this.hiddenFields.refuse(model.types, where);
|
|
155
|
+
// Every field, `@hidden` ones included: one components document serves every audience, and a
|
|
156
|
+
// customer document that would have to withhold one of its fields refuses instead (#1246).
|
|
157
|
+
const schemas = new SchemaRenderer_1.SchemaRenderer(model.types, new SchemaPlacement_1.SplitPlacement(model.packageName), InlinedWrappers_1.InlinedWrappers.none(), false);
|
|
161
158
|
for (const key of model.exported) {
|
|
162
159
|
schemas.define(key);
|
|
163
160
|
}
|
|
164
161
|
const rendered = schemas.components();
|
|
165
162
|
this.refuseUnmapped(schemas.unmapped(), COMPONENTS_DOCUMENT, where);
|
|
166
|
-
this.
|
|
163
|
+
this.unpublished.refuse(schemas.externalTypes(), model.types, inputs.upstream, COMPONENTS_DOCUMENT, where);
|
|
167
164
|
const undocumented = new UndocumentedSchemaGuard_1.UndocumentedSchemaGuard();
|
|
168
165
|
undocumented.collect(schemas.reachedTypes(), model.types);
|
|
169
166
|
undocumented.refuse(where);
|
|
170
167
|
const links = new DocLinkGuard_1.DocLinkGuard();
|
|
171
|
-
links.resolve(rendered, new DocLinkGuard_1.DocumentLinkNaming(model.types, schemas, new SchemaPlacement_1.SplitPlacement(model.packageName), new Map()), COMPONENTS_DOCUMENT);
|
|
168
|
+
links.resolve(rendered, new DocLinkGuard_1.DocumentLinkNaming(model.types, schemas, new SchemaPlacement_1.SplitPlacement(model.packageName), new Map(), false), COMPONENTS_DOCUMENT);
|
|
172
169
|
links.refuse(where);
|
|
173
170
|
if (rendered.isEmpty()) {
|
|
174
171
|
throw new OpenApiGenerationError_1.OpenApiGenerationError(`${model.packageName}'s entries export no type with a schema`, where, 'Name the entry files that export the library\'s DTOs and enums — usually "src/index.ts".');
|
|
@@ -209,13 +206,13 @@ class OpenApiGenerator {
|
|
|
209
206
|
* recording the ones it cannot name — see {@link DocLinkGuard}.
|
|
210
207
|
*/
|
|
211
208
|
resolveLinks(links, rendered, inputs, contracts, selection, placement) {
|
|
212
|
-
const naming = new DocLinkGuard_1.DocumentLinkNaming(this.mergedTypes(inputs), rendered.schemas, placement, this.publishedOperationIds(contracts, selection, inputs));
|
|
209
|
+
const naming = new DocLinkGuard_1.DocumentLinkNaming(this.mergedTypes(inputs), rendered.schemas, placement, this.publishedOperationIds(contracts, selection, inputs), selection.dropHidden);
|
|
213
210
|
links.resolve(rendered.document, naming, selection.fileName);
|
|
214
211
|
}
|
|
215
212
|
/** ONE document, from the operations this selection accepts and nothing else. */
|
|
216
213
|
render(inputs, contracts, selection, placement) {
|
|
217
214
|
const types = this.mergedTypes(inputs);
|
|
218
|
-
const schemas = new SchemaRenderer_1.SchemaRenderer(types, placement, this.wrappers(inputs, selection, types));
|
|
215
|
+
const schemas = new SchemaRenderer_1.SchemaRenderer(types, placement, this.wrappers(inputs, selection, types), selection.dropHidden);
|
|
219
216
|
const operations = this.operationRenderer(inputs, selection, schemas);
|
|
220
217
|
this.refuseDuplicateOperationIds(contracts, selection, operations, inputs.manifestPath);
|
|
221
218
|
const apiKey = this.singleApiKey(inputs, contracts, selection);
|
|
@@ -343,38 +340,17 @@ class OpenApiGenerator {
|
|
|
343
340
|
return ids;
|
|
344
341
|
}
|
|
345
342
|
/**
|
|
346
|
-
*
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
* exactly the duplication this replaces. A document that exists but lacks the schema is stale.
|
|
343
|
+
* A split document's references into other packages' components documents: each must be
|
|
344
|
+
* published there (#1058), and — in the customer document — none may carry a `@hidden` field,
|
|
345
|
+
* which a shared components document cannot withhold (#1246).
|
|
350
346
|
*/
|
|
351
|
-
|
|
352
|
-
const
|
|
353
|
-
const
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
if (owner === undefined) {
|
|
359
|
-
unpublished.push(`${declared}: its file belongs to no package, so no document can own its schema`);
|
|
360
|
-
continue;
|
|
361
|
-
}
|
|
362
|
-
const published = upstream.publishedBy(owner);
|
|
363
|
-
if (published === undefined) {
|
|
364
|
-
const reason = upstream.missingFor(owner)?.reason ?? 'it was never located';
|
|
365
|
-
unpublished.push(`${declared}: ${owner} publishes no components document — ${reason}`);
|
|
366
|
-
}
|
|
367
|
-
else if (!published.schemaNames.has(type.schemaName)) {
|
|
368
|
-
stale.push(`${declared}: ${published.documentPath} has no schema '${type.schemaName}'`);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
if (unpublished.length > 0) {
|
|
372
|
-
throw new OpenApiGenerationError_1.OpenApiGenerationError(`${unpublished.length} type(s) ${fileName} reaches are declared in a package that ` +
|
|
373
|
-
'publishes no components document', where, PUBLISH_COMPONENTS_CURE, unpublished);
|
|
374
|
-
}
|
|
375
|
-
if (stale.length > 0) {
|
|
376
|
-
throw new OpenApiGenerationError_1.OpenApiGenerationError(`${stale.length} type(s) ${fileName} references are missing from their package's components document`, where, 'Regenerate the upstream components document before this one — it is older than its ' +
|
|
377
|
-
'source (in nx, "^openapi-components-generate" in this target\'s dependsOn orders it).', stale);
|
|
347
|
+
refuseExternalReferences(schemas, inputs, selection) {
|
|
348
|
+
const external = schemas.externalTypes();
|
|
349
|
+
const types = this.mergedTypes(inputs);
|
|
350
|
+
const where = inputs.manifestPath;
|
|
351
|
+
this.unpublished.refuse(external, types, inputs.upstream, selection.fileName, where);
|
|
352
|
+
if (selection.dropHidden) {
|
|
353
|
+
this.hiddenFields.refuseExternal(external, types, selection.fileName, where);
|
|
378
354
|
}
|
|
379
355
|
}
|
|
380
356
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OpenApiGenerator.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/generate/OpenApiGenerator.ts"],"names":[],"mappings":";;;AAAA,4DAUkC;AAClC,mDAA2D;AAC3D,sEAAmE;AAEnE,yDAM4B;AAC5B,iDAAkE;AAClE,2DAAwD;AACxD,2DAA0E;A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AU,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;AA9wBD,4CA8wBC","sourcesContent":["import {\n ApiDocModel,\n DocumentedApiKey,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedField,\n DocumentedType,\n OperationIds,\n TypeNameCollision,\n TypeRef,\n} from '@webpieces/api-doc-model';\nimport { JsonObject, JsonValue } from '../json/JsonObject';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\nimport { ErrorResponseEntry, ServerEntry } from '../manifest/OpenApiManifest';\nimport {\n ComponentsInputs,\n ContractModel,\n GeneratedDocument,\n GeneratedDocuments,\n GenerationInputs,\n} from './GenerationInputs';\nimport { DocLinkGuard, DocumentLinkNaming } from './DocLinkGuard';\nimport { DocumentSelection } from './DocumentSelection';\nimport { OperationRenderer, ResponseContract } from './OperationRenderer';\nimport {\n BundledNames,\n BundledPlacement,\n ComponentsReference,\n DiscoveryPlacement,\n SchemaPlacement,\n SplitPlacement,\n} from './SchemaPlacement';\nimport { SchemaRenderer, UnmappedField } from './SchemaRenderer';\nimport { SecurityDeriver } from './SecurityDeriver';\nimport { 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 * And a JSDoc `{@link}` the document cannot publish under its target's published name\n * ({@link DocLinkGuard}) (#1284).\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 links = new DocLinkGuard();\n const documents: GeneratedDocument[] = [];\n for (const selection of DocumentSelection.all()) {\n const contracts = inputs.contracts.filter((each: ContractModel) =>\n selection.acceptsContract(each.model),\n );\n if (contracts.length === 0) {\n continue;\n }\n if (selection.inlinesEveryPackage) {\n documents.push(\n new GeneratedDocument(\n selection.fileName,\n this.bundled(inputs, contracts, selection, links, undocumented),\n ),\n );\n continue;\n }\n this.refuseCollisions(this.collisionsOf(inputs, contracts), inputs.manifestPath);\n const placement = new SplitPlacement(inputs.homePackage);\n const split = this.render(inputs, contracts, selection, placement);\n this.resolveLinks(links, split, inputs, contracts, selection, placement);\n this.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, links),\n ),\n );\n }\n undocumented.refuse(inputs.manifestPath);\n links.refuse(inputs.manifestPath);\n return new GeneratedDocuments(documents);\n }\n\n /**\n * A DTO library's COMPONENTS-ONLY document (#1058): `openapi`, `info`, `x-webpieces-id` and\n * `components.schemas` — every type the library exports and declares, with every OTHER package's\n * type a `$ref` into that package's own components document, so a chain of DTO libraries is a\n * chain of documents of any depth.\n *\n * `info.version` is the PACKAGE version. The package-qualified URI downstream documents reference\n * it by (`@scope/pkg/components.openapi.json`) is stated as `x-webpieces-id`, because OpenAPI 3.1's\n * root object admits no `$id` — a 3.1 validator rejects one — and the document must validate on its\n * own.\n */\n components(inputs: ComponentsInputs): GeneratedDocument {\n const model = inputs.model;\n const where = inputs.manifestPath;\n this.stackedJsDoc.refuse(model.stackedJsDoc, where);\n this.refuseCollisions(model.collisions, where);\n 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 const links = new DocLinkGuard();\n links.resolve(\n rendered,\n new DocumentLinkNaming(\n model.types,\n schemas,\n new SplitPlacement(model.packageName),\n new Map(),\n ),\n COMPONENTS_DOCUMENT,\n );\n links.refuse(where);\n if (rendered.isEmpty()) {\n throw new OpenApiGenerationError(\n `${model.packageName}'s entries export no type with a schema`,\n where,\n 'Name the entry files that export the library\\'s DTOs and enums — usually \"src/index.ts\".',\n );\n }\n return new GeneratedDocument(\n COMPONENTS_DOCUMENT,\n new JsonObject()\n .set('openapi', OPENAPI_VERSION)\n .set(\n 'info',\n new JsonObject()\n .set('title', inputs.manifest.title)\n .set('version', model.packageVersion),\n )\n .set('x-webpieces-id', ComponentsReference.documentUri(model.packageName))\n .set('components', new JsonObject().set('schemas', rendered)),\n );\n }\n\n /**\n * The SELF-CONTAINED form of a document: every reached schema defined locally, whichever package\n * declares it — the `*.bundled.json` sibling of a split document, and the MCP projection.\n *\n * Two passes, because a schema's NAME depends on which other schemas the document reaches: the\n * first renders with every type under its unique model key just to learn the reached set, and the\n * second renders with the names {@link BundledNames} assigns from it. Rendering is a pure walk of\n * the model, so the second pass reaches exactly what the first did.\n */\n private bundled(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n links: DocLinkGuard,\n undocumented?: UndocumentedSchemaGuard,\n ): JsonObject {\n // The discovery pass publishes nothing, so its links are not judged: the named pass below\n // reaches exactly the same prose.\n const discovery = this.render(inputs, contracts, selection, new DiscoveryPlacement());\n // The MCP projection inlines every type it reaches, from any package, so it is judged here\n // over that whole set (#1292). A split document's bundled sibling is not: each type in it is\n // judged by the document — or the components document — that defines it.\n undocumented?.collect(discovery.schemas.reachedTypes(), this.mergedTypes(inputs));\n const names = BundledNames.assign(\n discovery.schemas.reachedTypes(),\n this.mergedTypes(inputs),\n inputs.homePackage,\n );\n const placement = new BundledPlacement(names);\n const rendered = this.render(inputs, contracts, selection, placement);\n this.resolveLinks(links, rendered, inputs, contracts, selection, placement);\n return rendered.document;\n }\n\n /**\n * Publish every `{@link}` in a rendered document under its target's name in THAT document (#1284),\n * recording the ones it cannot name — see {@link DocLinkGuard}.\n */\n private resolveLinks(\n links: DocLinkGuard,\n rendered: RenderedDocument,\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n placement: SchemaPlacement,\n ): void {\n const naming = new DocumentLinkNaming(\n this.mergedTypes(inputs),\n rendered.schemas,\n placement,\n this.publishedOperationIds(contracts, selection, inputs),\n );\n links.resolve(rendered.document, naming, selection.fileName);\n }\n\n /** ONE document, from the operations this selection accepts and nothing else. */\n private render(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n placement: SchemaPlacement,\n ): RenderedDocument {\n const types = this.mergedTypes(inputs);\n const schemas = new SchemaRenderer(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 /** `Contract.method` -> operationId, for every operation this document publishes. */\n private publishedOperationIds(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n inputs: GenerationInputs,\n ): ReadonlyMap<string, string> {\n const operationIds = new OperationIds(inputs.manifest.operationIds);\n const ids = new Map<string, string>();\n for (const contractModel of contracts) {\n const model = contractModel.model;\n for (const endpoint of model.endpoints) {\n if (selection.acceptsEndpoint(endpoint)) {\n ids.set(\n `${model.contractName}.${endpoint.methodName}`,\n operationIds.of(model.contractName, endpoint.methodName),\n );\n }\n }\n }\n return ids;\n }\n\n /**\n * 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,4DAUkC;AAClC,mDAA2D;AAC3D,sEAAmE;AAEnE,yDAM4B;AAC5B,iDAAkE;AAClE,2DAAwD;AACxD,2DAA0E;AAC1E,uDAO2B;AAC3B,qDAAiE;AACjE,uDAAoD;AACpD,yDAAsD;AACtD,6EAA0E;AAC1E,yDAAsD;AACtD,+DAA4D;AAC5D,iDAA8C;AAC9C,2DAAwD;AACxD,iDAA8C;AAC9C,uEAAoE;AACpE,uDAAoD;AAEpD,uGAAuG;AACvG,MAAM,gBAAgB;IAEL;IACA;IAFb,YACa,QAAoB,EACpB,OAAuB;QADvB,aAAQ,GAAR,QAAQ,CAAY;QACpB,YAAO,GAAP,OAAO,CAAgB;IACjC,CAAC;CACP;AAED,8FAA8F;AAC9F,MAAM,cAAc,GAAG,UAAU,CAAC;AAElC,2EAA2E;AAC3E,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAEjD,4FAA4F;AAC5F,MAAM,eAAe,GAAG,OAAO,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAa,gBAAgB;IACR,QAAQ,GAAG,IAAI,iCAAe,EAAE,CAAC;IACjC,YAAY,GAAG,IAAI,qCAAiB,EAAE,CAAC;IACvC,cAAc,GAAG,IAAI,yCAAmB,EAAE,CAAC;IAC3C,SAAS,GAAG,IAAI,2BAAY,EAAE,CAAC;IAC/B,SAAS,GAAG,IAAI,mCAA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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;AAtvBD,4CAsvBC","sourcesContent":["import {\n ApiDocModel,\n DocumentedApiKey,\n DocumentedAuthMethod,\n DocumentedEndpoint,\n DocumentedField,\n DocumentedType,\n OperationIds,\n TypeNameCollision,\n TypeRef,\n} from '@webpieces/api-doc-model';\nimport { JsonObject, JsonValue } from '../json/JsonObject';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\nimport { ErrorResponseEntry, ServerEntry } from '../manifest/OpenApiManifest';\nimport {\n ComponentsInputs,\n ContractModel,\n GeneratedDocument,\n GeneratedDocuments,\n GenerationInputs,\n} from './GenerationInputs';\nimport { DocLinkGuard, DocumentLinkNaming } from './DocLinkGuard';\nimport { DocumentSelection } from './DocumentSelection';\nimport { OperationRenderer, ResponseContract } from './OperationRenderer';\nimport {\n BundledNames,\n BundledPlacement,\n ComponentsReference,\n DiscoveryPlacement,\n SchemaPlacement,\n SplitPlacement,\n} from './SchemaPlacement';\nimport { SchemaRenderer, UnmappedField } from './SchemaRenderer';\nimport { SecurityDeriver } from './SecurityDeriver';\nimport { HiddenFieldGuard } from './HiddenFieldGuard';\nimport { UnpublishedComponentsGuard } from './UnpublishedComponentsGuard';\nimport { McpToolNameGuard } from './McpToolNameGuard';\nimport { MissingReturnsGuard } from './MissingReturnsGuard';\nimport { SummaryGuard } from './SummaryGuard';\nimport { StackedJsDocGuard } from './StackedJsDocGuard';\nimport { TagOwnership } from './TagOwnership';\nimport { UndocumentedSchemaGuard } from './UndocumentedSchemaGuard';\nimport { InlinedWrappers } from './InlinedWrappers';\n\n/** One rendered document, and the renderer that built its schemas — what it defined and referenced. */\nclass RenderedDocument {\n constructor(\n readonly document: JsonObject,\n readonly schemas: SchemaRenderer,\n ) {}\n}\n\n/** The suffix of a split document's self-contained sibling: `public-openapi.bundled.json`. */\nconst BUNDLED_SUFFIX = '.bundled';\n\n/** The document a DTO library publishes, without its extension (#1058). */\nconst COMPONENTS_DOCUMENT = 'components.openapi';\n\n/** The OpenAPI version this generator writes. See the class doc for why 3.1 and not 3.0. */\nconst OPENAPI_VERSION = '3.1.0';\n\n/**\n * {@link GenerationInputs} -> one OpenAPI 3.1.0 document per `@ApiType` some contract declares.\n *\n * ## 3.1, because it is what the model can state HONESTLY\n *\n * `type: [T, \"null\"]` instead of a `nullable` keyword; a `description` legal beside a `$ref`; a\n * top-level `webhooks:` block. Each of those is a fact the model holds that 3.0 would have forced\n * this renderer to drop or to lie about. 3.1's schema dialect is also JSON Schema 2020-12, which is\n * what MCP `tools/list` speaks.\n *\n * ## ONE render function, called once per document\n *\n * ```\n * ApiDocModel --> render(selection) --+--> full-private-openapi.json SVC_TO_SVC contracts\n * +--> public-openapi.json EXTERNAL_CUSTOMER contracts, minus hidden methods\n * +--> mcp-openapi.json MCP contracts\n * ```\n *\n * `components.schemas` is built by walking OUTWARD from the operations the selection accepted, so an\n * unselected operation's DTOs are never constructed. See {@link DocumentSelection} for why that\n * asymmetry — a bug emits nothing, rather than shipping an unreleased feature's schemas with only\n * its URL removed — decides the whole design.\n *\n * ## It REFUSES to write an unmapped field\n *\n * An unmapped type renders as an empty schema, which in JSON Schema means \"anything\". Publishing one\n * is a green build handing a partner a field with no shape, so the guard names the JSON pointer of\n * every one and exits non-zero. There is deliberately NO flag to switch it off: the cure is at the\n * contract, by naming the type.\n *\n * It refuses a declaration with stacked JSDoc the same way, and for the same reason — see\n * {@link StackedJsDocGuard} (#1286). And, in every document including the MCP projection and its tool\n * catalogs, an operation with a body but no `@returns` ({@link MissingReturnsGuard}) and a published\n * schema with no JSDoc description ({@link UndocumentedSchemaGuard}) — each naming every offender in\n * one run (#1292). Likewise an operation with no valid `@summary` ({@link SummaryGuard}) and an MCP\n * tool whose name the Claude Connectors Directory would refuse ({@link McpToolNameGuard}) (#1296).\n * And a JSDoc `{@link}` the document cannot publish under its target's published name\n * ({@link DocLinkGuard}) (#1284) — a `@hidden` field's included, in the customer document. And a\n * `@hidden` field that is required, or a type whose every field is `@hidden` ({@link HiddenFieldGuard})\n * (#1246).\n */\nexport class OpenApiGenerator {\n private readonly security = new SecurityDeriver();\n private readonly stackedJsDoc = new StackedJsDocGuard();\n private readonly missingReturns = new MissingReturnsGuard();\n private readonly summaries = new SummaryGuard();\n private readonly toolNames = new McpToolNameGuard();\n private readonly tagOwnership = new TagOwnership();\n private readonly hiddenFields = new HiddenFieldGuard();\n private readonly unpublished = new UnpublishedComponentsGuard();\n\n /**\n * ONE document per `@ApiType` some contract declares, and no others.\n *\n * A document nobody asked for is not written empty — it is not written. That is the ONE\n * conditional in the whole pipeline, and it lives here rather than in three places: no contract\n * declaring `MCP` means no `mcp-openapi.json`, with no second \"is it empty?\" rule to keep in step\n * with the first.\n */\n generate(inputs: GenerationInputs): GeneratedDocuments {\n // Before ANY selection: a declaration's prose reaches every document it appears in, so the\n // refusal is about the contracts, not about one document (#1286).\n const models = inputs.contracts.map((each: ContractModel) => each.model);\n if (inputs.errorType !== undefined) {\n models.push(inputs.errorType);\n }\n this.stackedJsDoc.refuse(\n models.flatMap((model: ApiDocModel) => model.stackedJsDoc),\n inputs.manifestPath,\n );\n this.summaries.refuse(inputs.contracts, inputs.manifestPath);\n this.toolNames.refuse(inputs.contracts, inputs.manifestPath);\n this.missingReturns.refuse(inputs.contracts, inputs.manifestPath);\n this.tagOwnership.refuseSharedOwners(inputs.contracts, inputs.manifestPath);\n this.hiddenFields.refuse(this.mergedTypes(inputs), inputs.manifestPath);\n // Collected across EVERY OpenAPI document of the run and refused once, after them all, so an\n // author is handed every undocumented schema at once rather than one document at a time.\n const undocumented = new UndocumentedSchemaGuard();\n const links = new DocLinkGuard();\n const documents: GeneratedDocument[] = [];\n for (const selection of DocumentSelection.all()) {\n const contracts = inputs.contracts.filter((each: ContractModel) =>\n selection.acceptsContract(each.model),\n );\n if (contracts.length === 0) {\n continue;\n }\n if (selection.inlinesEveryPackage) {\n documents.push(\n new GeneratedDocument(\n selection.fileName,\n this.bundled(inputs, contracts, selection, links, undocumented),\n ),\n );\n continue;\n }\n this.refuseCollisions(this.collisionsOf(inputs, contracts), inputs.manifestPath);\n const placement = new SplitPlacement(inputs.homePackage);\n const split = this.render(inputs, contracts, selection, placement);\n this.resolveLinks(links, split, inputs, contracts, selection, placement);\n this.refuseExternalReferences(split.schemas, inputs, selection);\n undocumented.collect(split.schemas.reachedTypes(), this.mergedTypes(inputs));\n // An inlined wrapper is still a published schema, so it still needs its description.\n undocumented.collect(split.schemas.inlinedTypes(), this.mergedTypes(inputs));\n documents.push(new GeneratedDocument(selection.fileName, split.document));\n documents.push(\n new GeneratedDocument(\n `${selection.fileName}${BUNDLED_SUFFIX}`,\n this.bundled(inputs, contracts, selection, links),\n ),\n );\n }\n undocumented.refuse(inputs.manifestPath);\n links.refuse(inputs.manifestPath);\n return new GeneratedDocuments(documents);\n }\n\n /**\n * A DTO library's COMPONENTS-ONLY document (#1058): `openapi`, `info`, `x-webpieces-id` and\n * `components.schemas` — every type the library exports and declares, with every OTHER package's\n * type a `$ref` into that package's own components document, so a chain of DTO libraries is a\n * chain of documents of any depth.\n *\n * `info.version` is the PACKAGE version. The package-qualified URI downstream documents reference\n * it by (`@scope/pkg/components.openapi.json`) is stated as `x-webpieces-id`, because OpenAPI 3.1's\n * root object admits no `$id` — a 3.1 validator rejects one — and the document must validate on its\n * own.\n */\n components(inputs: ComponentsInputs): GeneratedDocument {\n const model = inputs.model;\n const where = inputs.manifestPath;\n this.stackedJsDoc.refuse(model.stackedJsDoc, where);\n this.refuseCollisions(model.collisions, where);\n this.hiddenFields.refuse(model.types, where);\n // Every field, `@hidden` ones included: one components document serves every audience, and a\n // customer document that would have to withhold one of its fields refuses instead (#1246).\n const schemas = new SchemaRenderer(\n model.types,\n new SplitPlacement(model.packageName),\n InlinedWrappers.none(),\n false,\n );\n for (const key of model.exported) {\n schemas.define(key);\n }\n const rendered = schemas.components();\n this.refuseUnmapped(schemas.unmapped(), COMPONENTS_DOCUMENT, where);\n this.unpublished.refuse(\n schemas.externalTypes(),\n model.types,\n inputs.upstream,\n COMPONENTS_DOCUMENT,\n where,\n );\n const undocumented = new UndocumentedSchemaGuard();\n undocumented.collect(schemas.reachedTypes(), model.types);\n undocumented.refuse(where);\n const links = new DocLinkGuard();\n links.resolve(\n rendered,\n new DocumentLinkNaming(\n model.types,\n schemas,\n new SplitPlacement(model.packageName),\n new Map(),\n false,\n ),\n COMPONENTS_DOCUMENT,\n );\n links.refuse(where);\n if (rendered.isEmpty()) {\n throw new OpenApiGenerationError(\n `${model.packageName}'s entries export no type with a schema`,\n where,\n 'Name the entry files that export the library\\'s DTOs and enums — usually \"src/index.ts\".',\n );\n }\n return new GeneratedDocument(\n COMPONENTS_DOCUMENT,\n new JsonObject()\n .set('openapi', OPENAPI_VERSION)\n .set(\n 'info',\n new JsonObject()\n .set('title', inputs.manifest.title)\n .set('version', model.packageVersion),\n )\n .set('x-webpieces-id', ComponentsReference.documentUri(model.packageName))\n .set('components', new JsonObject().set('schemas', rendered)),\n );\n }\n\n /**\n * The SELF-CONTAINED form of a document: every reached schema defined locally, whichever package\n * declares it — the `*.bundled.json` sibling of a split document, and the MCP projection.\n *\n * Two passes, because a schema's NAME depends on which other schemas the document reaches: the\n * first renders with every type under its unique model key just to learn the reached set, and the\n * second renders with the names {@link BundledNames} assigns from it. Rendering is a pure walk of\n * the model, so the second pass reaches exactly what the first did.\n */\n private bundled(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n links: DocLinkGuard,\n undocumented?: UndocumentedSchemaGuard,\n ): JsonObject {\n // The discovery pass publishes nothing, so its links are not judged: the named pass below\n // reaches exactly the same prose.\n const discovery = this.render(inputs, contracts, selection, new DiscoveryPlacement());\n // The MCP projection inlines every type it reaches, from any package, so it is judged here\n // over that whole set (#1292). A split document's bundled sibling is not: each type in it is\n // judged by the document — or the components document — that defines it.\n undocumented?.collect(discovery.schemas.reachedTypes(), this.mergedTypes(inputs));\n const names = BundledNames.assign(\n discovery.schemas.reachedTypes(),\n this.mergedTypes(inputs),\n inputs.homePackage,\n );\n const placement = new BundledPlacement(names);\n const rendered = this.render(inputs, contracts, selection, placement);\n this.resolveLinks(links, rendered, inputs, contracts, selection, placement);\n return rendered.document;\n }\n\n /**\n * Publish every `{@link}` in a rendered document under its target's name in THAT document (#1284),\n * recording the ones it cannot name — see {@link DocLinkGuard}.\n */\n private resolveLinks(\n links: DocLinkGuard,\n rendered: RenderedDocument,\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n placement: SchemaPlacement,\n ): void {\n const naming = new DocumentLinkNaming(\n this.mergedTypes(inputs),\n rendered.schemas,\n placement,\n this.publishedOperationIds(contracts, selection, inputs),\n selection.dropHidden,\n );\n links.resolve(rendered.document, naming, selection.fileName);\n }\n\n /** ONE document, from the operations this selection accepts and nothing else. */\n private render(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n placement: SchemaPlacement,\n ): RenderedDocument {\n const types = this.mergedTypes(inputs);\n const schemas = new SchemaRenderer(\n types,\n placement,\n this.wrappers(inputs, selection, types),\n selection.dropHidden,\n );\n const operations = this.operationRenderer(inputs, selection, schemas);\n this.refuseDuplicateOperationIds(contracts, selection, operations, inputs.manifestPath);\n const apiKey = this.singleApiKey(inputs, contracts, selection);\n const schemeNames = inputs.manifest.securitySchemeNames;\n const hoisted =\n apiKey !== undefined && this.everyOperationIsCovered(contracts, selection)\n ? this.security.requirement(schemeNames)\n : undefined;\n\n const contract = new ResponseContract(\n this.errorResponses(inputs),\n this.errorSchemaRef(inputs, schemas),\n this.headerRefs(inputs),\n );\n\n const paths = new JsonObject();\n const webhooks = new JsonObject();\n const tags = new Set<string>();\n for (const contractModel of contracts) {\n this.renderContract(\n contractModel,\n selection,\n operations,\n contract,\n this.webhookContract(),\n hoisted === undefined ? this.security.requirement(schemeNames) : undefined,\n paths,\n webhooks,\n tags,\n );\n }\n\n // The schemas are built HERE, after the operations, because building them is what walks a\n // DTO's fields — and an unmapped field can only be found by that walk. A guard that ran\n // before it would see only the top-level request and response refs and miss every one.\n const renderedSchemas = schemas.components().orUndefined();\n this.refuseUnmapped(schemas.unmapped(), selection.fileName, inputs.manifestPath);\n\n const components = new JsonObject()\n .set('schemas', renderedSchemas)\n .set(\n 'securitySchemes',\n this.renderSecuritySchemes(inputs, contracts, selection, apiKey),\n )\n .set('headers', this.headers(inputs));\n\n const document = new JsonObject()\n .set('openapi', OPENAPI_VERSION)\n .set('info', this.info(inputs, selection, !paths.isEmpty()))\n .set('servers', this.servers(inputs))\n .set('tags', this.tagList(tags, contracts))\n .set('security', hoisted === undefined ? undefined : hoisted.slice())\n .set('paths', paths)\n .set('webhooks', webhooks.orUndefined())\n .set('components', components.orUndefined());\n return new RenderedDocument(document, schemas);\n }\n\n /** The operation renderer, carrying what this selection stamps on each operation. */\n private operationRenderer(\n inputs: GenerationInputs,\n selection: DocumentSelection,\n schemas: SchemaRenderer,\n ): OperationRenderer {\n return new OperationRenderer(\n schemas,\n selection.includeMcpExtensions,\n selection.internalNotice,\n selection.includeWebpiecesExtensions,\n inputs.manifest.operationIds,\n );\n }\n\n /**\n * The single-use request/response wrappers this document defines inline (#1303), counted over\n * EVERY contract of the manifest so a wrapper is inline or a component in every document alike.\n */\n private wrappers(\n inputs: GenerationInputs,\n selection: DocumentSelection,\n types: ReadonlyMap<string, DocumentedType>,\n ): InlinedWrappers {\n if (!selection.inlinesWrappers) {\n return InlinedWrappers.none();\n }\n const errorKey = inputs.errorType === undefined ? undefined : inputs.manifest.errors?.type;\n return InlinedWrappers.of(inputs.contracts, types, inputs.homePackage, errorKey);\n }\n\n private renderSecuritySchemes(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n apiKey: DocumentedApiKey | undefined,\n ): JsonObject | undefined {\n const schemes =\n apiKey === undefined\n ? new JsonObject()\n : this.security.schemes(\n apiKey,\n inputs.manifest.securitySchemeNames,\n inputs.manifestPath,\n );\n return this.security\n .addBuiltinSchemes(schemes, this.selectedEndpoints(contracts, selection))\n .orUndefined();\n }\n\n /** Same-named, different declarations in one package, across every contract a document reads. */\n private collisionsOf(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n ): readonly TypeNameCollision[] {\n const models = contracts.map((each: ContractModel) => each.model);\n const all = inputs.errorType === undefined ? models : models.concat([inputs.errorType]);\n return all.flatMap((model: ApiDocModel) => Array.from(model.collisions));\n }\n\n /**\n * Two DIFFERENT declarations of one name in one package. A document defines each of its\n * package's schemas under its bare name, so one of the two would be published as the other's\n * shape. (Two packages' same-named types are not this: each is defined in its own package's\n * document — #1058's `LocalizedDescriptionsDto` case.)\n */\n private refuseCollisions(collisions: readonly TypeNameCollision[], where: string): void {\n if (collisions.length === 0) {\n return;\n }\n throw new OpenApiGenerationError(\n `${collisions.length} name(s) are declared twice in one package, so one document would ` +\n 'publish two different types under one name',\n where,\n 'Rename one declaration of each. Within one package a schema name is one type.',\n collisions.map(\n (each: TypeNameCollision) =>\n `${each.name} (${each.packageName ?? 'no package'}): ${each.firstLocation} and ${each.secondLocation}`,\n ),\n );\n }\n\n /**\n * OpenAPI requires every operationId to be unique among ALL operations of a document, webhooks\n * included. `\"operationIds\": \"method\"` publishes the bare method name, so two contracts with a\n * same-named method would publish one id twice — and a generated client would silently get one\n * method for two operations. Refused here, naming both, before anything renders (#1270). The ids\n * come from the renderer's own {@link OperationRenderer.operationIdOf}, so the check and the\n * published value cannot disagree.\n */\n private refuseDuplicateOperationIds(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n operations: OperationRenderer,\n where: string,\n ): void {\n const firstOwner = new Map<string, string>();\n const duplicates: string[] = [];\n for (const contractModel of contracts) {\n const model = contractModel.model;\n for (const endpoint of model.endpoints) {\n if (!selection.acceptsEndpoint(endpoint)) {\n continue;\n }\n const id = operations.operationIdOf(endpoint, model.contractName);\n const owner = `${model.contractName}.${endpoint.methodName} (${contractModel.file})`;\n const first = firstOwner.get(id);\n if (first === undefined) {\n firstOwner.set(id, owner);\n } else {\n duplicates.push(`operationId '${id}': ${first} and ${owner}`);\n }\n }\n }\n if (duplicates.length === 0) {\n return;\n }\n throw new OpenApiGenerationError(\n `${duplicates.length} operationId(s) would be published twice in ${selection.fileName}; ` +\n 'an operationId must be unique across every operation of one document',\n where,\n 'Rename one of each pair of methods, or set \"operationIds\": \"contract_method\" in the ' +\n 'manifest, which prefixes every id with its contract name (this renames every method ' +\n \"in partners' generated clients).\",\n duplicates,\n );\n }\n\n /** `Contract.method` -> operationId, for every operation this document publishes. */\n private publishedOperationIds(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n inputs: GenerationInputs,\n ): ReadonlyMap<string, string> {\n const operationIds = new OperationIds(inputs.manifest.operationIds);\n const ids = new Map<string, string>();\n for (const contractModel of contracts) {\n const model = contractModel.model;\n for (const endpoint of model.endpoints) {\n if (selection.acceptsEndpoint(endpoint)) {\n ids.set(\n `${model.contractName}.${endpoint.methodName}`,\n operationIds.of(model.contractName, endpoint.methodName),\n );\n }\n }\n }\n return ids;\n }\n\n /**\n * A split document's references into other packages' components documents: each must be\n * published there (#1058), and — in the customer document — none may carry a `@hidden` field,\n * which a shared components document cannot withhold (#1246).\n */\n private refuseExternalReferences(\n schemas: SchemaRenderer,\n inputs: GenerationInputs,\n selection: DocumentSelection,\n ): void {\n const external = schemas.externalTypes();\n const types = this.mergedTypes(inputs);\n const where = inputs.manifestPath;\n this.unpublished.refuse(external, types, inputs.upstream, selection.fileName, where);\n if (selection.dropHidden) {\n this.hiddenFields.refuseExternal(external, types, selection.fileName, where);\n }\n }\n\n /**\n * A webhook is served by the PARTNER, so neither our failure envelope nor the header we stamp on\n * our own responses is true of it. Publishing either would document their server, not ours.\n */\n private webhookContract(): ResponseContract {\n return new ResponseContract([], undefined, undefined);\n }\n\n /** One contract's ACCEPTED endpoints, into `paths` or into `webhooks`. */\n private renderContract(\n contractModel: ContractModel,\n selection: DocumentSelection,\n operations: OperationRenderer,\n contract: ResponseContract,\n webhookContract: ResponseContract,\n perOperationSecurity: readonly JsonValue[] | undefined,\n paths: JsonObject,\n webhooks: JsonObject,\n tags: Set<string>,\n ): void {\n const model = contractModel.model;\n const tag = contractModel.entry.tag;\n for (const endpoint of model.endpoints) {\n if (!selection.acceptsEndpoint(endpoint)) {\n continue;\n }\n // A tag is added only by an operation that survived, so a document never advertises a\n // section of its sidebar that turns out to be empty.\n tags.add(tag);\n if (contractModel.entry.isWebhook()) {\n webhooks.set(\n this.eventName(endpoint),\n new JsonObject().set(\n 'post',\n operations.webhook(endpoint, model.contractName, tag, webhookContract),\n ),\n );\n continue;\n }\n const url = `${model.basePath}${endpoint.path}`;\n const existing = paths.get(url);\n const item = existing instanceof JsonObject ? existing : new JsonObject();\n item.set(\n endpoint.httpMethod.toLowerCase(),\n operations.operation(\n endpoint,\n model.contractName,\n tag,\n contract,\n this.security.operation(endpoint.auth, perOperationSecurity),\n ),\n );\n paths.set(url, item);\n }\n }\n\n /**\n * A webhook is keyed by the EVENT NAME, with the `@ApiPath` base deliberately NOT prepended.\n *\n * There is no url of ours here — the partner hosts the endpoint, at whatever path they choose —\n * so publishing `/our-base/delivered` would document a route that exists nowhere. What we are\n * naming is the event we will send.\n */\n private eventName(endpoint: DocumentedEndpoint): string {\n return endpoint.path.replace(/^\\/+/, '');\n }\n\n /**\n * Every named type from every contract, merged by MODEL KEY — which carries the declaring\n * package, so two packages' same-named types never meet here (#1058).\n *\n * Two contracts declaring DIFFERENT types under one key is a hard failure, not a first-wins\n * merge: `components.schemas` is keyed by name, so one of the two would be published as the\n * other's shape, and the operation referring to it would be quietly wrong.\n */\n private mergedTypes(inputs: GenerationInputs): ReadonlyMap<string, DocumentedType> {\n const merged = new Map<string, DocumentedType>();\n const published = new Map<string, DocumentedType>();\n const sources = inputs.contracts.map((each: ContractModel) => each.model);\n const all = inputs.errorType === undefined ? sources : sources.concat([inputs.errorType]);\n for (const model of all) {\n for (const name of Array.from(model.types.keys())) {\n const incoming = model.types.get(name)!;\n const previous = published.get(incoming.schemaName);\n if (\n previous !== undefined &&\n previous.location !== incoming.location &&\n (previous.name !== previous.schemaName || incoming.name !== incoming.schemaName)\n ) {\n throw new OpenApiGenerationError(\n `stripped schema name '${incoming.schemaName}' collides: '${previous.name}' at ${previous.location} and '${incoming.name}' at ${incoming.location}`,\n inputs.manifestPath,\n 'Change schemaNames so every reached declaration has a distinct published name.',\n );\n }\n published.set(incoming.schemaName, incoming);\n const existing = merged.get(name);\n if (\n existing !== undefined &&\n this.signature(existing) !== this.signature(incoming)\n ) {\n throw new OpenApiGenerationError(\n `two different types are both named '${incoming.name}'`,\n `${model.contractName} (${inputs.manifestPath})`,\n 'Rename one of them. `components.schemas` is keyed by name, so one shape ' +\n 'would be published as the other.',\n );\n }\n merged.set(name, incoming);\n }\n }\n return merged;\n }\n\n /** Enough of a type's shape to tell two same-named types apart without comparing prose. */\n private signature(type: DocumentedType): string {\n const fields = type.fields.map((field: DocumentedField) => field.name).join(',');\n return `${fields}|${type.enumValues.join(',')}|${type.unionRefNames.join(',')}`;\n }\n\n /**\n * The ONE api-key regime this document publishes.\n *\n * Two regimes in one document is a hard failure: `securitySchemeNames` is a single ordered list,\n * so there is no honest way to say which regime a given name belongs to, and a document that\n * guessed would publish one regime's header names under the other's scheme keys.\n */\n private singleApiKey(\n inputs: GenerationInputs,\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): DocumentedApiKey | undefined {\n let found: DocumentedApiKey | undefined;\n for (const endpoint of this.selectedEndpoints(contracts, selection)) {\n const apiKey = endpoint.auth?.methods.find(\n (method: DocumentedAuthMethod) => method.apiKey !== undefined,\n )?.apiKey;\n if (apiKey === undefined) {\n continue;\n }\n if (found !== undefined && found.regime !== apiKey.regime) {\n throw new OpenApiGenerationError(\n `the ${selection.fileName} document mixes the api-key regimes ` +\n `'${found.regime}' ` +\n `and '${apiKey.regime}'`,\n inputs.manifestPath,\n 'Publish one regime per document — split the manifest, or move the ' +\n \"other regime's contract out of `apis`.\",\n );\n }\n found = apiKey;\n }\n return found;\n }\n\n /**\n * True when EVERY selected operation demands the credential, which is what licenses hoisting the\n * requirement to the document. A document that mixes credentialled and uncredentialled routes\n * stamps it per-operation instead — hoisting there would tell a partner that a public endpoint\n * needs a key.\n *\n * Judged per DOCUMENT, over the operations that document actually contains, because that is the\n * only question the document's own `security` block answers.\n */\n private everyOperationIsCovered(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): boolean {\n const served = this.selectedEndpoints(contracts, selection);\n return (\n served.length > 0 &&\n served.every(\n (e: DocumentedEndpoint) =>\n e.auth?.methods.length === 1 && e.auth.methods[0].apiKey !== undefined,\n )\n );\n }\n\n /**\n * The endpoints this selection accepts that are routes on OUR server. A webhook is somebody\n * else's route, so it never counts toward our security requirement or our regime.\n */\n private selectedEndpoints(\n contracts: readonly ContractModel[],\n selection: DocumentSelection,\n ): readonly DocumentedEndpoint[] {\n const served: DocumentedEndpoint[] = [];\n for (const contract of contracts) {\n if (contract.entry.isWebhook()) {\n continue;\n }\n for (const endpoint of contract.model.endpoints) {\n if (selection.acceptsEndpoint(endpoint)) {\n served.push(endpoint);\n }\n }\n }\n return served;\n }\n\n /** `info`, whose `description` is the ONE piece of prose that differs between the documents. */\n private info(\n inputs: GenerationInputs,\n selection: DocumentSelection,\n hasRoutes: boolean,\n ): JsonObject {\n return new JsonObject()\n .set('title', inputs.manifest.title)\n .set('summary', inputs.manifest.summary)\n .set('version', inputs.manifest.version)\n .set('description', selection.description(inputs.description, hasRoutes));\n }\n\n private servers(inputs: GenerationInputs): readonly JsonValue[] | undefined {\n if (inputs.manifest.servers.length === 0) {\n return undefined;\n }\n return inputs.manifest.servers.map((server: ServerEntry) =>\n new JsonObject().set('url', server.url).set('description', server.description),\n );\n }\n\n /**\n * `tags[]` in MANIFEST ORDER, because that order IS the published sidebar — one of the two\n * orders in this document that carries meaning and is therefore NOT sorted. Each description is\n * the owning contract's JSDoc — see {@link TagOwnership} (#1292).\n */\n private tagList(\n tags: ReadonlySet<string>,\n contracts: readonly ContractModel[],\n ): readonly JsonValue[] | undefined {\n const list: JsonValue[] = [];\n for (const name of Array.from(tags)) {\n list.push(\n new JsonObject()\n .set('name', name)\n .set('description', this.tagOwnership.descriptionOf(name, contracts)),\n );\n }\n return list.length === 0 ? undefined : list;\n }\n\n private errorResponses(inputs: GenerationInputs): readonly ErrorResponseEntry[] {\n return inputs.manifest.errors?.responses ?? [];\n }\n\n private errorSchemaRef(\n inputs: GenerationInputs,\n schemas: SchemaRenderer,\n ): JsonObject | undefined {\n const errors = inputs.manifest.errors;\n if (errors === undefined || inputs.errorType === undefined) {\n return undefined;\n }\n // Rendering the reference is what puts the error body into `components.schemas`, so the\n // published shape is the compiler's answer about that TS type and not a hand-copied one.\n // The model key of a type its own file declares is its bare name (`DocumentedType.keyOf`).\n return schemas.type(TypeRef.ref(errors.type), '#/components/schemas/error');\n }\n\n /** `components.headers`, one entry per declared response header. */\n private headers(inputs: GenerationInputs): JsonObject | undefined {\n const headers = new JsonObject();\n for (const header of inputs.responseHeaders) {\n headers.set(\n header.headerName,\n new JsonObject()\n .set('description', header.description)\n .set('required', header.required)\n .set('schema', new JsonObject().set('type', 'string')),\n );\n }\n return headers.orUndefined();\n }\n\n /** The `$ref`s every SUCCESS response carries at those headers. */\n private headerRefs(inputs: GenerationInputs): JsonObject | undefined {\n const refs = new JsonObject();\n for (const header of inputs.responseHeaders) {\n refs.set(\n header.headerName,\n new JsonObject().set('$ref', `#/components/headers/${header.headerName}`),\n );\n }\n return refs.orUndefined();\n }\n\n /**\n * The guard. An unmapped field is a published partner-facing field with no shape, and there is\n * deliberately no flag to switch this off — the cure is at the contract, by naming the type.\n */\n private refuseUnmapped(\n unmapped: readonly UnmappedField[],\n fileName: string,\n manifestPath: string,\n ): void {\n if (unmapped.length === 0) {\n return;\n }\n const pointers = unmapped.map(\n (field: UnmappedField) => `${field.pointer} (${field.typeText})`,\n );\n throw new OpenApiGenerationError(\n `${unmapped.length} field(s) in ${fileName} have no schema it can state`,\n manifestPath,\n 'Give each one a type a document can carry — a named DTO, an array of one, a ' +\n 'string-literal union, or Record<string, X>. An untyped field publishes as \"anything\".',\n pointers,\n );\n }\n}\n"]}
|
|
@@ -49,6 +49,12 @@ export declare class UnmappedField {
|
|
|
49
49
|
* description, and `properties` even when empty — instead of as a `$ref`; it is never added to
|
|
50
50
|
* `components.schemas`. It is recorded in {@link inlinedTypes} so the description guard still judges
|
|
51
51
|
* it: inlining is never a way around a missing JSDoc.
|
|
52
|
+
*
|
|
53
|
+
* ## A `@hidden` field is never rendered into the customer document (#1246)
|
|
54
|
+
*
|
|
55
|
+
* With `dropsHiddenFields`, an object schema simply skips the field — its property, its prose, its
|
|
56
|
+
* `required` entry — wherever that schema is written: a component, an inlined wrapper, a webhook
|
|
57
|
+
* payload, a nested `$ref` target. Nothing is built and then removed.
|
|
52
58
|
*/
|
|
53
59
|
export declare class SchemaRenderer {
|
|
54
60
|
/** The model's named types, by key (`DocumentedType.keyOf`). */
|
|
@@ -56,6 +62,12 @@ export declare class SchemaRenderer {
|
|
|
56
62
|
private readonly placement;
|
|
57
63
|
/** The wrappers an operation defines inline rather than by `$ref` (#1303). */
|
|
58
64
|
private readonly wrappers;
|
|
65
|
+
/**
|
|
66
|
+
* Omit every `@hidden` field (#1246) — the customer document alone. The field is never
|
|
67
|
+
* rendered, so a type reached ONLY through it is never reached either: select-then-render,
|
|
68
|
+
* exactly as for a hidden method (see `DocumentSelection`).
|
|
69
|
+
*/
|
|
70
|
+
private readonly dropsHiddenFields;
|
|
59
71
|
private readonly reached;
|
|
60
72
|
private readonly inlined;
|
|
61
73
|
private readonly external;
|
|
@@ -64,7 +76,13 @@ export declare class SchemaRenderer {
|
|
|
64
76
|
/** The model's named types, by key (`DocumentedType.keyOf`). */
|
|
65
77
|
types: ReadonlyMap<string, DocumentedType>, placement: SchemaPlacement,
|
|
66
78
|
/** The wrappers an operation defines inline rather than by `$ref` (#1303). */
|
|
67
|
-
wrappers: InlinedWrappers
|
|
79
|
+
wrappers: InlinedWrappers,
|
|
80
|
+
/**
|
|
81
|
+
* Omit every `@hidden` field (#1246) — the customer document alone. The field is never
|
|
82
|
+
* rendered, so a type reached ONLY through it is never reached either: select-then-render,
|
|
83
|
+
* exactly as for a hidden method (see `DocumentSelection`).
|
|
84
|
+
*/
|
|
85
|
+
dropsHiddenFields: boolean);
|
|
68
86
|
/** Keys of the named types this document DEFINES, reached directly or through another schema. */
|
|
69
87
|
reachedTypes(): ReadonlySet<string>;
|
|
70
88
|
/** Keys of the wrappers this document defined INLINE at their one operation (#1303). */
|
|
@@ -51,11 +51,18 @@ exports.UnmappedField = UnmappedField;
|
|
|
51
51
|
* description, and `properties` even when empty — instead of as a `$ref`; it is never added to
|
|
52
52
|
* `components.schemas`. It is recorded in {@link inlinedTypes} so the description guard still judges
|
|
53
53
|
* it: inlining is never a way around a missing JSDoc.
|
|
54
|
+
*
|
|
55
|
+
* ## A `@hidden` field is never rendered into the customer document (#1246)
|
|
56
|
+
*
|
|
57
|
+
* With `dropsHiddenFields`, an object schema simply skips the field — its property, its prose, its
|
|
58
|
+
* `required` entry — wherever that schema is written: a component, an inlined wrapper, a webhook
|
|
59
|
+
* payload, a nested `$ref` target. Nothing is built and then removed.
|
|
54
60
|
*/
|
|
55
61
|
class SchemaRenderer {
|
|
56
62
|
types;
|
|
57
63
|
placement;
|
|
58
64
|
wrappers;
|
|
65
|
+
dropsHiddenFields;
|
|
59
66
|
reached = new Set();
|
|
60
67
|
inlined = new Set();
|
|
61
68
|
external = new Set();
|
|
@@ -64,10 +71,17 @@ class SchemaRenderer {
|
|
|
64
71
|
/** The model's named types, by key (`DocumentedType.keyOf`). */
|
|
65
72
|
types, placement,
|
|
66
73
|
/** The wrappers an operation defines inline rather than by `$ref` (#1303). */
|
|
67
|
-
wrappers
|
|
74
|
+
wrappers,
|
|
75
|
+
/**
|
|
76
|
+
* Omit every `@hidden` field (#1246) — the customer document alone. The field is never
|
|
77
|
+
* rendered, so a type reached ONLY through it is never reached either: select-then-render,
|
|
78
|
+
* exactly as for a hidden method (see `DocumentSelection`).
|
|
79
|
+
*/
|
|
80
|
+
dropsHiddenFields) {
|
|
68
81
|
this.types = types;
|
|
69
82
|
this.placement = placement;
|
|
70
83
|
this.wrappers = wrappers;
|
|
84
|
+
this.dropsHiddenFields = dropsHiddenFields;
|
|
71
85
|
}
|
|
72
86
|
/** Keys of the named types this document DEFINES, reached directly or through another schema. */
|
|
73
87
|
reachedTypes() {
|
|
@@ -167,6 +181,9 @@ class SchemaRenderer {
|
|
|
167
181
|
const properties = new JsonObject_1.JsonObject();
|
|
168
182
|
const required = [];
|
|
169
183
|
for (const field of type.fields) {
|
|
184
|
+
if (this.dropsHiddenFields && field.hidden) {
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
170
187
|
properties.set(field.name, this.field(field, `${pointer}/properties/${field.name}`));
|
|
171
188
|
if (!field.optional) {
|
|
172
189
|
required.push(field.name);
|