@webpieces/openapi-generator 0.4.929 → 0.4.930

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -55,7 +55,6 @@ It carries exactly what is **not a property of the code**:
55
55
  ```json
56
56
  {
57
57
  "title": "Example Orders API",
58
- "operationIds": "method",
59
58
  "version": "1.0.0",
60
59
  "descriptionFile": "description.md",
61
60
  "servers": [{ "url": "https://api.example.com", "description": "Production." }],
@@ -151,17 +150,19 @@ carries nothing there, because it is not there). The server stamps the header on
151
150
  for a correlation id the failing response is the one a partner most needs to quote back. A webhook
152
151
  takes none of them: it is served by the partner, not by us.
153
152
 
154
- **`operationIds` is REQUIRED — there is no default (#1270).** `operationId` is what openapi-generator,
155
- Kiota, NSwag and the rest name the METHOD in every client a partner generates, so changing its spelling
156
- renames every method in every partner's SDK. The manifest states it:
153
+ **`operationIds` is optional and defaults to `"contract_method"` (#1270, #1283).** `operationId` is
154
+ what openapi-generator, Kiota, NSwag and the rest name the METHOD in every client a partner generates,
155
+ so changing its spelling renames every method in every partner's SDK:
157
156
 
158
157
  | value | publishes | uniqueness |
159
158
  |---|---|---|
160
- | `"contract_method"` | `OrdersApi_fetchOrders` | by construction |
159
+ | `"contract_method"` (the default) | `OrdersApi_fetchOrders` | by construction |
161
160
  | `"method"` | `fetchOrders` | checked: two operations of one document (routes and webhooks alike) sharing an id is a HARD FAILURE naming both |
162
161
 
163
- A manifest without it, or with any other value, is refused with an error naming the key and both
164
- choices. Pick `"contract_method"` to keep the ids every earlier release published.
162
+ Omit the key for a new API: `"contract_method"` is the spelling every release before #1270 published,
163
+ and it keeps working as contracts grow (two contracts that each have a `fetch` never collide).
164
+ `"method"` is the opt-in for a document that has already published bare names and must keep them.
165
+ Any other value is refused with an error naming the key and both choices.
165
166
 
166
167
  **`responseHeaders[].required`** is rendered verbatim on the header object; omitted, the document
167
168
  does not state it (OpenAPI reads that as `false`).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webpieces/openapi-generator",
3
- "version": "0.4.929",
3
+ "version": "0.4.930",
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.929",
27
- "@webpieces/core-util": "0.4.929",
26
+ "@webpieces/api-doc-model": "0.4.930",
27
+ "@webpieces/core-util": "0.4.930",
28
28
  "typescript": "5.9.3"
29
29
  },
30
30
  "bin": {
@@ -20,8 +20,10 @@ export declare class ManifestLoader {
20
20
  /** @param manifestPath absolute path to a CONTRACT library's `openapi.manifest.json`. */
21
21
  load(manifestPath: string): OpenApiManifest;
22
22
  /**
23
- * REQUIRED, with no default (#1270): the operationId is the method name in every client a
24
- * partner generates, so its spelling is the consumer's decision, stated in the manifest.
23
+ * OPTIONAL, defaulting to `"contract_method"` (#1283) — the spelling every release before #1270
24
+ * published, and the one that is unique by construction, so a new contract gets the safe scheme
25
+ * without writing anything. `"method"` is the opt-in for a document that already published bare
26
+ * names. A value that is present but is neither choice is still refused.
25
27
  */
26
28
  private operationIds;
27
29
  private servers;
@@ -90,10 +90,15 @@ class ManifestLoader {
90
90
  return new OpenApiManifest_1.OpenApiManifest(raw.string('title'), raw.string('version'), this.servers(raw), raw.optionalString('descriptionFile'), this.apis(raw), raw.strings('securitySchemeNames'), this.errors(raw), this.responseHeaders(raw), this.schemaNames(raw), this.operationIds(raw));
91
91
  }
92
92
  /**
93
- * REQUIRED, with no default (#1270): the operationId is the method name in every client a
94
- * partner generates, so its spelling is the consumer's decision, stated in the manifest.
93
+ * OPTIONAL, defaulting to `"contract_method"` (#1283) — the spelling every release before #1270
94
+ * published, and the one that is unique by construction, so a new contract gets the safe scheme
95
+ * without writing anything. `"method"` is the opt-in for a document that already published bare
96
+ * names. A value that is present but is neither choice is still refused.
95
97
  */
96
98
  operationIds(raw) {
99
+ if (!raw.has('operationIds')) {
100
+ return OpenApiManifest_1.OperationIdStyle.CONTRACT_METHOD;
101
+ }
97
102
  const value = raw.optionalString('operationIds');
98
103
  const style = OPERATION_ID_STYLES.find((each) => each === value);
99
104
  if (style !== undefined) {
@@ -101,11 +106,12 @@ class ManifestLoader {
101
106
  }
102
107
  const choices = OPERATION_ID_STYLES.map((each) => `"${each}"`).join(' or ');
103
108
  throw new OpenApiGenerationError_1.OpenApiGenerationError(value === undefined
104
- ? "'operationIds' is missing or is not a string"
105
- : `unknown operationIds style '${value}'`, raw.where, `Add "operationIds": ${choices}. "${OpenApiManifest_1.OperationIdStyle.CONTRACT_METHOD}" publishes ` +
106
- `OrdersApi_fetchOrders; "${OpenApiManifest_1.OperationIdStyle.METHOD}" publishes fetchOrders and fails ` +
107
- 'generation when two operations of one document would share it. Generated partner ' +
108
- 'clients name their methods from it, so changing it renames every method in their SDKs.');
109
+ ? "'operationIds' is present but is not a non-empty string"
110
+ : `unknown operationIds style '${value}'`, raw.where, `Set "operationIds" to ${choices}, or omit it for "${OpenApiManifest_1.OperationIdStyle.CONTRACT_METHOD}". ` +
111
+ `"${OpenApiManifest_1.OperationIdStyle.CONTRACT_METHOD}" publishes OrdersApi_fetchOrders; ` +
112
+ `"${OpenApiManifest_1.OperationIdStyle.METHOD}" publishes fetchOrders and fails generation when two ` +
113
+ 'operations of one document would share it. Generated partner clients name their ' +
114
+ 'methods from it, so changing it renames every method in their SDKs.');
109
115
  }
110
116
  servers(raw) {
111
117
  return raw
@@ -1 +1 @@
1
- {"version":3,"file":"ManifestLoader.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/manifest/ManifestLoader.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,wDAAkC;AAClC,sEAAmE;AACnE,6CAA0C;AAC1C,4DAA2D;AAC3D,uDAS2B;AAE3B,gGAAgG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AEO,eAAe,CAAC,GAAe;QACnC,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,MAAkB,EAAE,EAAE;YAC7D,0FAA0F;YAC1F,0FAA0F;YAC1F,8DAA8D;YAC9D,IAAI,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAAE,CAAC;gBACpC,MAAM,IAAI,+CAAsB,CAC5B,IAAI,qBAAqB,gEAAgE,EACzF,GAAG,CAAC,KAAK,EACT,YAAY,qBAAqB,uDAAuD;oBACpF,kFAAkF;oBAClF,8FAA8F,CACrG,CAAC;YACN,CAAC;YACD,OAAO,IAAI,qCAAmB,CAC1B,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EACtB,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAC3B,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,EACpC,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CACrC,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;IAED,+EAA+E;IAC/E,OAAO,CAAC,YAAoB,EAAE,QAAgB;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACJ;AArND,wCAqNC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\nimport { JsonReader } from './JsonReader';\nimport { SchemaNameEntry } from '@webpieces/api-doc-model';\nimport {\n ApiEntry,\n ComponentsManifest,\n ErrorResponseEntry,\n ErrorsEntry,\n OpenApiManifest,\n OperationIdStyle,\n ResponseHeaderEntry,\n ServerEntry,\n} from './OpenApiManifest';\n\n/** The only `kind` an api entry may declare. Anything else is a typo, and typos are refused. */\nconst WEBHOOK = 'webhook';\n\n/**\n * The only `kind` a MANIFEST may declare (#1058): a DTO library's components-only document. A\n * manifest with no `kind` is a contract library's, exactly as before.\n */\nconst COMPONENTS = 'components';\n\n/** The deleted string-constant spelling of a response header's name (#1249). */\nconst RETIRED_NAME_CONSTANT = 'nameConstant';\n\n/** Keys a components manifest must not carry, each with why — a contract-manifest key is a mix-up. */\nconst NOT_IN_COMPONENTS: ReadonlyMap<string, string> = new Map<string, string>([\n ['apis', 'a components document has no paths; list the library\\'s entry files in \"entries\"'],\n [\n 'version',\n \"a library document's info.version is the package version, read from its package.json\",\n ],\n ['servers', 'a components document has no operations to serve'],\n ['errors', 'the error contract belongs to a contract document'],\n ['responseHeaders', 'response headers belong to a contract document'],\n ['securitySchemeNames', 'security belongs to a contract document'],\n ['operationIds', 'a components document has no operations to name'],\n]);\n\n/** Every spelling `operationIds` accepts, in the order the refusal lists them. */\nconst OPERATION_ID_STYLES: readonly OperationIdStyle[] = [\n OperationIdStyle.CONTRACT_METHOD,\n OperationIdStyle.METHOD,\n];\n\n/**\n * Read `openapi.manifest.json` into {@link OpenApiManifest}.\n *\n * It deals only in {@link JsonReader}, which is where the \"came off disk, not yet checked\" state is\n * concentrated — so nothing in this file, or anywhere downstream, handles an unnarrowed value.\n *\n * Every rejection is a HARD FAILURE naming the field. A published document quietly missing a section\n * is indistinguishable, from outside, from an API that genuinely has no error contract.\n */\nexport class ManifestLoader {\n /**\n * True for a DTO library's `\"kind\": \"components\"` manifest, false for a contract library's (no\n * `kind`). Any other `kind` is refused: a typo there would otherwise render the wrong document.\n */\n isComponents(manifestPath: string): boolean {\n const kind = this.read(manifestPath).optionalString('kind');\n if (kind === undefined) {\n return false;\n }\n if (kind !== COMPONENTS) {\n throw new OpenApiGenerationError(\n `unknown manifest kind '${kind}'`,\n manifestPath,\n `The only manifest kind is \"${COMPONENTS}\", for a DTO library's components document. ` +\n \"Leave it out for a contract library's manifest.\",\n );\n }\n return true;\n }\n\n /** A DTO library's components manifest. See {@link ComponentsManifest}. */\n loadComponents(manifestPath: string): ComponentsManifest {\n const raw = this.read(manifestPath);\n for (const key of NOT_IN_COMPONENTS.keys()) {\n const why = NOT_IN_COMPONENTS.get(key)!;\n if (raw.has(key)) {\n throw new OpenApiGenerationError(\n `a \"kind\": \"${COMPONENTS}\" manifest declares '${key}'`,\n raw.where,\n `Delete it — ${why}.`,\n );\n }\n }\n const entries = raw.strings('entries');\n if (entries.length === 0) {\n throw new OpenApiGenerationError(\n \"'entries' is empty\",\n raw.where,\n 'Name the library\\'s entry files, e.g. \"entries\": [\"src/index.ts\"]; the document holds every type they export.',\n );\n }\n return new ComponentsManifest(raw.string('title'), entries, this.schemaNames(raw));\n }\n\n private read(manifestPath: string): JsonReader {\n if (!fs.existsSync(manifestPath)) {\n throw new OpenApiGenerationError(\n 'no manifest at this path',\n manifestPath,\n 'Pass --manifest pointing at an openapi.manifest.json that exists.',\n );\n }\n return JsonReader.parseFile(fs.readFileSync(manifestPath, 'utf8'), manifestPath);\n }\n\n /** @param manifestPath absolute path to a CONTRACT library's `openapi.manifest.json`. */\n load(manifestPath: string): OpenApiManifest {\n if (this.isComponents(manifestPath)) {\n throw new OpenApiGenerationError(\n `this is a \"kind\": \"${COMPONENTS}\" manifest, not a contract manifest`,\n manifestPath,\n 'Render it as a components document (wp-openapi does so on its own when it reads the kind).',\n );\n }\n const raw = this.read(manifestPath);\n return new OpenApiManifest(\n raw.string('title'),\n raw.string('version'),\n this.servers(raw),\n raw.optionalString('descriptionFile'),\n this.apis(raw),\n raw.strings('securitySchemeNames'),\n this.errors(raw),\n this.responseHeaders(raw),\n this.schemaNames(raw),\n this.operationIds(raw),\n );\n }\n\n /**\n * REQUIRED, with no default (#1270): the operationId is the method name in every client a\n * partner generates, so its spelling is the consumer's decision, stated in the manifest.\n */\n private operationIds(raw: JsonReader): OperationIdStyle {\n const value = raw.optionalString('operationIds');\n const style = OPERATION_ID_STYLES.find((each: OperationIdStyle) => each === value);\n if (style !== undefined) {\n return style;\n }\n const choices = OPERATION_ID_STYLES.map((each: OperationIdStyle) => `\"${each}\"`).join(' or ');\n throw new OpenApiGenerationError(\n value === undefined\n ? \"'operationIds' is missing or is not a string\"\n : `unknown operationIds style '${value}'`,\n raw.where,\n `Add \"operationIds\": ${choices}. \"${OperationIdStyle.CONTRACT_METHOD}\" publishes ` +\n `OrdersApi_fetchOrders; \"${OperationIdStyle.METHOD}\" publishes fetchOrders and fails ` +\n 'generation when two operations of one document would share it. Generated partner ' +\n 'clients name their methods from it, so changing it renames every method in their SDKs.',\n );\n }\n\n private servers(raw: JsonReader): readonly ServerEntry[] {\n return raw\n .objects('servers')\n .map(\n (server: JsonReader) =>\n new ServerEntry(server.string('url'), server.optionalString('description')),\n );\n }\n\n private schemaNames(raw: JsonReader): readonly SchemaNameEntry[] {\n return raw.objects('schemaNames').map((entry: JsonReader) => {\n const paths = entry.strings('paths');\n const suffixes = entry.strings('stripSuffixes');\n if (\n paths.length === 0 ||\n paths.some((glob: string) => glob.trim() === '') ||\n !entry.has('stripSuffixes') ||\n suffixes.some((suffix: string) => suffix.length === 0)\n ) {\n throw new OpenApiGenerationError(\n 'invalid schemaNames entry',\n raw.where,\n 'Provide non-empty paths and an explicit stripSuffixes array of non-empty suffixes (or [] to preserve names). First matching path wins.',\n );\n }\n return new SchemaNameEntry(\n paths.map((glob: string) => path.resolve(path.dirname(raw.where), glob)),\n suffixes,\n );\n });\n }\n\n private apis(raw: JsonReader): readonly ApiEntry[] {\n const entries = raw\n .objects('apis')\n .map(\n (api: JsonReader) =>\n new ApiEntry(\n api.string('entry'),\n api.string('tag'),\n api.optionalString('kind'),\n ),\n );\n if (entries.length === 0) {\n throw new OpenApiGenerationError(\n \"'apis' is empty\",\n raw.where,\n 'List at least one contract; a document with no operations publishes nothing.',\n );\n }\n for (const entry of entries) {\n if (entry.kind !== undefined && entry.kind !== WEBHOOK) {\n throw new OpenApiGenerationError(\n `unknown api kind '${entry.kind}' on '${entry.entry}'`,\n raw.where,\n `The only declared kind is \"${WEBHOOK}\". Leave it out for an ordinary contract.`,\n );\n }\n }\n return entries;\n }\n\n private errors(raw: JsonReader): ErrorsEntry | undefined {\n const errors = raw.object('errors');\n if (errors === undefined) {\n return undefined;\n }\n return new ErrorsEntry(\n errors.string('entry'),\n errors.string('type'),\n errors\n .objects('responses')\n .map(\n (response: JsonReader) =>\n new ErrorResponseEntry(\n response.string('status'),\n response.string('description'),\n response.optionalBoolean('requiresAuth') ?? false,\n ),\n ),\n );\n }\n\n private responseHeaders(raw: JsonReader): readonly ResponseHeaderEntry[] {\n return raw.objects('responseHeaders').map((header: JsonReader) => {\n // RETIRED (#1249): a header NAME is never a string constant any more — it is read off the\n // ContextKey that is the one definition of the header. Refused, never accepted beside the\n // new key: two spellings means the old one is never migrated.\n if (header.has(RETIRED_NAME_CONSTANT)) {\n throw new OpenApiGenerationError(\n `'${RETIRED_NAME_CONSTANT}' was removed from responseHeaders[]; it moved to 'contextKey'`,\n raw.where,\n `Replace \"${RETIRED_NAME_CONSTANT}\" with \"contextKey\" naming an exported ContextKey in ` +\n '\"entry\" (e.g. `export const REQUEST_ID_KEY = WebpiecesCoreHeaders.REQUEST_ID;`, ' +\n 'or a dotted path like \"OneTabletKey.TX_ID\"); the header name is read off its responseHeader.',\n );\n }\n return new ResponseHeaderEntry(\n header.string('entry'),\n header.string('contextKey'),\n header.optionalString('description'),\n header.optionalBoolean('required'),\n );\n });\n }\n\n /** A manifest-relative path, resolved against the manifest's own directory. */\n resolve(manifestPath: string, relative: string): string {\n return path.resolve(path.dirname(manifestPath), relative);\n }\n}\n"]}
1
+ {"version":3,"file":"ManifestLoader.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/manifest/ManifestLoader.ts"],"names":[],"mappings":";;;;AAAA,oDAA8B;AAC9B,wDAAkC;AAClC,sEAAmE;AACnE,6CAA0C;AAC1C,4DAA2D;AAC3D,uDAS2B;AAE3B,gGAAgG;AAChG,MAAM,OAAO,GAAG,SAAS,CAAC;AAE1B;;;GAGG;AACH,MAAM,UAAU,GAAG,YAAY,CAAC;AAEhC,gFAAgF;AAChF,MAAM,qBAAqB,GAAG,c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D,CACR,CACR,CAAC;IACN,CAAC;IAEO,eAAe,CAAC,GAAe;QACnC,OAAO,GAAG,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,GAAG,CAAC,CAAC,MAAkB,EAAE,EAAE;YAC7D,0FAA0F;YAC1F,0FAA0F;YAC1F,8DAA8D;YAC9D,IAAI,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAAE,CAAC;gBACpC,MAAM,IAAI,+CAAsB,CAC5B,IAAI,qBAAqB,gEAAgE,EACzF,GAAG,CAAC,KAAK,EACT,YAAY,qBAAqB,uDAAuD;oBACpF,kFAAkF;oBAClF,8FAA8F,CACrG,CAAC;YACN,CAAC;YACD,OAAO,IAAI,qCAAmB,CAC1B,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EACtB,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC,EAC3B,MAAM,CAAC,cAAc,CAAC,aAAa,CAAC,EACpC,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CACrC,CAAC;QACN,CAAC,CAAC,CAAC;IACP,CAAC;IAED,+EAA+E;IAC/E,OAAO,CAAC,YAAoB,EAAE,QAAgB;QAC1C,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACJ;AA3ND,wCA2NC","sourcesContent":["import * as fs from 'node:fs';\nimport * as path from 'node:path';\nimport { OpenApiGenerationError } from '../OpenApiGenerationError';\nimport { JsonReader } from './JsonReader';\nimport { SchemaNameEntry } from '@webpieces/api-doc-model';\nimport {\n ApiEntry,\n ComponentsManifest,\n ErrorResponseEntry,\n ErrorsEntry,\n OpenApiManifest,\n OperationIdStyle,\n ResponseHeaderEntry,\n ServerEntry,\n} from './OpenApiManifest';\n\n/** The only `kind` an api entry may declare. Anything else is a typo, and typos are refused. */\nconst WEBHOOK = 'webhook';\n\n/**\n * The only `kind` a MANIFEST may declare (#1058): a DTO library's components-only document. A\n * manifest with no `kind` is a contract library's, exactly as before.\n */\nconst COMPONENTS = 'components';\n\n/** The deleted string-constant spelling of a response header's name (#1249). */\nconst RETIRED_NAME_CONSTANT = 'nameConstant';\n\n/** Keys a components manifest must not carry, each with why — a contract-manifest key is a mix-up. */\nconst NOT_IN_COMPONENTS: ReadonlyMap<string, string> = new Map<string, string>([\n ['apis', 'a components document has no paths; list the library\\'s entry files in \"entries\"'],\n [\n 'version',\n \"a library document's info.version is the package version, read from its package.json\",\n ],\n ['servers', 'a components document has no operations to serve'],\n ['errors', 'the error contract belongs to a contract document'],\n ['responseHeaders', 'response headers belong to a contract document'],\n ['securitySchemeNames', 'security belongs to a contract document'],\n ['operationIds', 'a components document has no operations to name'],\n]);\n\n/** Every spelling `operationIds` accepts, in the order the refusal lists them. */\nconst OPERATION_ID_STYLES: readonly OperationIdStyle[] = [\n OperationIdStyle.CONTRACT_METHOD,\n OperationIdStyle.METHOD,\n];\n\n/**\n * Read `openapi.manifest.json` into {@link OpenApiManifest}.\n *\n * It deals only in {@link JsonReader}, which is where the \"came off disk, not yet checked\" state is\n * concentrated — so nothing in this file, or anywhere downstream, handles an unnarrowed value.\n *\n * Every rejection is a HARD FAILURE naming the field. A published document quietly missing a section\n * is indistinguishable, from outside, from an API that genuinely has no error contract.\n */\nexport class ManifestLoader {\n /**\n * True for a DTO library's `\"kind\": \"components\"` manifest, false for a contract library's (no\n * `kind`). Any other `kind` is refused: a typo there would otherwise render the wrong document.\n */\n isComponents(manifestPath: string): boolean {\n const kind = this.read(manifestPath).optionalString('kind');\n if (kind === undefined) {\n return false;\n }\n if (kind !== COMPONENTS) {\n throw new OpenApiGenerationError(\n `unknown manifest kind '${kind}'`,\n manifestPath,\n `The only manifest kind is \"${COMPONENTS}\", for a DTO library's components document. ` +\n \"Leave it out for a contract library's manifest.\",\n );\n }\n return true;\n }\n\n /** A DTO library's components manifest. See {@link ComponentsManifest}. */\n loadComponents(manifestPath: string): ComponentsManifest {\n const raw = this.read(manifestPath);\n for (const key of NOT_IN_COMPONENTS.keys()) {\n const why = NOT_IN_COMPONENTS.get(key)!;\n if (raw.has(key)) {\n throw new OpenApiGenerationError(\n `a \"kind\": \"${COMPONENTS}\" manifest declares '${key}'`,\n raw.where,\n `Delete it — ${why}.`,\n );\n }\n }\n const entries = raw.strings('entries');\n if (entries.length === 0) {\n throw new OpenApiGenerationError(\n \"'entries' is empty\",\n raw.where,\n 'Name the library\\'s entry files, e.g. \"entries\": [\"src/index.ts\"]; the document holds every type they export.',\n );\n }\n return new ComponentsManifest(raw.string('title'), entries, this.schemaNames(raw));\n }\n\n private read(manifestPath: string): JsonReader {\n if (!fs.existsSync(manifestPath)) {\n throw new OpenApiGenerationError(\n 'no manifest at this path',\n manifestPath,\n 'Pass --manifest pointing at an openapi.manifest.json that exists.',\n );\n }\n return JsonReader.parseFile(fs.readFileSync(manifestPath, 'utf8'), manifestPath);\n }\n\n /** @param manifestPath absolute path to a CONTRACT library's `openapi.manifest.json`. */\n load(manifestPath: string): OpenApiManifest {\n if (this.isComponents(manifestPath)) {\n throw new OpenApiGenerationError(\n `this is a \"kind\": \"${COMPONENTS}\" manifest, not a contract manifest`,\n manifestPath,\n 'Render it as a components document (wp-openapi does so on its own when it reads the kind).',\n );\n }\n const raw = this.read(manifestPath);\n return new OpenApiManifest(\n raw.string('title'),\n raw.string('version'),\n this.servers(raw),\n raw.optionalString('descriptionFile'),\n this.apis(raw),\n raw.strings('securitySchemeNames'),\n this.errors(raw),\n this.responseHeaders(raw),\n this.schemaNames(raw),\n this.operationIds(raw),\n );\n }\n\n /**\n * OPTIONAL, defaulting to `\"contract_method\"` (#1283) — the spelling every release before #1270\n * published, and the one that is unique by construction, so a new contract gets the safe scheme\n * without writing anything. `\"method\"` is the opt-in for a document that already published bare\n * names. A value that is present but is neither choice is still refused.\n */\n private operationIds(raw: JsonReader): OperationIdStyle {\n if (!raw.has('operationIds')) {\n return OperationIdStyle.CONTRACT_METHOD;\n }\n const value = raw.optionalString('operationIds');\n const style = OPERATION_ID_STYLES.find((each: OperationIdStyle) => each === value);\n if (style !== undefined) {\n return style;\n }\n const choices = OPERATION_ID_STYLES.map((each: OperationIdStyle) => `\"${each}\"`).join(' or ');\n throw new OpenApiGenerationError(\n value === undefined\n ? \"'operationIds' is present but is not a non-empty string\"\n : `unknown operationIds style '${value}'`,\n raw.where,\n `Set \"operationIds\" to ${choices}, or omit it for \"${OperationIdStyle.CONTRACT_METHOD}\". ` +\n `\"${OperationIdStyle.CONTRACT_METHOD}\" publishes OrdersApi_fetchOrders; ` +\n `\"${OperationIdStyle.METHOD}\" publishes fetchOrders and fails generation when two ` +\n 'operations of one document would share it. Generated partner clients name their ' +\n 'methods from it, so changing it renames every method in their SDKs.',\n );\n }\n\n private servers(raw: JsonReader): readonly ServerEntry[] {\n return raw\n .objects('servers')\n .map(\n (server: JsonReader) =>\n new ServerEntry(server.string('url'), server.optionalString('description')),\n );\n }\n\n private schemaNames(raw: JsonReader): readonly SchemaNameEntry[] {\n return raw.objects('schemaNames').map((entry: JsonReader) => {\n const paths = entry.strings('paths');\n const suffixes = entry.strings('stripSuffixes');\n if (\n paths.length === 0 ||\n paths.some((glob: string) => glob.trim() === '') ||\n !entry.has('stripSuffixes') ||\n suffixes.some((suffix: string) => suffix.length === 0)\n ) {\n throw new OpenApiGenerationError(\n 'invalid schemaNames entry',\n raw.where,\n 'Provide non-empty paths and an explicit stripSuffixes array of non-empty suffixes (or [] to preserve names). First matching path wins.',\n );\n }\n return new SchemaNameEntry(\n paths.map((glob: string) => path.resolve(path.dirname(raw.where), glob)),\n suffixes,\n );\n });\n }\n\n private apis(raw: JsonReader): readonly ApiEntry[] {\n const entries = raw\n .objects('apis')\n .map(\n (api: JsonReader) =>\n new ApiEntry(\n api.string('entry'),\n api.string('tag'),\n api.optionalString('kind'),\n ),\n );\n if (entries.length === 0) {\n throw new OpenApiGenerationError(\n \"'apis' is empty\",\n raw.where,\n 'List at least one contract; a document with no operations publishes nothing.',\n );\n }\n for (const entry of entries) {\n if (entry.kind !== undefined && entry.kind !== WEBHOOK) {\n throw new OpenApiGenerationError(\n `unknown api kind '${entry.kind}' on '${entry.entry}'`,\n raw.where,\n `The only declared kind is \"${WEBHOOK}\". Leave it out for an ordinary contract.`,\n );\n }\n }\n return entries;\n }\n\n private errors(raw: JsonReader): ErrorsEntry | undefined {\n const errors = raw.object('errors');\n if (errors === undefined) {\n return undefined;\n }\n return new ErrorsEntry(\n errors.string('entry'),\n errors.string('type'),\n errors\n .objects('responses')\n .map(\n (response: JsonReader) =>\n new ErrorResponseEntry(\n response.string('status'),\n response.string('description'),\n response.optionalBoolean('requiresAuth') ?? false,\n ),\n ),\n );\n }\n\n private responseHeaders(raw: JsonReader): readonly ResponseHeaderEntry[] {\n return raw.objects('responseHeaders').map((header: JsonReader) => {\n // RETIRED (#1249): a header NAME is never a string constant any more — it is read off the\n // ContextKey that is the one definition of the header. Refused, never accepted beside the\n // new key: two spellings means the old one is never migrated.\n if (header.has(RETIRED_NAME_CONSTANT)) {\n throw new OpenApiGenerationError(\n `'${RETIRED_NAME_CONSTANT}' was removed from responseHeaders[]; it moved to 'contextKey'`,\n raw.where,\n `Replace \"${RETIRED_NAME_CONSTANT}\" with \"contextKey\" naming an exported ContextKey in ` +\n '\"entry\" (e.g. `export const REQUEST_ID_KEY = WebpiecesCoreHeaders.REQUEST_ID;`, ' +\n 'or a dotted path like \"OneTabletKey.TX_ID\"); the header name is read off its responseHeader.',\n );\n }\n return new ResponseHeaderEntry(\n header.string('entry'),\n header.string('contextKey'),\n header.optionalString('description'),\n header.optionalBoolean('required'),\n );\n });\n }\n\n /** A manifest-relative path, resolved against the manifest's own directory. */\n resolve(manifestPath: string, relative: string): string {\n return path.resolve(path.dirname(manifestPath), relative);\n }\n}\n"]}
@@ -17,7 +17,7 @@
17
17
  * - `errors` — the document-wide failure contract, with the BODY read from a real TS type so the
18
18
  * published shape cannot drift from the one on the wire.
19
19
  * - `responseHeaders[]` — declared by `contextKey` naming an exported ContextKey, never by a literal.
20
- * - `operationIds` — the published operationId spelling, a partner-visible decision (#1270).
20
+ * - `operationIds` — the published operationId spelling (#1270); optional, `contract_method` when omitted (#1283).
21
21
  *
22
22
  * Anything a renderer could read off the source instead belongs in the source.
23
23
  *
@@ -28,10 +28,11 @@
28
28
  */
29
29
  import { SchemaNameEntry } from '@webpieces/api-doc-model';
30
30
  /**
31
- * How every operation's `operationId` is spelled (#1270). REQUIRED in a contract manifest, with no
32
- * default: `operationId` is what openapi-generator, Kiota, NSwag and friends name the METHOD in every
33
- * client a partner generates, so changing the spelling renames every method in every partner's SDK.
34
- * That is the consumer's decision to state, never one a generator default makes silently.
31
+ * How every operation's `operationId` is spelled (#1270). OPTIONAL in a contract manifest, defaulting
32
+ * to {@link CONTRACT_METHOD} (#1283) — the spelling every earlier release published, and the only one
33
+ * unique by construction. `operationId` is what openapi-generator, Kiota, NSwag and friends name the
34
+ * METHOD in every client a partner generates, so changing the spelling renames every method in every
35
+ * partner's SDK; {@link METHOD} is the opt-in for a document that already published bare names.
35
36
  */
36
37
  export declare enum OperationIdStyle {
37
38
  /** `OrdersApi_fetchOrders` — unique by construction across contracts. */
@@ -2,10 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ComponentsManifest = exports.OpenApiManifest = exports.ResponseHeaderEntry = exports.ErrorsEntry = exports.ErrorResponseEntry = exports.ApiEntry = exports.ServerEntry = exports.OperationIdStyle = void 0;
4
4
  /**
5
- * How every operation's `operationId` is spelled (#1270). REQUIRED in a contract manifest, with no
6
- * default: `operationId` is what openapi-generator, Kiota, NSwag and friends name the METHOD in every
7
- * client a partner generates, so changing the spelling renames every method in every partner's SDK.
8
- * That is the consumer's decision to state, never one a generator default makes silently.
5
+ * How every operation's `operationId` is spelled (#1270). OPTIONAL in a contract manifest, defaulting
6
+ * to {@link CONTRACT_METHOD} (#1283) — the spelling every earlier release published, and the only one
7
+ * unique by construction. `operationId` is what openapi-generator, Kiota, NSwag and friends name the
8
+ * METHOD in every client a partner generates, so changing the spelling renames every method in every
9
+ * partner's SDK; {@link METHOD} is the opt-in for a document that already published bare names.
9
10
  */
10
11
  var OperationIdStyle;
11
12
  (function (OperationIdStyle) {
@@ -1 +1 @@
1
- {"version":3,"file":"OpenApiManifest.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/manifest/OpenApiManifest.ts"],"names":[],"mappings":";;;AA8BA;;;;;GAKG;AACH,IAAY,gBAQX;AARD,WAAY,gBAAgB;IACxB,yEAAyE;IACzE,uDAAmC,CAAA;IACnC;;;OAGG;IACH,qCAAiB,CAAA;AACrB,CAAC,EARW,gBAAgB,gCAAhB,gBAAgB,QAQ3B;AAED,MAAa,WAAW;IAEP;IACA;IAFb,YACa,GAAW,EACX,WAA+B;QAD/B,QAAG,GAAH,GAAG,CAAQ;QACX,gBAAW,GAAX,WAAW,CAAoB;IACzC,CAAC;CACP;AALD,kCAKC;AAED,6CAA6C;AAC7C,MAAa,QAAQ;IAGJ;IAEA;IASA;IAbb;IACI,4EAA4E;IACnE,KAAa;IACtB,2FAA2F;IAClF,GAAW;IACpB;;;;;;;OAOG;IACM,IAAwB;QAXxB,UAAK,GAAL,KAAK,CAAQ;QAEb,QAAG,GAAH,GAAG,CAAQ;QASX,SAAI,GAAJ,IAAI,CAAoB;IAClC,CAAC;IAEJ,SAAS;QACL,OAAO,IAAI,CAAC,IAAI,KAAK,SAAS,CAAC;IACnC,CAAC;CACJ;AApBD,4BAoBC;AAED,6DAA6D;AAC7D,MAAa,kBAAkB;IAEd;IACA;IAOA;IATb,YACa,MAAc,EACd,WAAmB;IAC5B;;;;;OAKG;IACM,YAAqB;QARrB,WAAM,GAAN,MAAM,CAAQ;QACd,gBAAW,GAAX,WAAW,CAAQ;QAOnB,iBAAY,GAAZ,YAAY,CAAS;IAC/B,CAAC;CACP;AAZD,gDAYC;AAED;;;;;;GAMG;AACH,MAAa,WAAW;IAGP;IAEA;IACA;IALb;IACI,yEAAyE;IAChE,KA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GAAX,WAAW,CAA4B;IACjD,CAAC;CACP;AAPD,gDAOC","sourcesContent":["/**\n * `openapi.manifest.json`, as CLASSES.\n *\n * ## What is allowed in here, and what is not\n *\n * The manifest carries exactly what is **not a property of the code**, and nothing else. Every field\n * below is a product decision, a deployment fact, or a NAME pointing at something the code owns:\n *\n * - `title`, `version` — product decisions.\n * - `servers[]` — a deployment fact.\n * - `descriptionFile` — a teaching decision.\n * - `apis[]` — which contracts, in the order the published sidebar shows them.\n * - `securitySchemeNames[]` — the published scheme KEYS only. Everything else about the schemes, and\n * the AND-ed `security` requirement, is DERIVED from the contract's own `apiKey(...)`. A\n * `components.securitySchemes` block here would be a second copy of header names the running\n * server never reads, and nothing could contradict it.\n * - `errors` — the document-wide failure contract, with the BODY read from a real TS type so the\n * published shape cannot drift from the one on the wire.\n * - `responseHeaders[]` — declared by `contextKey` naming an exported ContextKey, never by a literal.\n * - `operationIds` — the published operationId spelling, a partner-visible decision (#1270).\n *\n * Anything a renderer could read off the source instead belongs in the source.\n *\n * ## The ORDER of `apis[]` is published navigation\n *\n * It is rendered into `tags[]` in that order, and a docs theme builds its sidebar from `tags[]`.\n * Alphabetising this array is not a cleanup; it reorders partner-facing navigation.\n */\nimport { SchemaNameEntry } from '@webpieces/api-doc-model';\n\n/**\n * How every operation's `operationId` is spelled (#1270). REQUIRED in a contract manifest, with no\n * default: `operationId` is what openapi-generator, Kiota, NSwag and friends name the METHOD in every\n * client a partner generates, so changing the spelling renames every method in every partner's SDK.\n * That is the consumer's decision to state, never one a generator default makes silently.\n */\nexport enum OperationIdStyle {\n /** `OrdersApi_fetchOrders` — unique by construction across contracts. */\n CONTRACT_METHOD = 'contract_method',\n /**\n * `fetchOrders` — the bare method name. Two operations of one document sharing it is a HARD\n * FAILURE naming both, so the id is still unique.\n */\n METHOD = 'method',\n}\n\nexport class ServerEntry {\n constructor(\n readonly url: string,\n readonly description: string | undefined,\n ) {}\n}\n\n/** One contract file the generator reads. */\nexport class ApiEntry {\n constructor(\n /** Path to the contract `.ts`, relative to the manifest's own directory. */\n readonly entry: string,\n /** The tag every operation of this contract carries — and one `tags[]` entry, in order. */\n readonly tag: string,\n /**\n * `webhook` moves the contract into the top-level `webhooks:` block: these are calls WE\n * make to a partner's server, not routes on ours.\n *\n * DECLARED, never sniffed from a `*WebhookApi` filename. A name convention would hide a\n * partner-visible decision inside a rename, and a rename is the one edit nobody reviews for\n * contract impact.\n */\n readonly kind: string | undefined,\n ) {}\n\n isWebhook(): boolean {\n return this.kind === 'webhook';\n }\n}\n\n/** One status code of the document-wide failure contract. */\nexport class ErrorResponseEntry {\n constructor(\n readonly status: string,\n readonly description: string,\n /**\n * `true`: this failure can only happen to an AUTHENTICATED operation (a 401 for a bad\n * credential), so it is left OFF every operation whose resolved auth is public\n * (`@WpAuthPublic`) — a public endpoint cannot fail authentication. Omitted means `false`:\n * the response is listed on every operation.\n */\n readonly requiresAuth: boolean,\n ) {}\n}\n\n/**\n * The document-wide failure contract.\n *\n * Document-wide and not per-operation on purpose: per-operation codes would be a second hand-written\n * list to keep in step with the handlers, and stating them once tells a partner the truth — any\n * operation can fail these ways.\n */\nexport class ErrorsEntry {\n constructor(\n /** The `.ts` file declaring the error body, relative to the manifest. */\n readonly entry: string,\n /** The exported TYPE name of the body. Read with the compiler, so it cannot drift. */\n readonly type: string,\n readonly responses: readonly ErrorResponseEntry[],\n ) {}\n}\n\n/**\n * One response header every operation carries — on its success response AND on every failure the\n * document declares for it (#1270): a correlation id matters most on the response that FAILED, and\n * the server stamps it on every response, so declaring it on the 200 alone under-documents the wire.\n *\n * `contextKey` names an exported `ContextKey` in `entry` — the export's name, or a dotted path into\n * one (`OneTabletKey.TX_ID`) — and the generator reads the header name off that key's own\n * `ContextKey.trusted(...)` / `ContextKey.untrusted(...)` definition: its `responseHeader`, which is\n * what the server's response choke point actually writes (#1249). A literal here would be a copy of\n * the header name that a rename leaves silently stale — and JSON cannot import, so naming the key is\n * the only way for this file to point at the one definition. Failing to resolve it is a HARD\n * FAILURE for the same reason.\n */\nexport class ResponseHeaderEntry {\n constructor(\n readonly entry: string,\n readonly contextKey: string,\n readonly description: string | undefined,\n /**\n * Rendered verbatim as the OpenAPI header object's `required`. Omitted means the document\n * does not state it, which OpenAPI reads as `false`.\n */\n readonly required: boolean | undefined,\n ) {}\n}\n\nexport class OpenApiManifest {\n constructor(\n readonly title: string,\n readonly version: string,\n readonly servers: readonly ServerEntry[],\n /** A markdown preamble, relative to the manifest. Rendered into `info.description`. */\n readonly descriptionFile: string | undefined,\n readonly apis: readonly ApiEntry[],\n readonly securitySchemeNames: readonly string[],\n readonly errors: ErrorsEntry | undefined,\n readonly responseHeaders: readonly ResponseHeaderEntry[],\n readonly schemaNames: readonly SchemaNameEntry[],\n readonly operationIds: OperationIdStyle,\n ) {}\n}\n\n/**\n * A DTO library's `openapi.manifest.json` — `\"kind\": \"components\"` (#1058).\n *\n * It names the library's ENTRY FILES instead of contracts: the document it produces is\n * components-only — `openapi`, `info` and `components.schemas`, no paths — holding every type the\n * library exports and declares, which contract documents `$ref` instead of copying. There is no\n * `version` here: a library document's `info.version` IS the package version, read from its\n * `package.json`, so the two cannot disagree.\n */\nexport class ComponentsManifest {\n constructor(\n readonly title: string,\n /** The library's entry files (usually `src/index.ts`), relative to the manifest's directory. */\n readonly entries: readonly string[],\n readonly schemaNames: readonly SchemaNameEntry[],\n ) {}\n}\n"]}
1
+ {"version":3,"file":"OpenApiManifest.js","sourceRoot":"","sources":["../../../../../../packages/docs/openapi-generator/src/manifest/OpenApiManifest.ts"],"names":[],"mappings":";;;AA8BA;;;;;;GAMG;AACH,IAAY,gBAQX;AARD,WAAY,gBAAgB;IACxB,yEAAyE;IACzE,uDAAmC,CAAA;IACnC;;;OAGG;IACH,qCAAiB,CAAA;AACrB,CAAC,EARW,gBAAgB,gCAAhB,gBAAgB,QAQ3B;AAED,MAAa,WAAW;IAEP;IACA;IAFb,YACa,GAAW,EACX,WAA+B;QAD/B,QAAG,GAAH,GAAG,CAAQ;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A;IACA;IACA;IAXb,YACa,KAAa,EACb,OAAe,EACf,OAA+B;IACxC,uFAAuF;IAC9E,eAAmC,EACnC,IAAyB,EACzB,mBAAsC,EACtC,MAA+B,EAC/B,eAA+C,EAC/C,WAAuC,EACvC,YAA8B;QAV9B,UAAK,GAAL,KAAK,CAAQ;QACb,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAwB;QAE/B,oBAAe,GAAf,eAAe,CAAoB;QACnC,SAAI,GAAJ,IAAI,CAAqB;QACzB,wBAAmB,GAAnB,mBAAmB,CAAmB;QACtC,WAAM,GAAN,MAAM,CAAyB;QAC/B,oBAAe,GAAf,eAAe,CAAgC;QAC/C,gBAAW,GAAX,WAAW,CAA4B;QACvC,iBAAY,GAAZ,YAAY,CAAkB;IACxC,CAAC;CACP;AAdD,0CAcC;AAED;;;;;;;;GAQG;AACH,MAAa,kBAAkB;IAEd;IAEA;IACA;IAJb,YACa,KAAa;IACtB,gGAAgG;IACvF,OAA0B,EAC1B,WAAuC;QAHvC,UAAK,GAAL,KAAK,CAAQ;QAEb,YAAO,GAAP,OAAO,CAAmB;QAC1B,gBAAW,GAAX,WAAW,CAA4B;IACjD,CAAC;CACP;AAPD,gDAOC","sourcesContent":["/**\n * `openapi.manifest.json`, as CLASSES.\n *\n * ## What is allowed in here, and what is not\n *\n * The manifest carries exactly what is **not a property of the code**, and nothing else. Every field\n * below is a product decision, a deployment fact, or a NAME pointing at something the code owns:\n *\n * - `title`, `version` — product decisions.\n * - `servers[]` — a deployment fact.\n * - `descriptionFile` — a teaching decision.\n * - `apis[]` — which contracts, in the order the published sidebar shows them.\n * - `securitySchemeNames[]` — the published scheme KEYS only. Everything else about the schemes, and\n * the AND-ed `security` requirement, is DERIVED from the contract's own `apiKey(...)`. A\n * `components.securitySchemes` block here would be a second copy of header names the running\n * server never reads, and nothing could contradict it.\n * - `errors` — the document-wide failure contract, with the BODY read from a real TS type so the\n * published shape cannot drift from the one on the wire.\n * - `responseHeaders[]` — declared by `contextKey` naming an exported ContextKey, never by a literal.\n * - `operationIds` — the published operationId spelling (#1270); optional, `contract_method` when omitted (#1283).\n *\n * Anything a renderer could read off the source instead belongs in the source.\n *\n * ## The ORDER of `apis[]` is published navigation\n *\n * It is rendered into `tags[]` in that order, and a docs theme builds its sidebar from `tags[]`.\n * Alphabetising this array is not a cleanup; it reorders partner-facing navigation.\n */\nimport { SchemaNameEntry } from '@webpieces/api-doc-model';\n\n/**\n * How every operation's `operationId` is spelled (#1270). OPTIONAL in a contract manifest, defaulting\n * to {@link CONTRACT_METHOD} (#1283) — the spelling every earlier release published, and the only one\n * unique by construction. `operationId` is what openapi-generator, Kiota, NSwag and friends name the\n * METHOD in every client a partner generates, so changing the spelling renames every method in every\n * partner's SDK; {@link METHOD} is the opt-in for a document that already published bare names.\n */\nexport enum OperationIdStyle {\n /** `OrdersApi_fetchOrders` — unique by construction across contracts. */\n CONTRACT_METHOD = 'contract_method',\n /**\n * `fetchOrders` — the bare method name. Two operations of one document sharing it is a HARD\n * FAILURE naming both, so the id is still unique.\n */\n METHOD = 'method',\n}\n\nexport class ServerEntry {\n constructor(\n readonly url: string,\n readonly description: string | undefined,\n ) {}\n}\n\n/** One contract file the generator reads. */\nexport class ApiEntry {\n constructor(\n /** Path to the contract `.ts`, relative to the manifest's own directory. */\n readonly entry: string,\n /** The tag every operation of this contract carries — and one `tags[]` entry, in order. */\n readonly tag: string,\n /**\n * `webhook` moves the contract into the top-level `webhooks:` block: these are calls WE\n * make to a partner's server, not routes on ours.\n *\n * DECLARED, never sniffed from a `*WebhookApi` filename. A name convention would hide a\n * partner-visible decision inside a rename, and a rename is the one edit nobody reviews for\n * contract impact.\n */\n readonly kind: string | undefined,\n ) {}\n\n isWebhook(): boolean {\n return this.kind === 'webhook';\n }\n}\n\n/** One status code of the document-wide failure contract. */\nexport class ErrorResponseEntry {\n constructor(\n readonly status: string,\n readonly description: string,\n /**\n * `true`: this failure can only happen to an AUTHENTICATED operation (a 401 for a bad\n * credential), so it is left OFF every operation whose resolved auth is public\n * (`@WpAuthPublic`) — a public endpoint cannot fail authentication. Omitted means `false`:\n * the response is listed on every operation.\n */\n readonly requiresAuth: boolean,\n ) {}\n}\n\n/**\n * The document-wide failure contract.\n *\n * Document-wide and not per-operation on purpose: per-operation codes would be a second hand-written\n * list to keep in step with the handlers, and stating them once tells a partner the truth — any\n * operation can fail these ways.\n */\nexport class ErrorsEntry {\n constructor(\n /** The `.ts` file declaring the error body, relative to the manifest. */\n readonly entry: string,\n /** The exported TYPE name of the body. Read with the compiler, so it cannot drift. */\n readonly type: string,\n readonly responses: readonly ErrorResponseEntry[],\n ) {}\n}\n\n/**\n * One response header every operation carries — on its success response AND on every failure the\n * document declares for it (#1270): a correlation id matters most on the response that FAILED, and\n * the server stamps it on every response, so declaring it on the 200 alone under-documents the wire.\n *\n * `contextKey` names an exported `ContextKey` in `entry` — the export's name, or a dotted path into\n * one (`OneTabletKey.TX_ID`) — and the generator reads the header name off that key's own\n * `ContextKey.trusted(...)` / `ContextKey.untrusted(...)` definition: its `responseHeader`, which is\n * what the server's response choke point actually writes (#1249). A literal here would be a copy of\n * the header name that a rename leaves silently stale — and JSON cannot import, so naming the key is\n * the only way for this file to point at the one definition. Failing to resolve it is a HARD\n * FAILURE for the same reason.\n */\nexport class ResponseHeaderEntry {\n constructor(\n readonly entry: string,\n readonly contextKey: string,\n readonly description: string | undefined,\n /**\n * Rendered verbatim as the OpenAPI header object's `required`. Omitted means the document\n * does not state it, which OpenAPI reads as `false`.\n */\n readonly required: boolean | undefined,\n ) {}\n}\n\nexport class OpenApiManifest {\n constructor(\n readonly title: string,\n readonly version: string,\n readonly servers: readonly ServerEntry[],\n /** A markdown preamble, relative to the manifest. Rendered into `info.description`. */\n readonly descriptionFile: string | undefined,\n readonly apis: readonly ApiEntry[],\n readonly securitySchemeNames: readonly string[],\n readonly errors: ErrorsEntry | undefined,\n readonly responseHeaders: readonly ResponseHeaderEntry[],\n readonly schemaNames: readonly SchemaNameEntry[],\n readonly operationIds: OperationIdStyle,\n ) {}\n}\n\n/**\n * A DTO library's `openapi.manifest.json` — `\"kind\": \"components\"` (#1058).\n *\n * It names the library's ENTRY FILES instead of contracts: the document it produces is\n * components-only — `openapi`, `info` and `components.schemas`, no paths — holding every type the\n * library exports and declares, which contract documents `$ref` instead of copying. There is no\n * `version` here: a library document's `info.version` IS the package version, read from its\n * `package.json`, so the two cannot disagree.\n */\nexport class ComponentsManifest {\n constructor(\n readonly title: string,\n /** The library's entry files (usually `src/index.ts`), relative to the manifest's directory. */\n readonly entries: readonly string[],\n readonly schemaNames: readonly SchemaNameEntry[],\n ) {}\n}\n"]}