@twin.org/ts-to-openapi 0.0.3-next.17 → 0.0.3-next.18

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/dist/es/cli.js CHANGED
@@ -20,7 +20,7 @@ export class CLI extends CLIBase {
20
20
  return this.execute({
21
21
  title: "TWIN TypeScript To OpenAPI",
22
22
  appName: "ts-to-openapi",
23
- version: "0.0.3-next.17", // x-release-please-version
23
+ version: "0.0.3-next.18", // x-release-please-version
24
24
  icon: "⚙️ ",
25
25
  supportsEnvFiles: false,
26
26
  overrideOutputWidth: options?.overrideOutputWidth
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;GAEG;AACH,MAAM,OAAO,GAAI,SAAQ,OAAO;IAC/B;;;;;;;OAOG;IACI,KAAK,CAAC,GAAG,CACf,IAAc,EACd,gBAAyB,EACzB,OAA0C;QAE1C,OAAO,IAAI,CAAC,OAAO,CAClB;YACC,KAAK,EAAE,4BAA4B;YACnC,OAAO,EAAE,eAAe;YACxB,OAAO,EAAE,eAAe,EAAE,2BAA2B;YACrD,IAAI,EAAE,KAAK;YACX,gBAAgB,EAAE,KAAK;YACvB,mBAAmB,EAAE,OAAO,EAAE,mBAAmB;SACjD,EACD,gBAAgB,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,EACzF,IAAI,CACJ,CAAC;IACH,CAAC;IAED;;;OAGG;IACO,aAAa,CAAC,OAAgB;QACvC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { CLIBase } from \"@twin.org/cli-core\";\nimport type { Command } from \"commander\";\nimport { buildCommandTsToOpenApi } from \"./commands/tsToOpenApi.js\";\n\n/**\n * The main entry point for the CLI.\n */\nexport class CLI extends CLIBase {\n\t/**\n\t * Run the app.\n\t * @param argv The process arguments.\n\t * @param localesDirectory The directory for the locales, default to relative to the script.\n\t * @param options Additional options.\n\t * @param options.overrideOutputWidth Override the output width.\n\t * @returns The exit code.\n\t */\n\tpublic async run(\n\t\targv: string[],\n\t\tlocalesDirectory?: string,\n\t\toptions?: { overrideOutputWidth?: number }\n\t): Promise<number> {\n\t\treturn this.execute(\n\t\t\t{\n\t\t\t\ttitle: \"TWIN TypeScript To OpenAPI\",\n\t\t\t\tappName: \"ts-to-openapi\",\n\t\t\t\tversion: \"0.0.3-next.17\", // x-release-please-version\n\t\t\t\ticon: \"⚙️ \",\n\t\t\t\tsupportsEnvFiles: false,\n\t\t\t\toverrideOutputWidth: options?.overrideOutputWidth\n\t\t\t},\n\t\t\tlocalesDirectory ?? path.join(path.dirname(fileURLToPath(import.meta.url)), \"../locales\"),\n\t\t\targv\n\t\t);\n\t}\n\n\t/**\n\t * Configure any options or actions at the root program level.\n\t * @param program The root program command.\n\t */\n\tprotected configureRoot(program: Command): void {\n\t\tbuildCommandTsToOpenApi(program);\n\t}\n}\n"]}
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAEpE;;GAEG;AACH,MAAM,OAAO,GAAI,SAAQ,OAAO;IAC/B;;;;;;;OAOG;IACI,KAAK,CAAC,GAAG,CACf,IAAc,EACd,gBAAyB,EACzB,OAA0C;QAE1C,OAAO,IAAI,CAAC,OAAO,CAClB;YACC,KAAK,EAAE,4BAA4B;YACnC,OAAO,EAAE,eAAe;YACxB,OAAO,EAAE,eAAe,EAAE,2BAA2B;YACrD,IAAI,EAAE,KAAK;YACX,gBAAgB,EAAE,KAAK;YACvB,mBAAmB,EAAE,OAAO,EAAE,mBAAmB;SACjD,EACD,gBAAgB,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,EACzF,IAAI,CACJ,CAAC;IACH,CAAC;IAED;;;OAGG;IACO,aAAa,CAAC,OAAgB;QACvC,uBAAuB,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;CACD","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { CLIBase } from \"@twin.org/cli-core\";\nimport type { Command } from \"commander\";\nimport { buildCommandTsToOpenApi } from \"./commands/tsToOpenApi.js\";\n\n/**\n * The main entry point for the CLI.\n */\nexport class CLI extends CLIBase {\n\t/**\n\t * Run the app.\n\t * @param argv The process arguments.\n\t * @param localesDirectory The directory for the locales, default to relative to the script.\n\t * @param options Additional options.\n\t * @param options.overrideOutputWidth Override the output width.\n\t * @returns The exit code.\n\t */\n\tpublic async run(\n\t\targv: string[],\n\t\tlocalesDirectory?: string,\n\t\toptions?: { overrideOutputWidth?: number }\n\t): Promise<number> {\n\t\treturn this.execute(\n\t\t\t{\n\t\t\t\ttitle: \"TWIN TypeScript To OpenAPI\",\n\t\t\t\tappName: \"ts-to-openapi\",\n\t\t\t\tversion: \"0.0.3-next.18\", // x-release-please-version\n\t\t\t\ticon: \"⚙️ \",\n\t\t\t\tsupportsEnvFiles: false,\n\t\t\t\toverrideOutputWidth: options?.overrideOutputWidth\n\t\t\t},\n\t\t\tlocalesDirectory ?? path.join(path.dirname(fileURLToPath(import.meta.url)), \"../locales\"),\n\t\t\targv\n\t\t);\n\t}\n\n\t/**\n\t * Configure any options or actions at the root program level.\n\t * @param program The root program command.\n\t */\n\tprotected configureRoot(program: Command): void {\n\t\tbuildCommandTsToOpenApi(program);\n\t}\n}\n"]}
@@ -4,7 +4,7 @@ import { mkdir, rm, writeFile } from "node:fs/promises";
4
4
  import path from "node:path";
5
5
  import { pathToFileURL } from "node:url";
6
6
  import { CLIDisplay, CLIUtils } from "@twin.org/cli-core";
7
- import { GeneralError, I18n, Is, JsonHelper, ObjectHelper, StringHelper } from "@twin.org/core";
7
+ import { GeneralError, I18n, Is, ObjectHelper, StringHelper } from "@twin.org/core";
8
8
  import { TypeScriptToSchema, Constants } from "@twin.org/tools-core";
9
9
  import { OpenApiConstants } from "@twin.org/tools-models";
10
10
  import { HttpStatusCode, MimeTypes } from "@twin.org/web";
@@ -490,7 +490,6 @@ async function finaliseOutput(schemas, openApi, securitySchemes, externalReferen
490
490
  const { finalSchemas, substituteSchemas } = prepareFinalSchemas(schemas, externalReferences);
491
491
  removeStandardSchemas(finalSchemas);
492
492
  applyRefOnlySchemaSubstitutions(openApi, substituteSchemas);
493
- applyEquivalentResponseSubstitutions(openApi, finalSchemas, substituteSchemas);
494
493
  const sortedSchemas = buildSortedPrunedSchemas(openApi, finalSchemas);
495
494
  // Schemas that have been kept as local component schemas must not have their
496
495
  // $ref values in paths rewritten to external URLs.
@@ -639,20 +638,6 @@ function applyRefOnlySchemaSubstitutions(openApi, substituteSchemas) {
639
638
  * @param finalSchemas The final schemas map.
640
639
  * @param substituteSchemas The collected schema substitutions.
641
640
  */
642
- function applyEquivalentResponseSubstitutions(openApi, finalSchemas, substituteSchemas) {
643
- const equivalentResponseSchemaSubstitutions = findEquivalentResponseSchemaSubstitutions(finalSchemas);
644
- if (equivalentResponseSchemaSubstitutions.length > 0) {
645
- rewriteSchemaRefs(openApi.paths, equivalentResponseSchemaSubstitutions);
646
- rewriteSchemaRefs(finalSchemas, equivalentResponseSchemaSubstitutions);
647
- for (const substitution of equivalentResponseSchemaSubstitutions) {
648
- delete finalSchemas[substitution.from];
649
- substituteSchemas.push({
650
- from: substitution.from,
651
- to: `#/components/schemas/${substitution.to}`
652
- });
653
- }
654
- }
655
- }
656
641
  /**
657
642
  * Build sorted and tidied schemas from the current OpenAPI references.
658
643
  * @param openApi The OpenAPI document.
@@ -666,6 +651,7 @@ function buildSortedPrunedSchemas(openApi, finalSchemas) {
666
651
  const sortedSchemas = {};
667
652
  for (const key of prunedSchemaKeys) {
668
653
  tidySchemaProperties(prunedSchemas[key], false);
654
+ delete prunedSchemas[key].title;
669
655
  sortedSchemas[key] = prunedSchemas[key];
670
656
  }
671
657
  return sortedSchemas;
@@ -699,36 +685,6 @@ function pruneToReferencedSchemas(openApi, schemas) {
699
685
  }
700
686
  return prunedSchemas;
701
687
  }
702
- /**
703
- * Find response wrapper schemas that are structurally identical to a canonical non-response schema.
704
- * @param schemas The candidate component schemas.
705
- * @returns The schema substitutions.
706
- */
707
- function findEquivalentResponseSchemaSubstitutions(schemas) {
708
- const substitutions = [];
709
- const schemaEntries = Object.entries(schemas);
710
- for (const [schemaName, schema] of schemaEntries) {
711
- if (schemaName.endsWith("Response")) {
712
- const canonicalEntry = schemaEntries
713
- .filter(([candidateName, candidateSchema]) => {
714
- if (candidateName === schemaName ||
715
- candidateName.endsWith("Response") ||
716
- StringHelper.stripPrefix(candidateName) !== "Error") {
717
- return false;
718
- }
719
- return JsonHelper.canonicalize(candidateSchema) === JsonHelper.canonicalize(schema);
720
- })
721
- .sort(([candidateNameA], [candidateNameB]) => candidateNameA.localeCompare(candidateNameB))[0];
722
- if (canonicalEntry) {
723
- substitutions.push({
724
- from: schemaName,
725
- to: canonicalEntry[0]
726
- });
727
- }
728
- }
729
- }
730
- return substitutions;
731
- }
732
688
  /**
733
689
  * Rewrite schema refs using the provided substitutions.
734
690
  * @param value The value to rewrite.
@@ -996,25 +952,8 @@ function resolveResponseSchemaRefName(schemas, typeName) {
996
952
  if (!Is.stringValue(typeName)) {
997
953
  return undefined;
998
954
  }
999
- if (isErrorResponseType(typeName) && resolveSchema(schemas, "Error")) {
1000
- return "Error";
1001
- }
1002
955
  return typeName;
1003
956
  }
1004
- /**
1005
- * Determine whether a response type should be canonicalised to the shared Error schema.
1006
- * @param typeName The response type name.
1007
- * @returns True if the type represents an error response wrapper.
1008
- */
1009
- function isErrorResponseType(typeName) {
1010
- const strippedTypeName = StringHelper.stripPrefix(typeName);
1011
- for (const responseDetails of Object.values(HTTP_STATUS_CODE_MAP)) {
1012
- if (responseDetails.responseType === typeName) {
1013
- return responseDetails.code >= HttpStatusCode.badRequest;
1014
- }
1015
- }
1016
- return /(?:^Bad.*Response$|^UnauthorizedResponse$|^ForbiddenResponse$|^NotFoundResponse$|^ConflictResponse$|^Unprocessable.*Response$|ErrorResponse$)/u.test(strippedTypeName);
1017
- }
1018
957
  /**
1019
958
  * Delete a schema by its raw or stripped interface type name.
1020
959
  * @param schemas The schema map.
@@ -1 +1 @@
1
- {"version":3,"file":"tsToOpenApi.js","sourceRoot":"","sources":["../../../src/commands/tsToOpenApi.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,EAAE,UAAU,EAAE,YA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IAAI,aAAa,GAAG,YAAY,CAAC,mBAAmB,CACnD,UAAU,CAAC,aAAa,IAAI,iBAAiB,CAAC,gBAAgB,IAAI,EAAE,CACpE,CAAC;YAEF,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC9B,aAAa,GAAG,IAAI,YAAY,CAAC,kBAAkB,CAAC,aAAa,CAAC,EAAE,CAAC;YACtE,CAAC;YAED,IAAI,MAAM,GAAiB,iBAAiB,CAAC,cAAc,CAAC,aAAa,EAAE,eAAe,CAAC,CAAC;YAE5F,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,eAAe,IAAI,KAAK,CAAC,CAAC,CAAC;YAE3D,IAAI,EAAE,CAAC,WAAW,CAAC,UAAU,CAAC,wBAAwB,CAAC,EAAE,CAAC;gBACzD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;oBAC5B,KAAK,CAAC,WAAW,GAAG,GAAG,KAAK,CAAC,WAAW,GAAG,UAAU,CAAC,wBAAwB,EAAE,CAAC;gBAClF,CAAC;YACF,CAAC;YAED,UAAU,CAAC,IAAI,CAAC;gBACf,UAAU,EAAE,MAAM;gBAClB,IAAI,EAAE,iBAAiB,CAAC,IAAI;aAC5B,CAAC,CAAC;QACJ,CAAC;QAED,UAAU,CAAC,KAAK,EAAE,CAAC;IACpB,CAAC;IAED,OAAO,UAAU,CAAC;AACnB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { mkdir, rm, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { CLIDisplay, CLIUtils } from \"@twin.org/cli-core\";\nimport { GeneralError, I18n, Is, JsonHelper, ObjectHelper, StringHelper } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { TypeScriptToSchema, Constants } from \"@twin.org/tools-core\";\nimport {\n\ttype IJsonSchema,\n\ttype IOpenApi,\n\ttype IOpenApiExample,\n\ttype IOpenApiHeader,\n\ttype IOpenApiParameter,\n\ttype IOpenApiPathItem,\n\ttype IOpenApiPathMethod,\n\ttype IOpenApiResponse,\n\ttype IOpenApiSecurityScheme,\n\ttype IPackageJson,\n\tOpenApiConstants\n} from \"@twin.org/tools-models\";\nimport { HttpStatusCode, MimeTypes } from \"@twin.org/web\";\nimport type { Command } from \"commander\";\nimport {\n\tHTTP_STATUS_CODE_MAP,\n\tgetHttpExampleFromType,\n\tgetHttpStatusCodeFromType\n} from \"./httpStatusCodeMap.js\";\nimport type { IInputPath } from \"../models/IInputPath.js\";\nimport type { IInputResult } from \"../models/IInputResult.js\";\nimport type { IRestRoute } from \"../models/IRestRoute.js\";\nimport type { IRestRouteEntryPoint } from \"../models/IRestRouteEntryPoints.js\";\nimport type { ITag } from \"../models/ITag.js\";\nimport type { ITsToOpenApiConfig } from \"../models/ITsToOpenApiConfig.js\";\nimport type { ITsToOpenApiConfigEntryPoint } from \"../models/ITsToOpenApiConfigEntryPoint.js\";\n\n/**\n * Build the root command to be consumed by the CLI.\n * @param program The command to build on.\n */\nexport function buildCommandTsToOpenApi(program: Command): void {\n\tprogram\n\t\t.argument(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.options.config.param\"),\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.options.config.description\")\n\t\t)\n\t\t.argument(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.options.output-file.param\"),\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.options.output-file.description\")\n\t\t)\n\t\t.action(async (config, outputFile, opts) => {\n\t\t\tawait actionCommandTsToOpenApi(config, outputFile, opts);\n\t\t});\n}\n\n/**\n * Action the root command.\n * @param configFile The optional configuration file.\n * @param outputFile The output file for the generation OpenApi spec.\n * @param opts The options for the command.\n */\nexport async function actionCommandTsToOpenApi(\n\tconfigFile: string,\n\toutputFile: string,\n\topts: unknown\n): Promise<void> {\n\tlet outputWorkingDir: string | undefined;\n\ttry {\n\t\tlet config: ITsToOpenApiConfig | undefined;\n\n\t\tconst fullConfigFile = path.resolve(configFile);\n\t\tconst fullOutputFile = path.resolve(outputFile);\n\t\toutputWorkingDir = path.join(path.dirname(fullOutputFile), \"working\");\n\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.labels.configJson\"),\n\t\t\tfullConfigFile\n\t\t);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.labels.outputFile\"),\n\t\t\tfullOutputFile\n\t\t);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.labels.outputWorkingDir\"),\n\t\t\toutputWorkingDir\n\t\t);\n\t\tCLIDisplay.break();\n\n\t\ttry {\n\t\t\tCLIDisplay.task(I18n.formatMessage(\"commands.ts-to-openapi.progress.loadingConfigJson\"));\n\t\t\tCLIDisplay.break();\n\n\t\t\tconfig = await CLIUtils.readJsonFile<ITsToOpenApiConfig>(fullConfigFile);\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-openapi.configFailed\", undefined, err);\n\t\t}\n\n\t\tif (Is.empty(config)) {\n\t\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-openapi.configFailed\");\n\t\t}\n\n\t\tCLIDisplay.task(I18n.formatMessage(\"commands.ts-to-openapi.progress.creatingWorkingDir\"));\n\t\tawait mkdir(outputWorkingDir, { recursive: true });\n\t\tCLIDisplay.break();\n\n\t\tawait tsToOpenApi(config ?? {}, fullOutputFile, outputWorkingDir);\n\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.done();\n\t} finally {\n\t\ttry {\n\t\t\tif (outputWorkingDir) {\n\t\t\t\tawait rm(outputWorkingDir, { recursive: true });\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n\n/**\n * Convert the TypeScript definitions to OpenAPI spec.\n * @param config The configuration for the app.\n * @param outputFile The location of the file to output the OpenAPI spec.\n * @param workingDirectory The folder the app was run from.\n */\nexport async function tsToOpenApi(\n\tconfig: ITsToOpenApiConfig,\n\toutputFile: string,\n\tworkingDirectory: string\n): Promise<void> {\n\tawait writeFile(\n\t\tpath.join(workingDirectory, \"package.json\"),\n\t\tJSON.stringify(\n\t\t\t{\n\t\t\t\tversion: \"1.0.0\",\n\t\t\t\tname: \"ts-to-openapi-working\",\n\t\t\t\tdependencies: {}\n\t\t\t},\n\t\t\tundefined,\n\t\t\t\"\\t\"\n\t\t)\n\t);\n\n\tconst openApi: IOpenApi = {\n\t\topenapi: OpenApiConstants.API_VERSION,\n\t\tinfo: {\n\t\t\ttitle: config.title,\n\t\t\tdescription: config.description,\n\t\t\tversion: config.version,\n\t\t\tlicense: {\n\t\t\t\tname: config.licenseName,\n\t\t\t\turl: config.licenseUrl\n\t\t\t}\n\t\t},\n\t\tservers: Is.arrayValue(config.servers) ? config.servers.map(s => ({ url: s })) : undefined,\n\t\ttags: [],\n\t\tpaths: {}\n\t};\n\n\tCLIDisplay.task(I18n.formatMessage(\"commands.ts-to-openapi.progress.creatingSecuritySchemas\"));\n\tCLIDisplay.break();\n\n\tconst authSecurity: { [name: string]: string[] }[] = [];\n\tconst securitySchemes: { [name: string]: IOpenApiSecurityScheme } = {};\n\n\tbuildSecurity(config, securitySchemes, authSecurity);\n\n\tconst responseCodes: string[] = [];\n\tconst inputResults: IInputResult[] = [];\n\tconst typeRoots: string[] = [];\n\tconst restRoutesAndTags = await loadPackages(config, workingDirectory, typeRoots);\n\n\tfor (const restRouteAndTag of restRoutesAndTags) {\n\t\tconst paths = await processPackageRestDetails(restRouteAndTag.restRoutes);\n\t\tinputResults.push({\n\t\t\tpaths,\n\t\t\ttags: restRouteAndTag.tags\n\t\t});\n\t}\n\n\tCLIDisplay.task(I18n.formatMessage(\"commands.ts-to-openapi.progress.generatingSchemas\"));\n\n\tconst schemas = await generateSchemas(typeRoots);\n\n\tfor (let i = 0; i < inputResults.length; i++) {\n\t\tconst result = inputResults[i];\n\t\tfor (const tag of result.tags) {\n\t\t\tconst exists = openApi.tags?.find(t => t.name === tag.name);\n\t\t\tif (!exists) {\n\t\t\t\topenApi.tags?.push(tag);\n\t\t\t}\n\t\t}\n\n\t\tfor (const inputPath of result.paths) {\n\t\t\tconst responses: ({ code?: HttpStatusCode } & IOpenApiResponse)[] = [];\n\t\t\tconst responseTypes = inputPath.responseType;\n\n\t\t\tconst pathSpecificAuthSecurity: { [name: string]: string[] }[] = [];\n\n\t\t\tif (authSecurity.length > 0 && !inputPath.skipAuth) {\n\t\t\t\tpathSpecificAuthSecurity.push(...authSecurity);\n\t\t\t}\n\n\t\t\tif (pathSpecificAuthSecurity.length > 0) {\n\t\t\t\tresponseTypes.push({\n\t\t\t\t\tstatusCode: HttpStatusCode.unauthorized,\n\t\t\t\t\ttype: \"IUnauthorizedResponse\"\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tfor (const responseType of responseTypes) {\n\t\t\t\tconst responseSchema = resolveSchema(schemas, responseType.type);\n\t\t\t\tconst responseSchemaRefName = resolveResponseSchemaRefName(schemas, responseType.type);\n\t\t\t\tconst isBinaryOctetStream = responseType.type === nameof<Uint8Array>();\n\t\t\t\tif (responseSchema || isBinaryOctetStream) {\n\t\t\t\t\tlet headers: { [id: string]: IOpenApiHeader } | undefined;\n\t\t\t\t\tlet examples: { [id: string]: IOpenApiExample } | undefined;\n\n\t\t\t\t\tif (Is.arrayValue(responseType.examples)) {\n\t\t\t\t\t\tfor (const example of responseType.examples) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tIs.object<{ headers: { [id: string]: string | string[] }; body: unknown }>(\n\t\t\t\t\t\t\t\t\texample.response\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tif (Is.objectValue(example.response.headers)) {\n\t\t\t\t\t\t\t\t\theaders ??= {};\n\t\t\t\t\t\t\t\t\tconst headersSchema = Is.object<IJsonSchema>(responseSchema?.properties?.headers)\n\t\t\t\t\t\t\t\t\t\t? responseSchema.properties.headers\n\t\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\t\t\tfor (const header in example.response.headers) {\n\t\t\t\t\t\t\t\t\t\tconst headerValue = example.response.headers[header];\n\t\t\t\t\t\t\t\t\t\tconst propertySchema = headersSchema?.properties?.[header];\n\t\t\t\t\t\t\t\t\t\tconst schemaType = Is.object<IJsonSchema>(propertySchema)\n\t\t\t\t\t\t\t\t\t\t\t? propertySchema?.type\n\t\t\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\t\t\t\theaders[header] = {\n\t\t\t\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\t\t\t\ttype: Is.string(schemaType) ? schemaType : \"string\"\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\tdescription: `e.g. ${\n\t\t\t\t\t\t\t\t\t\t\t\tIs.array(headerValue) ? headerValue.join(\",\") : headerValue\n\t\t\t\t\t\t\t\t\t\t\t}`\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (!Is.undefined(example.response.body)) {\n\t\t\t\t\t\t\t\t\texamples ??= {};\n\t\t\t\t\t\t\t\t\texamples[example.id] = {\n\t\t\t\t\t\t\t\t\t\tsummary: example.description,\n\t\t\t\t\t\t\t\t\t\tvalue: example.response.body\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst statusExample = getHttpExampleFromType(responseType.type);\n\t\t\t\t\t\tif (statusExample) {\n\t\t\t\t\t\t\texamples = {};\n\t\t\t\t\t\t\texamples.exampleResponse = {\n\t\t\t\t\t\t\t\tvalue: statusExample\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlet mimeType: string;\n\t\t\t\t\tlet schemaType: string | undefined;\n\t\t\t\t\tlet schemaFormat: string | undefined;\n\t\t\t\t\tlet schemaRef: string | undefined;\n\t\t\t\t\tlet description = responseSchema?.description ?? responseType.type;\n\n\t\t\t\t\tif (Is.stringValue(responseType.mimeType)) {\n\t\t\t\t\t\tmimeType = responseType.mimeType;\n\t\t\t\t\t} else if (isBinaryOctetStream) {\n\t\t\t\t\t\tmimeType = \"application/octet-stream\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst hasBody = Is.notEmpty(responseSchema?.properties?.body);\n\t\t\t\t\t\tif (hasBody) {\n\t\t\t\t\t\t\tmimeType = MimeTypes.Json;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmimeType = MimeTypes.PlainText;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Perform some special handling for binary octet-streams to produce a nicer spec output\n\t\t\t\t\tif (isBinaryOctetStream) {\n\t\t\t\t\t\tschemaType = \"string\";\n\t\t\t\t\t\tschemaFormat = \"binary\";\n\t\t\t\t\t\tschemaRef = undefined;\n\t\t\t\t\t\tdescription = \"Binary data\";\n\t\t\t\t\t\tif (Is.objectValue<IOpenApiExample>(examples)) {\n\t\t\t\t\t\t\tconst exampleKeys = Object.keys(examples);\n\n\t\t\t\t\t\t\tconst firstExample = examples[exampleKeys[0]];\n\t\t\t\t\t\t\tdescription = firstExample.summary ?? description;\n\t\t\t\t\t\t\tfirstExample.summary = \"Binary Data\";\n\n\t\t\t\t\t\t\tfor (const exampleKey in examples) {\n\t\t\t\t\t\t\t\texamples[exampleKey].value = \"\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tschemaRef = `#/components/schemas/${StringHelper.stripPrefix(responseSchemaRefName ?? responseType.type)}`;\n\t\t\t\t\t}\n\n\t\t\t\t\tresponses.push({\n\t\t\t\t\t\tcode: responseType.statusCode,\n\t\t\t\t\t\tdescription,\n\t\t\t\t\t\tcontent:\n\t\t\t\t\t\t\tresponseType.type === \"ICreatedResponse\" || responseType.type === \"INoContentResponse\"\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\t[mimeType]: {\n\t\t\t\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\t\t\t\t$ref: schemaRef,\n\t\t\t\t\t\t\t\t\t\t\t\ttype: schemaType,\n\t\t\t\t\t\t\t\t\t\t\t\tformat: schemaFormat\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\texamples\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\theaders\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (inputPath.responseCodes.length > 0) {\n\t\t\t\tfor (const responseCode of inputPath.responseCodes) {\n\t\t\t\t\tconst responseCodeDetails = HTTP_STATUS_CODE_MAP[responseCode];\n\t\t\t\t\t// Only include the response code if it hasn't already been\n\t\t\t\t\t// included with a specific response\n\t\t\t\t\tif (!responseTypes.some(r => r.statusCode === responseCodeDetails.code)) {\n\t\t\t\t\t\tif (!responseCodes.includes(responseCode)) {\n\t\t\t\t\t\t\tresponseCodes.push(responseCode);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet examples: { [id: string]: IOpenApiExample } | undefined;\n\n\t\t\t\t\t\tif (responseCodeDetails.example) {\n\t\t\t\t\t\t\texamples = {\n\t\t\t\t\t\t\t\texampleResponse: {\n\t\t\t\t\t\t\t\t\tvalue: responseCodeDetails.example\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst responseCodeSchema = resolveSchema(schemas, responseCodeDetails.responseType);\n\t\t\t\t\t\tif (responseCodeSchema) {\n\t\t\t\t\t\t\tconst responseCodeSchemaRefName = resolveResponseSchemaRefName(\n\t\t\t\t\t\t\t\tschemas,\n\t\t\t\t\t\t\t\tresponseCodeDetails.responseType\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tresponses.push({\n\t\t\t\t\t\t\t\tcode: responseCodeDetails.code,\n\t\t\t\t\t\t\t\tdescription: responseCodeSchema.description ?? responseCodeDetails.responseType,\n\t\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t\t[MimeTypes.Json]: {\n\t\t\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\t\t\t$ref: `#/components/schemas/${StringHelper.stripPrefix(responseCodeSchemaRefName ?? responseCodeDetails.responseType)}`\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\texamples\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst pathQueryHeaderParams: {\n\t\t\t\tname: string;\n\t\t\t\tdescription?: string;\n\t\t\t\trequired: boolean;\n\t\t\t\tin: IOpenApiParameter[\"in\"];\n\t\t\t\tschema: IJsonSchema;\n\t\t\t\tstyle?: IOpenApiParameter[\"style\"];\n\t\t\t\texample?: unknown;\n\t\t\t}[] = inputPath.pathParameters.map(p => ({\n\t\t\t\tname: p,\n\t\t\t\tdescription: \"\",\n\t\t\t\trequired: true,\n\t\t\t\tschema: {\n\t\t\t\t\ttype: \"string\"\n\t\t\t\t},\n\t\t\t\tin: \"path\",\n\t\t\t\tstyle: \"simple\"\n\t\t\t}));\n\n\t\t\tconst requestExample = inputPath.requestExamples?.[0]?.request as {\n\t\t\t\tpathParams: { [id: string]: string };\n\t\t\t\theaders: { [id: string]: string };\n\t\t\t\tquery: { [id: string]: string };\n\t\t\t};\n\n\t\t\tif (Is.object(requestExample?.pathParams)) {\n\t\t\t\tfor (const pathOrQueryParam of pathQueryHeaderParams) {\n\t\t\t\t\tif (requestExample.pathParams[pathOrQueryParam.name]) {\n\t\t\t\t\t\tpathOrQueryParam.example = requestExample.pathParams[pathOrQueryParam.name];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet requestObject: IJsonSchema | undefined = inputPath.requestType\n\t\t\t\t? resolveSchema(schemas, inputPath.requestType)\n\t\t\t\t: undefined;\n\n\t\t\tif (requestObject?.properties) {\n\t\t\t\t// If there are any properties other than body, query, pathParams and headers\n\t\t\t\t// we should throw an error as we don't know what to do with them\n\t\t\t\tconst otherKeys = Object.keys(requestObject.properties).filter(\n\t\t\t\t\tk => ![\"body\", \"query\", \"pathParams\", \"headers\"].includes(k)\n\t\t\t\t);\n\t\t\t\tif (otherKeys.length > 0) {\n\t\t\t\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-openapi.unsupportedProperties\", {\n\t\t\t\t\t\tkeys: otherKeys.join(\", \")\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// If there is a path params object convert these to params\n\t\t\t\tif (Is.object<IJsonSchema>(requestObject.properties.pathParams)) {\n\t\t\t\t\tfor (const pathParam of pathQueryHeaderParams) {\n\t\t\t\t\t\tconst prop = requestObject.properties.pathParams.properties?.[pathParam.name];\n\t\t\t\t\t\tif (Is.object<IJsonSchema>(prop)) {\n\t\t\t\t\t\t\tpathParam.description = prop.description ?? pathParam.description;\n\t\t\t\t\t\t\tpathParam.schema = {\n\t\t\t\t\t\t\t\ttype: prop.type,\n\t\t\t\t\t\t\t\tenum: prop.enum,\n\t\t\t\t\t\t\t\t$ref: prop.$ref\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tpathParam.required = true;\n\t\t\t\t\t\t\tdelete requestObject.properties.pathParams.properties?.[pathParam.name];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdelete requestObject.properties.pathParams;\n\t\t\t\t}\n\n\t\t\t\t// If there is a query object convert these to params as well\n\t\t\t\tif (Is.object<IJsonSchema>(requestObject.properties.query)) {\n\t\t\t\t\tfor (const prop in requestObject.properties.query.properties) {\n\t\t\t\t\t\tconst queryProp = requestObject.properties.query.properties[prop];\n\t\t\t\t\t\tif (Is.object<IJsonSchema>(queryProp)) {\n\t\t\t\t\t\t\tlet example: unknown;\n\t\t\t\t\t\t\tif (Is.object(requestExample.query) && requestExample.query[prop]) {\n\t\t\t\t\t\t\t\texample = requestExample.query[prop];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tpathQueryHeaderParams.push({\n\t\t\t\t\t\t\t\tname: prop,\n\t\t\t\t\t\t\t\tdescription: queryProp.description,\n\t\t\t\t\t\t\t\trequired: Boolean(requestObject.required?.includes(prop)),\n\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\ttype: queryProp.type,\n\t\t\t\t\t\t\t\t\tenum: queryProp.enum,\n\t\t\t\t\t\t\t\t\t$ref: queryProp.$ref\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tin: \"query\",\n\t\t\t\t\t\t\t\texample\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tdelete requestObject.properties.query.properties[prop];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdelete requestObject.properties.query;\n\t\t\t\t}\n\n\t\t\t\t// If there are headers in the object convert these to spec params\n\t\t\t\tif (Is.object<IJsonSchema>(requestObject.properties.headers)) {\n\t\t\t\t\tconst headerProperties = requestObject.properties.headers.properties;\n\n\t\t\t\t\tfor (const prop in headerProperties) {\n\t\t\t\t\t\tconst headerSchema = headerProperties[prop];\n\t\t\t\t\t\tif (Is.object<IJsonSchema>(headerSchema)) {\n\t\t\t\t\t\t\tlet example: unknown;\n\t\t\t\t\t\t\tif (Is.object(requestExample.headers) && requestExample.headers[prop]) {\n\t\t\t\t\t\t\t\texample = requestExample.headers[prop];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tpathQueryHeaderParams.push({\n\t\t\t\t\t\t\t\tname: prop,\n\t\t\t\t\t\t\t\tdescription: headerSchema.description,\n\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\ttype: \"string\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tin: \"header\",\n\t\t\t\t\t\t\t\tstyle: \"simple\",\n\t\t\t\t\t\t\t\texample\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdelete requestObject.properties.headers;\n\t\t\t\t}\n\n\t\t\t\t// If we have used all the properties from the object in the\n\t\t\t\t// path we should remove it.\n\t\t\t\tif (Object.keys(requestObject.properties).length === 0 && inputPath.requestType) {\n\t\t\t\t\tdeleteSchema(schemas, inputPath.requestType);\n\t\t\t\t\trequestObject = undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.restRoutes) {\n\t\t\t\tlet fullPath = StringHelper.trimTrailingSlashes(inputPath.path);\n\t\t\t\tif (fullPath.length === 0) {\n\t\t\t\t\tfullPath = \"/\";\n\t\t\t\t}\n\t\t\t\topenApi.paths ??= {};\n\t\t\t\tconst openApiPaths = openApi.paths;\n\t\t\t\topenApiPaths[fullPath] ??= {};\n\t\t\t\tconst pathItem = openApiPaths[fullPath];\n\n\t\t\t\tconst method = inputPath.method.toLowerCase() as keyof Pick<\n\t\t\t\t\tIOpenApiPathItem,\n\t\t\t\t\t\"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\"\n\t\t\t\t>;\n\n\t\t\t\tconst operation = {\n\t\t\t\t\toperationId: inputPath.operationId,\n\t\t\t\t\tsummary: inputPath.summary,\n\t\t\t\t\ttags: [inputPath.tag],\n\t\t\t\t\tparameters:\n\t\t\t\t\t\tpathQueryHeaderParams.length > 0\n\t\t\t\t\t\t\t? pathQueryHeaderParams.map(p => ({\n\t\t\t\t\t\t\t\t\tname: p.name,\n\t\t\t\t\t\t\t\t\tdescription: p.description,\n\t\t\t\t\t\t\t\t\tin: p.in,\n\t\t\t\t\t\t\t\t\trequired: p.required,\n\t\t\t\t\t\t\t\t\tschema: p.schema,\n\t\t\t\t\t\t\t\t\tstyle: p.style,\n\t\t\t\t\t\t\t\t\texample: p.example\n\t\t\t\t\t\t\t\t}))\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t} as IOpenApiPathMethod;\n\t\t\t\tpathItem[method] = operation;\n\n\t\t\t\tconst pathOperation: IOpenApiPathMethod | undefined = pathItem[method];\n\n\t\t\t\tif (pathSpecificAuthSecurity.length > 0) {\n\t\t\t\t\tif (pathOperation) {\n\t\t\t\t\t\tpathOperation.security = pathSpecificAuthSecurity;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (requestObject && inputPath.requestType) {\n\t\t\t\t\tlet examples: { [id: string]: IOpenApiExample } | undefined;\n\t\t\t\t\tif (Is.arrayValue(inputPath.requestExamples)) {\n\t\t\t\t\t\tfor (const example of inputPath.requestExamples) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tIs.object<{ body: unknown }>(example.request) &&\n\t\t\t\t\t\t\t\t!Is.undefined(example.request.body)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\texamples ??= {};\n\t\t\t\t\t\t\t\texamples[example.id] = {\n\t\t\t\t\t\t\t\t\tsummary: example.description,\n\t\t\t\t\t\t\t\t\tvalue: example.request.body\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlet requestMimeType: string;\n\t\t\t\t\tif (Is.stringValue(inputPath.requestMimeType)) {\n\t\t\t\t\t\trequestMimeType = inputPath.requestMimeType;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst requestSchema = resolveSchema(schemas, inputPath.requestType);\n\t\t\t\t\t\tconst hasBody = Is.notEmpty(requestSchema?.properties?.body);\n\t\t\t\t\t\tif (hasBody) {\n\t\t\t\t\t\t\trequestMimeType = MimeTypes.Json;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trequestMimeType = MimeTypes.PlainText;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (pathOperation) {\n\t\t\t\t\t\tpathOperation.requestBody = {\n\t\t\t\t\t\t\tdescription: requestObject.description,\n\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t[requestMimeType]: {\n\t\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\t\t$ref: `#/components/schemas/${StringHelper.stripPrefix(inputPath.requestType)}`\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\texamples\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (responses.length > 0) {\n\t\t\t\t\tconst openApiResponses: { [code: string]: IOpenApiResponse } = {};\n\t\t\t\t\tfor (const response of responses) {\n\t\t\t\t\t\tconst code = response.code;\n\t\t\t\t\t\tif (code) {\n\t\t\t\t\t\t\tdelete response.code;\n\t\t\t\t\t\t\topenApiResponses[code] ??= { description: \"\" };\n\t\t\t\t\t\t\topenApiResponses[code] = ObjectHelper.merge(openApiResponses[code], response);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (pathOperation) {\n\t\t\t\t\t\tpathOperation.responses = openApiResponses;\n\t\t\t\t\t}\n\t\t\t\t} else if (pathOperation) {\n\t\t\t\t\tpathOperation.responses = {};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tawait finaliseOutput(schemas, openApi, securitySchemes, config.externalReferences, outputFile);\n}\n\n/**\n * Finalise the schemas and output the spec.\n * @param schemas The schemas.\n * @param openApi The OpenAPI spec.\n * @param securitySchemes The security schemes.\n * @param externalReferences The external references.\n * @param outputFile The output file.\n */\nasync function finaliseOutput(\n\tschemas: { [id: string]: IJsonSchema },\n\topenApi: IOpenApi,\n\tsecuritySchemes: { [name: string]: IOpenApiSecurityScheme },\n\texternalReferences: { [type: string]: string } | undefined,\n\toutputFile: string\n): Promise<void> {\n\tCLIDisplay.break();\n\tCLIDisplay.task(I18n.formatMessage(\"commands.ts-to-openapi.progress.finalisingSchemas\"));\n\n\tconst { finalSchemas, substituteSchemas } = prepareFinalSchemas(schemas, externalReferences);\n\n\tremoveStandardSchemas(finalSchemas);\n\tapplyRefOnlySchemaSubstitutions(openApi, substituteSchemas);\n\tapplyEquivalentResponseSubstitutions(openApi, finalSchemas, substituteSchemas);\n\n\tconst sortedSchemas = buildSortedPrunedSchemas(openApi, finalSchemas);\n\n\t// Schemas that have been kept as local component schemas must not have their\n\t// $ref values in paths rewritten to external URLs.\n\tconst localSchemaNames = new Set(Object.keys(sortedSchemas));\n\trewriteExternalSchemaReferences(sortedSchemas, externalReferences);\n\trewriteExternalSchemaReferences(openApi.paths, externalReferences, localSchemaNames);\n\n\topenApi.components = {\n\t\tschemas: sortedSchemas,\n\t\tsecuritySchemes\n\t};\n\n\tvalidateComponentSchemaRefs(openApi);\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"commands.ts-to-openapi.progress.writingOutputFile\"),\n\t\toutputFile\n\t);\n\n\ttry {\n\t\tawait mkdir(path.dirname(outputFile), { recursive: true });\n\t} catch {}\n\tawait writeFile(outputFile, `${JSON.stringify(openApi, undefined, \"\\t\")}\\n`);\n}\n\n/**\n * Collect all local component schema $ref names referenced anywhere in a value.\n * @param value The value to scan.\n * @param refs The set of ref names to populate.\n */\nfunction collectComponentSchemaRefs(value: unknown, refs: Set<string>): void {\n\tif (Is.array(value)) {\n\t\tfor (const item of value) {\n\t\t\tcollectComponentSchemaRefs(item, refs);\n\t\t}\n\t\treturn;\n\t}\n\tif (Is.object(value)) {\n\t\tif (Is.string(value.$ref) && value.$ref.startsWith(\"#/components/schemas/\")) {\n\t\t\trefs.add(value.$ref.slice(\"#/components/schemas/\".length));\n\t\t}\n\t\tfor (const child of Object.values(value)) {\n\t\t\tcollectComponentSchemaRefs(child, refs);\n\t\t}\n\t}\n}\n\n/**\n * Validate that every local component schema $ref in paths resolves to a defined schema.\n * @param openApi The OpenAPI spec to validate.\n * @throws GeneralError if any local component schema $ref does not resolve to a defined schema.\n */\nfunction validateComponentSchemaRefs(openApi: IOpenApi): void {\n\tconst refs = new Set<string>();\n\tcollectComponentSchemaRefs(openApi.paths, refs);\n\tconst schemas = openApi.components?.schemas ?? {};\n\tconst missing = [...refs].filter(name => !(name in schemas));\n\tif (missing.length > 0) {\n\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-openapi.unresolvedComponentRefs\", {\n\t\t\trefs: missing.join(\", \")\n\t\t});\n\t}\n}\n\n/**\n * Prepare schemas for final component output and collect schema substitutions.\n * @param schemas The schema map.\n * @param externalReferences The external reference mappings.\n * @returns The prepared schemas and substitutions.\n */\nfunction prepareFinalSchemas(\n\tschemas: { [id: string]: IJsonSchema },\n\texternalReferences: { [type: string]: string } | undefined\n): {\n\tfinalSchemas: { [id: string]: IJsonSchema };\n\tsubstituteSchemas: { from: string; to: string }[];\n} {\n\tconst substituteSchemas: { from: string; to: string }[] = [];\n\tconst finalSchemas: { [id: string]: IJsonSchema } = {};\n\n\tfor (const schema in schemas) {\n\t\tconst props = schemas[schema].properties;\n\t\tlet skipSchema = false;\n\t\tlet isLocalWrapper = false;\n\n\t\tif (Is.object<{ [id: string]: IJsonSchema | boolean }>(props)) {\n\t\t\ttidySchemaProperties(props, true);\n\n\t\t\t// Any request/response objects should be added to the final schemas\n\t\t\t// but only the body property, if there is no body then we don't\n\t\t\t// need to add it to the schemas\n\t\t\tif (schema.endsWith(\"Response\") || schema.endsWith(\"Request\")) {\n\t\t\t\tif (Is.object<IJsonSchema>(props.body)) {\n\t\t\t\t\tschemas[schema] = props.body;\n\t\t\t\t\t// Body was extracted from a local API wrapper type; external reference\n\t\t\t\t\t// patterns must not override this — the schema stays in components.\n\t\t\t\t\tisLocalWrapper = true;\n\t\t\t\t} else {\n\t\t\t\t\t// Body is absent or a boolean schema (true = any, false = never).\n\t\t\t\t\t// Emit an empty schema {} to prevent dangling $refs in paths that\n\t\t\t\t\t// reference this type, while still keeping it in components.\n\t\t\t\t\tschemas[schema] = {};\n\t\t\t\t\tisLocalWrapper = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// If the schema is external then remove it from the final schemas.\n\t\t// Local API wrapper types (Request/Response schemas whose body was extracted)\n\t\t// are always kept as local component schemas regardless of external ref patterns.\n\t\tif (!isLocalWrapper && resolveExternalReference(schema, externalReferences)) {\n\t\t\tskipSchema = true;\n\t\t}\n\n\t\tif (!skipSchema) {\n\t\t\t// If the final schema has no properties and is just a ref to another object type\n\t\t\t// then replace the references with that of the referenced type.\n\t\t\tconst ref = schemas[schema].$ref;\n\t\t\tif (!Is.arrayValue(schemas[schema].properties) && Is.stringValue(ref)) {\n\t\t\t\tsubstituteSchemas.push({ from: schema, to: ref });\n\t\t\t} else {\n\t\t\t\tfinalSchemas[StringHelper.stripPrefix(schema)] = schemas[schema];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tfinalSchemas,\n\t\tsubstituteSchemas\n\t};\n}\n\n/**\n * Remove standard schemas that should not appear in the final OpenAPI output.\n * @param finalSchemas The final schemas map.\n */\nfunction removeStandardSchemas(finalSchemas: { [id: string]: IJsonSchema }): void {\n\tconst removeTypes = [\"HttpStatusCode\", ...Constants.ARRAY_NUMBER_TYPE_NAMES];\n\tfor (const type of removeTypes) {\n\t\tdelete finalSchemas[type];\n\t}\n}\n\n/**\n * Apply substitutions for ref-only wrapper schemas to path refs.\n * @param openApi The OpenAPI document.\n * @param substituteSchemas The collected schema substitutions.\n */\nfunction applyRefOnlySchemaSubstitutions(\n\topenApi: IOpenApi,\n\tsubstituteSchemas: { from: string; to: string }[]\n): void {\n\tconst refOnlySubstitutions: { from: string; to: string }[] = [];\n\tconst componentsPrefix = \"#/components/schemas/\";\n\n\tfor (const substitution of substituteSchemas) {\n\t\tif (substitution.to.startsWith(componentsPrefix)) {\n\t\t\trefOnlySubstitutions.push({\n\t\t\t\tfrom: StringHelper.stripPrefix(substitution.from),\n\t\t\t\tto: StringHelper.stripPrefix(substitution.to.slice(componentsPrefix.length))\n\t\t\t});\n\t\t}\n\t}\n\n\tif (refOnlySubstitutions.length > 0) {\n\t\trewriteSchemaRefs(openApi.paths, refOnlySubstitutions);\n\t}\n}\n\n/**\n * Apply equivalent-response schema substitutions to paths and final schemas.\n * @param openApi The OpenAPI document.\n * @param finalSchemas The final schemas map.\n * @param substituteSchemas The collected schema substitutions.\n */\nfunction applyEquivalentResponseSubstitutions(\n\topenApi: IOpenApi,\n\tfinalSchemas: { [id: string]: IJsonSchema },\n\tsubstituteSchemas: { from: string; to: string }[]\n): void {\n\tconst equivalentResponseSchemaSubstitutions =\n\t\tfindEquivalentResponseSchemaSubstitutions(finalSchemas);\n\n\tif (equivalentResponseSchemaSubstitutions.length > 0) {\n\t\trewriteSchemaRefs(openApi.paths, equivalentResponseSchemaSubstitutions);\n\t\trewriteSchemaRefs(finalSchemas, equivalentResponseSchemaSubstitutions);\n\n\t\tfor (const substitution of equivalentResponseSchemaSubstitutions) {\n\t\t\tdelete finalSchemas[substitution.from];\n\t\t\tsubstituteSchemas.push({\n\t\t\t\tfrom: substitution.from,\n\t\t\t\tto: `#/components/schemas/${substitution.to}`\n\t\t\t});\n\t\t}\n\t}\n}\n\n/**\n * Build sorted and tidied schemas from the current OpenAPI references.\n * @param openApi The OpenAPI document.\n * @param finalSchemas The candidate schemas.\n * @returns The sorted schema map.\n */\nfunction buildSortedPrunedSchemas(\n\topenApi: IOpenApi,\n\tfinalSchemas: { [id: string]: IJsonSchema }\n): { [id: string]: IJsonSchema } {\n\tconst prunedSchemas = pruneToReferencedSchemas(openApi, finalSchemas);\n\tconst prunedSchemaKeys = Object.keys(prunedSchemas);\n\tprunedSchemaKeys.sort();\n\n\tconst sortedSchemas: { [id: string]: IJsonSchema } = {};\n\tfor (const key of prunedSchemaKeys) {\n\t\ttidySchemaProperties(prunedSchemas[key], false);\n\t\tsortedSchemas[key] = prunedSchemas[key];\n\t}\n\n\treturn sortedSchemas;\n}\n\n/**\n * Prune schemas to only those referenced by the OpenAPI document and their transitive dependencies.\n * @param openApi The generated OpenAPI document.\n * @param schemas The candidate schemas.\n * @returns The pruned schemas.\n */\nfunction pruneToReferencedSchemas(\n\topenApi: IOpenApi,\n\tschemas: { [id: string]: IJsonSchema }\n): { [id: string]: IJsonSchema } {\n\tconst referencedSchemaNames = new Set<string>();\n\tconst pendingSchemaNames: string[] = [];\n\n\tconst enqueueSchemaRef = (ref: string): void => {\n\t\tconst schemaName = normaliseSchemaRefName(ref, schemas);\n\t\tif (schemaName && !referencedSchemaNames.has(schemaName)) {\n\t\t\treferencedSchemaNames.add(schemaName);\n\t\t\tpendingSchemaNames.push(schemaName);\n\t\t}\n\t};\n\n\tcollectSchemaRefs(openApi.paths, enqueueSchemaRef);\n\n\twhile (pendingSchemaNames.length > 0) {\n\t\tconst schemaName = pendingSchemaNames.pop();\n\t\tif (schemaName) {\n\t\t\tcollectSchemaRefs(schemas[schemaName], enqueueSchemaRef);\n\t\t}\n\t}\n\n\tconst prunedSchemas: { [id: string]: IJsonSchema } = {};\n\tfor (const schemaName of referencedSchemaNames) {\n\t\tprunedSchemas[schemaName] = schemas[schemaName];\n\t}\n\n\treturn prunedSchemas;\n}\n\n/**\n * Find response wrapper schemas that are structurally identical to a canonical non-response schema.\n * @param schemas The candidate component schemas.\n * @returns The schema substitutions.\n */\nfunction findEquivalentResponseSchemaSubstitutions(schemas: {\n\t[id: string]: IJsonSchema;\n}): { from: string; to: string }[] {\n\tconst substitutions: { from: string; to: string }[] = [];\n\tconst schemaEntries = Object.entries(schemas);\n\n\tfor (const [schemaName, schema] of schemaEntries) {\n\t\tif (schemaName.endsWith(\"Response\")) {\n\t\t\tconst canonicalEntry = schemaEntries\n\t\t\t\t.filter(([candidateName, candidateSchema]) => {\n\t\t\t\t\tif (\n\t\t\t\t\t\tcandidateName === schemaName ||\n\t\t\t\t\t\tcandidateName.endsWith(\"Response\") ||\n\t\t\t\t\t\tStringHelper.stripPrefix(candidateName) !== \"Error\"\n\t\t\t\t\t) {\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\n\t\t\t\t\treturn JsonHelper.canonicalize(candidateSchema) === JsonHelper.canonicalize(schema);\n\t\t\t\t})\n\t\t\t\t.sort(([candidateNameA], [candidateNameB]) =>\n\t\t\t\t\tcandidateNameA.localeCompare(candidateNameB)\n\t\t\t\t)[0];\n\n\t\t\tif (canonicalEntry) {\n\t\t\t\tsubstitutions.push({\n\t\t\t\t\tfrom: schemaName,\n\t\t\t\t\tto: canonicalEntry[0]\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\treturn substitutions;\n}\n\n/**\n * Rewrite schema refs using the provided substitutions.\n * @param value The value to rewrite.\n * @param substitutions The schema substitutions.\n */\nfunction rewriteSchemaRefs(value: unknown, substitutions: { from: string; to: string }[]): void {\n\tif (Is.array(value)) {\n\t\tfor (const item of value) {\n\t\t\trewriteSchemaRefs(item, substitutions);\n\t\t}\n\t\treturn;\n\t}\n\n\tif (Is.object<{ $ref?: unknown }>(value)) {\n\t\tif (Is.stringValue(value.$ref)) {\n\t\t\tfor (const substitution of substitutions) {\n\t\t\t\tif (value.$ref === `#/components/schemas/${substitution.from}`) {\n\t\t\t\t\tvalue.$ref = `#/components/schemas/${substitution.to}`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const objectValue of Object.values(value)) {\n\t\t\trewriteSchemaRefs(objectValue, substitutions);\n\t\t}\n\t}\n}\n\n/**\n * Collect schema references from a value.\n * @param value The value to inspect.\n * @param onRef The callback for each schema ref.\n */\nfunction collectSchemaRefs(value: unknown, onRef: (ref: string) => void): void {\n\tif (Is.array(value)) {\n\t\tfor (const item of value) {\n\t\t\tcollectSchemaRefs(item, onRef);\n\t\t}\n\t\treturn;\n\t}\n\n\tif (Is.object<{ $ref?: unknown }>(value)) {\n\t\tif (Is.stringValue(value.$ref)) {\n\t\t\tonRef(value.$ref);\n\t\t}\n\n\t\tfor (const objectValue of Object.values(value)) {\n\t\t\tcollectSchemaRefs(objectValue, onRef);\n\t\t}\n\t}\n}\n\n/**\n * Normalise a schema ref to a component schema name.\n * @param ref The schema ref.\n * @param schemas The available schemas.\n * @returns The normalised schema name if it exists.\n */\nfunction normaliseSchemaRefName(\n\tref: string,\n\tschemas: { [id: string]: IJsonSchema }\n): string | undefined {\n\tconst refParts = ref.split(\"/\");\n\tconst rawName = refParts[refParts.length - 1];\n\tif (!Is.stringValue(rawName)) {\n\t\treturn undefined;\n\t}\n\n\tconst schemaName = StringHelper.stripPrefix(rawName);\n\n\treturn schemas[schemaName] ? schemaName : undefined;\n}\n\n/**\n * Rewrite component schema refs to external refs when configured.\n * @param value The object to walk and rewrite in place.\n * @param externalReferences The external reference mappings.\n * @param preservedSchemas An optional set of local component schema names whose refs must not be rewritten.\n */\nfunction rewriteExternalSchemaReferences(\n\tvalue: unknown,\n\texternalReferences: { [type: string]: string } | undefined,\n\tpreservedSchemas?: Set<string>\n): void {\n\tif (!Is.object(externalReferences)) {\n\t\treturn;\n\t}\n\n\tif (Is.array(value)) {\n\t\tfor (const item of value) {\n\t\t\trewriteExternalSchemaReferences(item, externalReferences, preservedSchemas);\n\t\t}\n\t\treturn;\n\t}\n\n\tif (Is.object<{ $ref?: unknown }>(value)) {\n\t\tif (Is.stringValue(value.$ref)) {\n\t\t\tconst schemaPrefix = \"#/components/schemas/\";\n\t\t\tif (value.$ref.startsWith(schemaPrefix)) {\n\t\t\t\tconst schemaName = value.$ref.slice(schemaPrefix.length);\n\t\t\t\tif (!preservedSchemas?.has(schemaName)) {\n\t\t\t\t\tconst externalReference = resolveExternalReference(schemaName, externalReferences);\n\t\t\t\t\tif (Is.stringValue(externalReference)) {\n\t\t\t\t\t\tvalue.$ref = externalReference;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const objectValue of Object.values(value)) {\n\t\t\trewriteExternalSchemaReferences(objectValue, externalReferences, preservedSchemas);\n\t\t}\n\t}\n}\n\n/**\n * Resolve a schema name to an external reference URL if configured.\n * @param schemaName The schema name.\n * @param externalReferences The external reference mappings.\n * @returns The external reference URL if matched.\n */\nfunction resolveExternalReference(\n\tschemaName: string,\n\texternalReferences: { [type: string]: string } | undefined\n): string | undefined {\n\tif (!Is.object(externalReferences)) {\n\t\treturn undefined;\n\t}\n\n\tconst schemaCandidates = [schemaName, StringHelper.stripPrefix(schemaName)].filter(candidate =>\n\t\tIs.stringValue(candidate)\n\t);\n\n\tfor (const external in externalReferences) {\n\t\tconst re = new RegExp(`^${external}$`);\n\t\tfor (const candidate of schemaCandidates) {\n\t\t\tif (re.test(candidate)) {\n\t\t\t\treturn candidate.replace(re, externalReferences[external]);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Build the security schemas from the config.\n * @param config The configuration.\n * @param securitySchemes The security schemes.\n * @param authSecurity The auth security.\n */\nfunction buildSecurity(\n\tconfig: ITsToOpenApiConfig,\n\tsecuritySchemes: { [name: string]: IOpenApiSecurityScheme },\n\tauthSecurity: { [name: string]: string[] }[]\n): void {\n\tif (Is.arrayValue(config.authMethods)) {\n\t\tfor (const authMethod of config.authMethods) {\n\t\t\tconst security: { [name: string]: string[] } = {};\n\t\t\tif (authMethod === \"basic\") {\n\t\t\t\tsecuritySchemes.basicAuthScheme = {\n\t\t\t\t\ttype: \"http\",\n\t\t\t\t\tscheme: \"basic\"\n\t\t\t\t};\n\t\t\t\tsecurity.basicAuthScheme = [];\n\t\t\t} else if (authMethod === \"jwtBearer\") {\n\t\t\t\tsecuritySchemes.jwtBearerAuthScheme = {\n\t\t\t\t\ttype: \"http\",\n\t\t\t\t\tscheme: \"bearer\",\n\t\t\t\t\tbearerFormat: \"JWT\"\n\t\t\t\t};\n\t\t\t\tsecurity.jwtBearerAuthScheme = [];\n\t\t\t} else if (authMethod === \"jwtCookie\") {\n\t\t\t\tsecuritySchemes.jwtCookieAuthScheme = {\n\t\t\t\t\ttype: \"apiKey\",\n\t\t\t\t\tin: \"cookie\",\n\t\t\t\t\tname: \"auth_token\"\n\t\t\t\t};\n\t\t\t\tsecurity.jwtCookieAuthScheme = [];\n\t\t\t}\n\t\t\tauthSecurity.push(security);\n\t\t}\n\t}\n}\n\n/**\n * Process the REST details for a package.\n * @param baseDir The base directory other locations are relative to.\n * @param prefix The prefix.\n * @param restDetails The package details.\n * @returns The paths and schemas for the input.\n * @internal\n */\nasync function processPackageRestDetails(restRoutes: IRestRoute[]): Promise<IInputPath[]> {\n\tconst paths: IInputPath[] = [];\n\n\tCLIDisplay.task(I18n.formatMessage(\"commands.ts-to-openapi.progress.processingRoutes\"));\n\n\tfor (const route of restRoutes) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.labels.route\"),\n\t\t\t`${route.operationId} ${route.method} ${route.path}`,\n\t\t\t1\n\t\t);\n\t\tconst pathParameters: string[] = [];\n\n\t\tconst pathPaths = route.path.split(\"/\");\n\t\tconst finalPathParts = [];\n\t\tfor (const part of pathPaths) {\n\t\t\tif (part.startsWith(\":\")) {\n\t\t\t\tfinalPathParts.push(`{${part.slice(1)}}`);\n\t\t\t\tpathParameters.push(part.slice(1));\n\t\t\t} else {\n\t\t\t\tfinalPathParts.push(part);\n\t\t\t}\n\t\t}\n\n\t\tconst responseType: {\n\t\t\tstatusCode: HttpStatusCode;\n\t\t\ttype: string;\n\t\t\tmimeType?: string;\n\t\t\tdescription?: string;\n\t\t\texamples?: {\n\t\t\t\tid: string;\n\t\t\t\tdescription?: string;\n\t\t\t\tresponse: unknown;\n\t\t\t}[];\n\t\t}[] = [];\n\n\t\t// If there is no response type automatically add a success\n\t\tif (Is.empty(route.responseType)) {\n\t\t\t// But only if we haven't got a response already for different content type\n\t\t\tif (responseType.length === 0) {\n\t\t\t\tresponseType.push({\n\t\t\t\t\ttype: \"IOkResponse\",\n\t\t\t\t\tstatusCode: HttpStatusCode.ok\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (Is.array(route.responseType)) {\n\t\t\t// Find the response codes for the response types\n\t\t\tfor (const rt of route.responseType) {\n\t\t\t\tconst responseCode = getHttpStatusCodeFromType(rt.type);\n\t\t\t\tresponseType.push({\n\t\t\t\t\t...rt,\n\t\t\t\t\tmimeType: rt.mimeType,\n\t\t\t\t\tstatusCode: responseCode,\n\t\t\t\t\texamples: rt.examples\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst inputPath: IInputPath = {\n\t\t\tpath: finalPathParts.join(\"/\"),\n\t\t\tmethod: route.method,\n\t\t\tpathParameters,\n\t\t\toperationId: route.operationId,\n\t\t\ttag: route.tag,\n\t\t\tsummary: route.summary,\n\t\t\trequestType: route.requestType?.type,\n\t\t\trequestMimeType: route.requestType?.mimeType,\n\t\t\trequestExamples: route.requestType?.examples,\n\t\t\tresponseType,\n\t\t\tresponseCodes: [\"badRequest\", \"internalServerError\"],\n\t\t\tskipAuth: route.skipAuth ?? false\n\t\t};\n\n\t\tconst handlerSource = route.handler.toString();\n\n\t\tlet match;\n\t\tconst re = /httpstatuscode\\.([_a-z]*)/gi;\n\t\twhile ((match = re.exec(handlerSource)) !== null) {\n\t\t\tinputPath.responseCodes.push(match[1]);\n\t\t}\n\n\t\tpaths.push(inputPath);\n\t}\n\n\tCLIDisplay.break();\n\n\treturn paths;\n}\n\n/**\n * Generate schemas for the models.\n * @param modelDirWildcards The filenames for all the models.\n * @returns The generated schemas.\n * @internal\n */\nasync function generateSchemas(modelDirWildcards: string[]): Promise<{\n\t[id: string]: IJsonSchema;\n}> {\n\tconst allSchemas: { [id: string]: IJsonSchema } = {};\n\tconst typeScriptToSchema = new TypeScriptToSchema();\n\tconst packageSchemas: { [id: string]: { [id: string]: IJsonSchema } } = {};\n\n\tfor (const files of modelDirWildcards) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.progress.models\"),\n\t\t\tfiles.replace(/\\\\/g, \"/\"),\n\t\t\t1\n\t\t);\n\n\t\tconst schemas = await typeScriptToSchema.generateSchema(\n\t\t\t\"#/components/schemas/\",\n\t\t\t\"@twin.org/ts-to-openapi\",\n\t\t\tpackageSchemas,\n\t\t\tfiles\n\t\t);\n\n\t\tfor (const schemaName in schemas) {\n\t\t\tallSchemas[schemaName] ??= schemas[schemaName];\n\t\t}\n\t}\n\n\treturn allSchemas;\n}\n\n/**\n * Resolve a schema by its raw or stripped interface type name.\n * @param schemas The schema map.\n * @param typeName The type name.\n * @returns The resolved schema if present.\n */\nfunction resolveSchema(\n\tschemas: { [id: string]: IJsonSchema },\n\ttypeName: string | undefined\n): IJsonSchema | undefined {\n\tif (!Is.stringValue(typeName)) {\n\t\treturn undefined;\n\t}\n\n\treturn schemas[typeName] ?? schemas[StringHelper.stripPrefix(typeName)];\n}\n\n/**\n * Resolve a response type to the schema component name that should be referenced in OpenAPI.\n * @param schemas The schema map.\n * @param typeName The response type name.\n * @returns The canonical component name if one can be determined.\n */\nfunction resolveResponseSchemaRefName(\n\tschemas: { [id: string]: IJsonSchema },\n\ttypeName: string | undefined\n): string | undefined {\n\tif (!Is.stringValue(typeName)) {\n\t\treturn undefined;\n\t}\n\n\tif (isErrorResponseType(typeName) && resolveSchema(schemas, \"Error\")) {\n\t\treturn \"Error\";\n\t}\n\n\treturn typeName;\n}\n\n/**\n * Determine whether a response type should be canonicalised to the shared Error schema.\n * @param typeName The response type name.\n * @returns True if the type represents an error response wrapper.\n */\nfunction isErrorResponseType(typeName: string): boolean {\n\tconst strippedTypeName = StringHelper.stripPrefix(typeName);\n\n\tfor (const responseDetails of Object.values(HTTP_STATUS_CODE_MAP)) {\n\t\tif (responseDetails.responseType === typeName) {\n\t\t\treturn responseDetails.code >= HttpStatusCode.badRequest;\n\t\t}\n\t}\n\n\treturn /(?:^Bad.*Response$|^UnauthorizedResponse$|^ForbiddenResponse$|^NotFoundResponse$|^ConflictResponse$|^Unprocessable.*Response$|ErrorResponse$)/u.test(\n\t\tstrippedTypeName\n\t);\n}\n\n/**\n * Delete a schema by its raw or stripped interface type name.\n * @param schemas The schema map.\n * @param typeName The type name.\n */\nfunction deleteSchema(schemas: { [id: string]: IJsonSchema }, typeName: string | undefined): void {\n\tif (!Is.stringValue(typeName)) {\n\t\treturn;\n\t}\n\n\tdelete schemas[typeName];\n\tdelete schemas[StringHelper.stripPrefix(typeName)];\n}\n\n/**\n * Tidy up schemas for OpenAPI context.\n * Removes unsupported schema keywords and normalises nested property schemas.\n * @param value The schema value to tidy.\n * @internal\n */\nfunction tidySchemaProperties(value: unknown, removeRefDescriptions: boolean): void {\n\tif (Is.array(value)) {\n\t\tfor (const item of value) {\n\t\t\ttidySchemaProperties(item, removeRefDescriptions);\n\t\t}\n\t\treturn;\n\t}\n\n\tif (Is.object<{ [id: string]: unknown; $ref?: unknown; description?: unknown }>(value)) {\n\t\tdelete value.$schema;\n\t\tdelete value.$id;\n\t\tdelete value.$comment;\n\n\t\tif (removeRefDescriptions) {\n\t\t\tfor (const prop of Object.keys(value)) {\n\t\t\t\tconst schemaProperty = value[prop];\n\t\t\t\tif (Is.object<IJsonSchema>(schemaProperty)) {\n\t\t\t\t\t// For OpenAPI we don't include a description for items that have refs.\n\t\t\t\t\tif (schemaProperty.$ref) {\n\t\t\t\t\t\tdelete schemaProperty.description;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (schemaProperty.properties) {\n\t\t\t\t\t\ttidySchemaProperties(schemaProperty.properties, true);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tschemaProperty.items &&\n\t\t\t\t\t\tIs.object<IJsonSchema>(schemaProperty.items) &&\n\t\t\t\t\t\tIs.object<IJsonSchema>(schemaProperty.items.properties)\n\t\t\t\t\t) {\n\t\t\t\t\t\ttidySchemaProperties(schemaProperty.items.properties, true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const objectValue of Object.values(value)) {\n\t\t\t\ttidySchemaProperties(objectValue, false);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Load the packages from config and get the routes and tags from them.\n * @param tsToOpenApiConfig The app config.\n * @param outputWorkingDir The working directory.\n * @param typeRoots The model roots.\n * @returns The routes and tags for each package.\n * @internal\n */\nasync function loadPackages(\n\ttsToOpenApiConfig: ITsToOpenApiConfig,\n\toutputWorkingDir: string,\n\ttypeRoots: string[]\n): Promise<\n\t{\n\t\trestRoutes: IRestRoute[];\n\t\ttags: ITag[];\n\t}[]\n> {\n\tconst restRoutes: {\n\t\trestRoutes: IRestRoute[];\n\t\ttags: ITag[];\n\t}[] = [];\n\n\tlet localNpmRoot = await CLIUtils.findNpmRoot(process.cwd());\n\tlocalNpmRoot = localNpmRoot.replace(/[/\\\\]node_modules/, \"\");\n\n\tconst packages: string[] = [];\n\tconst localPackages: string[] = [];\n\n\tfor (const configRestRoutes of tsToOpenApiConfig.restRoutes) {\n\t\tif (Is.stringValue(configRestRoutes.package)) {\n\t\t\tconst existsLocally = await CLIUtils.dirExists(\n\t\t\t\tpath.join(localNpmRoot, \"node_modules\", configRestRoutes.package)\n\t\t\t);\n\t\t\tif (existsLocally) {\n\t\t\t\tif (!localPackages.includes(configRestRoutes.package)) {\n\t\t\t\t\tlocalPackages.push(configRestRoutes.package);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst version = configRestRoutes.version ?? \"latest\";\n\t\t\t\tconst newPackage = `${configRestRoutes.package}@${version}`;\n\t\t\t\tif (!packages.includes(newPackage)) {\n\t\t\t\t\tpackages.push(`${configRestRoutes.package}@${version}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (packages.length > 0) {\n\t\tCLIDisplay.task(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.progress.installingNpmPackages\"),\n\t\t\tpackages.join(\" \")\n\t\t);\n\t\tawait CLIUtils.runShellCmd(\"npm\", [\"install\", ...packages], outputWorkingDir);\n\t\tCLIDisplay.break();\n\t}\n\n\tfor (const configRestRoutes of tsToOpenApiConfig.restRoutes) {\n\t\tconst typeFolders = [\"models\", \"errors\"];\n\t\tconst packageName = configRestRoutes.package;\n\t\tconst packageRoot = configRestRoutes.packageRoot;\n\t\tif (!Is.stringValue(packageName) && !Is.stringValue(packageRoot)) {\n\t\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-openapi.packageNameOrRootMissing\");\n\t\t}\n\n\t\tlet rootFolder;\n\t\tlet npmResolveFolder;\n\t\tif (Is.stringValue(packageName)) {\n\t\t\tif (localPackages.includes(packageName)) {\n\t\t\t\tnpmResolveFolder = localNpmRoot;\n\t\t\t\trootFolder = path.join(localNpmRoot, \"node_modules\", packageName);\n\t\t\t} else {\n\t\t\t\tnpmResolveFolder = outputWorkingDir;\n\t\t\t\trootFolder = path.join(outputWorkingDir, \"node_modules\", packageName);\n\n\t\t\t\tconst downloadedPackageExists = await CLIUtils.dirExists(rootFolder);\n\t\t\t\tif (!downloadedPackageExists) {\n\t\t\t\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-openapi.packageResolutionFailed\", {\n\t\t\t\t\t\tpackage: packageName,\n\t\t\t\t\t\tworkingDir: outputWorkingDir\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\trootFolder = path.resolve(packageRoot ?? \"\");\n\t\t\tnpmResolveFolder = rootFolder;\n\t\t}\n\n\t\tconst pkgJson = (await CLIUtils.readJsonFile<IPackageJson>(\n\t\t\tpath.join(rootFolder, \"package.json\")\n\t\t)) ?? { name: \"\" };\n\t\tCLIDisplay.task(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.progress.processingPackage\"),\n\t\t\tpkgJson.name\n\t\t);\n\n\t\tfor (const typeFolder of typeFolders) {\n\t\t\tconst typesDir = path.join(rootFolder, \"dist\", \"types\", typeFolder);\n\t\t\tif (await CLIUtils.dirExists(typesDir)) {\n\t\t\t\tconst newRoot = path.join(typesDir, \"**/*.ts\");\n\t\t\t\tif (!typeRoots.includes(newRoot)) {\n\t\t\t\t\ttypeRoots.push(newRoot);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (pkgJson.dependencies) {\n\t\t\tconst nodeModulesFolder = await CLIUtils.findNpmRoot(npmResolveFolder);\n\t\t\tfor (const dep in pkgJson.dependencies) {\n\t\t\t\tif (dep.startsWith(\"@twin.org\")) {\n\t\t\t\t\tfor (const typeFolder of typeFolders) {\n\t\t\t\t\t\tconst typesDirDep = path.join(nodeModulesFolder, dep, \"dist\", \"types\", typeFolder);\n\t\t\t\t\t\tif (await CLIUtils.dirExists(typesDirDep)) {\n\t\t\t\t\t\t\tconst newRoot = path.join(typesDirDep, \"**/*.ts\");\n\t\t\t\t\t\t\tif (!typeRoots.includes(newRoot)) {\n\t\t\t\t\t\t\t\ttypeRoots.push(newRoot);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tCLIDisplay.task(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.progress.importingModule\"),\n\t\t\tpkgJson.name\n\t\t);\n\n\t\tconst pkg = await import(pathToFileURL(path.join(rootFolder, \"dist/es/index.js\")).href);\n\n\t\tif (!Is.array(pkg.restEntryPoints)) {\n\t\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-openapi.missingRestRoutesEntryPoints\", {\n\t\t\t\tmethod: \"restEntryPoints\",\n\t\t\t\tpackage: pkgJson.name\n\t\t\t});\n\t\t}\n\n\t\tconst packageEntryPoints: IRestRouteEntryPoint[] = pkg.restEntryPoints;\n\n\t\tconst entryPoints: ITsToOpenApiConfigEntryPoint[] =\n\t\t\tconfigRestRoutes.entryPoints ?? packageEntryPoints.map(e => ({ name: e.name }));\n\n\t\tfor (const entryPoint of entryPoints) {\n\t\t\tconst packageEntryPoint = packageEntryPoints.find(e => e.name === entryPoint.name);\n\n\t\t\tif (!Is.object<IRestRouteEntryPoint>(packageEntryPoint)) {\n\t\t\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-openapi.missingRestRoutesEntryPoint\", {\n\t\t\t\t\tentryPoint: entryPoint.name,\n\t\t\t\t\tpackage: pkgJson.name\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlet baseRouteName = StringHelper.trimTrailingSlashes(\n\t\t\t\tentryPoint.baseRoutePath ?? packageEntryPoint.defaultBaseRoute ?? \"\"\n\t\t\t);\n\n\t\t\tif (baseRouteName.length > 0) {\n\t\t\t\tbaseRouteName = `/${StringHelper.trimLeadingSlashes(baseRouteName)}`;\n\t\t\t}\n\n\t\t\tlet routes: IRestRoute[] = packageEntryPoint.generateRoutes(baseRouteName, \"dummy-service\");\n\n\t\t\troutes = routes.filter(r => !(r.excludeFromSpec ?? false));\n\n\t\t\tif (Is.stringValue(entryPoint.operationIdDistinguisher)) {\n\t\t\t\tfor (const route of routes) {\n\t\t\t\t\troute.operationId = `${route.operationId}${entryPoint.operationIdDistinguisher}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\trestRoutes.push({\n\t\t\t\trestRoutes: routes,\n\t\t\t\ttags: packageEntryPoint.tags\n\t\t\t});\n\t\t}\n\n\t\tCLIDisplay.break();\n\t}\n\n\treturn restRoutes;\n}\n"]}
1
+ {"version":3,"file":"tsToOpenApi.js","sourceRoot":"","sources":["../../../src/commands/tsToOpenApi.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,IAAI,EA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Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { mkdir, rm, writeFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\nimport { CLIDisplay, CLIUtils } from \"@twin.org/cli-core\";\nimport { GeneralError, I18n, Is, ObjectHelper, StringHelper } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { TypeScriptToSchema, Constants } from \"@twin.org/tools-core\";\nimport {\n\ttype IJsonSchema,\n\ttype IOpenApi,\n\ttype IOpenApiExample,\n\ttype IOpenApiHeader,\n\ttype IOpenApiParameter,\n\ttype IOpenApiPathItem,\n\ttype IOpenApiPathMethod,\n\ttype IOpenApiResponse,\n\ttype IOpenApiSecurityScheme,\n\ttype IPackageJson,\n\tOpenApiConstants\n} from \"@twin.org/tools-models\";\nimport { HttpStatusCode, MimeTypes } from \"@twin.org/web\";\nimport type { Command } from \"commander\";\nimport {\n\tHTTP_STATUS_CODE_MAP,\n\tgetHttpExampleFromType,\n\tgetHttpStatusCodeFromType\n} from \"./httpStatusCodeMap.js\";\nimport type { IInputPath } from \"../models/IInputPath.js\";\nimport type { IInputResult } from \"../models/IInputResult.js\";\nimport type { IRestRoute } from \"../models/IRestRoute.js\";\nimport type { IRestRouteEntryPoint } from \"../models/IRestRouteEntryPoints.js\";\nimport type { ITag } from \"../models/ITag.js\";\nimport type { ITsToOpenApiConfig } from \"../models/ITsToOpenApiConfig.js\";\nimport type { ITsToOpenApiConfigEntryPoint } from \"../models/ITsToOpenApiConfigEntryPoint.js\";\n\n/**\n * Build the root command to be consumed by the CLI.\n * @param program The command to build on.\n */\nexport function buildCommandTsToOpenApi(program: Command): void {\n\tprogram\n\t\t.argument(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.options.config.param\"),\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.options.config.description\")\n\t\t)\n\t\t.argument(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.options.output-file.param\"),\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.options.output-file.description\")\n\t\t)\n\t\t.action(async (config, outputFile, opts) => {\n\t\t\tawait actionCommandTsToOpenApi(config, outputFile, opts);\n\t\t});\n}\n\n/**\n * Action the root command.\n * @param configFile The optional configuration file.\n * @param outputFile The output file for the generation OpenApi spec.\n * @param opts The options for the command.\n */\nexport async function actionCommandTsToOpenApi(\n\tconfigFile: string,\n\toutputFile: string,\n\topts: unknown\n): Promise<void> {\n\tlet outputWorkingDir: string | undefined;\n\ttry {\n\t\tlet config: ITsToOpenApiConfig | undefined;\n\n\t\tconst fullConfigFile = path.resolve(configFile);\n\t\tconst fullOutputFile = path.resolve(outputFile);\n\t\toutputWorkingDir = path.join(path.dirname(fullOutputFile), \"working\");\n\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.labels.configJson\"),\n\t\t\tfullConfigFile\n\t\t);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.labels.outputFile\"),\n\t\t\tfullOutputFile\n\t\t);\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.labels.outputWorkingDir\"),\n\t\t\toutputWorkingDir\n\t\t);\n\t\tCLIDisplay.break();\n\n\t\ttry {\n\t\t\tCLIDisplay.task(I18n.formatMessage(\"commands.ts-to-openapi.progress.loadingConfigJson\"));\n\t\t\tCLIDisplay.break();\n\n\t\t\tconfig = await CLIUtils.readJsonFile<ITsToOpenApiConfig>(fullConfigFile);\n\t\t} catch (err) {\n\t\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-openapi.configFailed\", undefined, err);\n\t\t}\n\n\t\tif (Is.empty(config)) {\n\t\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-openapi.configFailed\");\n\t\t}\n\n\t\tCLIDisplay.task(I18n.formatMessage(\"commands.ts-to-openapi.progress.creatingWorkingDir\"));\n\t\tawait mkdir(outputWorkingDir, { recursive: true });\n\t\tCLIDisplay.break();\n\n\t\tawait tsToOpenApi(config ?? {}, fullOutputFile, outputWorkingDir);\n\n\t\tCLIDisplay.break();\n\t\tCLIDisplay.done();\n\t} finally {\n\t\ttry {\n\t\t\tif (outputWorkingDir) {\n\t\t\t\tawait rm(outputWorkingDir, { recursive: true });\n\t\t\t}\n\t\t} catch {}\n\t}\n}\n\n/**\n * Convert the TypeScript definitions to OpenAPI spec.\n * @param config The configuration for the app.\n * @param outputFile The location of the file to output the OpenAPI spec.\n * @param workingDirectory The folder the app was run from.\n */\nexport async function tsToOpenApi(\n\tconfig: ITsToOpenApiConfig,\n\toutputFile: string,\n\tworkingDirectory: string\n): Promise<void> {\n\tawait writeFile(\n\t\tpath.join(workingDirectory, \"package.json\"),\n\t\tJSON.stringify(\n\t\t\t{\n\t\t\t\tversion: \"1.0.0\",\n\t\t\t\tname: \"ts-to-openapi-working\",\n\t\t\t\tdependencies: {}\n\t\t\t},\n\t\t\tundefined,\n\t\t\t\"\\t\"\n\t\t)\n\t);\n\n\tconst openApi: IOpenApi = {\n\t\topenapi: OpenApiConstants.API_VERSION,\n\t\tinfo: {\n\t\t\ttitle: config.title,\n\t\t\tdescription: config.description,\n\t\t\tversion: config.version,\n\t\t\tlicense: {\n\t\t\t\tname: config.licenseName,\n\t\t\t\turl: config.licenseUrl\n\t\t\t}\n\t\t},\n\t\tservers: Is.arrayValue(config.servers) ? config.servers.map(s => ({ url: s })) : undefined,\n\t\ttags: [],\n\t\tpaths: {}\n\t};\n\n\tCLIDisplay.task(I18n.formatMessage(\"commands.ts-to-openapi.progress.creatingSecuritySchemas\"));\n\tCLIDisplay.break();\n\n\tconst authSecurity: { [name: string]: string[] }[] = [];\n\tconst securitySchemes: { [name: string]: IOpenApiSecurityScheme } = {};\n\n\tbuildSecurity(config, securitySchemes, authSecurity);\n\n\tconst responseCodes: string[] = [];\n\tconst inputResults: IInputResult[] = [];\n\tconst typeRoots: string[] = [];\n\tconst restRoutesAndTags = await loadPackages(config, workingDirectory, typeRoots);\n\n\tfor (const restRouteAndTag of restRoutesAndTags) {\n\t\tconst paths = await processPackageRestDetails(restRouteAndTag.restRoutes);\n\t\tinputResults.push({\n\t\t\tpaths,\n\t\t\ttags: restRouteAndTag.tags\n\t\t});\n\t}\n\n\tCLIDisplay.task(I18n.formatMessage(\"commands.ts-to-openapi.progress.generatingSchemas\"));\n\n\tconst schemas = await generateSchemas(typeRoots);\n\n\tfor (let i = 0; i < inputResults.length; i++) {\n\t\tconst result = inputResults[i];\n\t\tfor (const tag of result.tags) {\n\t\t\tconst exists = openApi.tags?.find(t => t.name === tag.name);\n\t\t\tif (!exists) {\n\t\t\t\topenApi.tags?.push(tag);\n\t\t\t}\n\t\t}\n\n\t\tfor (const inputPath of result.paths) {\n\t\t\tconst responses: ({ code?: HttpStatusCode } & IOpenApiResponse)[] = [];\n\t\t\tconst responseTypes = inputPath.responseType;\n\n\t\t\tconst pathSpecificAuthSecurity: { [name: string]: string[] }[] = [];\n\n\t\t\tif (authSecurity.length > 0 && !inputPath.skipAuth) {\n\t\t\t\tpathSpecificAuthSecurity.push(...authSecurity);\n\t\t\t}\n\n\t\t\tif (pathSpecificAuthSecurity.length > 0) {\n\t\t\t\tresponseTypes.push({\n\t\t\t\t\tstatusCode: HttpStatusCode.unauthorized,\n\t\t\t\t\ttype: \"IUnauthorizedResponse\"\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tfor (const responseType of responseTypes) {\n\t\t\t\tconst responseSchema = resolveSchema(schemas, responseType.type);\n\t\t\t\tconst responseSchemaRefName = resolveResponseSchemaRefName(schemas, responseType.type);\n\t\t\t\tconst isBinaryOctetStream = responseType.type === nameof<Uint8Array>();\n\t\t\t\tif (responseSchema || isBinaryOctetStream) {\n\t\t\t\t\tlet headers: { [id: string]: IOpenApiHeader } | undefined;\n\t\t\t\t\tlet examples: { [id: string]: IOpenApiExample } | undefined;\n\n\t\t\t\t\tif (Is.arrayValue(responseType.examples)) {\n\t\t\t\t\t\tfor (const example of responseType.examples) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tIs.object<{ headers: { [id: string]: string | string[] }; body: unknown }>(\n\t\t\t\t\t\t\t\t\texample.response\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tif (Is.objectValue(example.response.headers)) {\n\t\t\t\t\t\t\t\t\theaders ??= {};\n\t\t\t\t\t\t\t\t\tconst headersSchema = Is.object<IJsonSchema>(responseSchema?.properties?.headers)\n\t\t\t\t\t\t\t\t\t\t? responseSchema.properties.headers\n\t\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\t\t\tfor (const header in example.response.headers) {\n\t\t\t\t\t\t\t\t\t\tconst headerValue = example.response.headers[header];\n\t\t\t\t\t\t\t\t\t\tconst propertySchema = headersSchema?.properties?.[header];\n\t\t\t\t\t\t\t\t\t\tconst schemaType = Is.object<IJsonSchema>(propertySchema)\n\t\t\t\t\t\t\t\t\t\t\t? propertySchema?.type\n\t\t\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\t\t\t\theaders[header] = {\n\t\t\t\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\t\t\t\ttype: Is.string(schemaType) ? schemaType : \"string\"\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\tdescription: `e.g. ${\n\t\t\t\t\t\t\t\t\t\t\t\tIs.array(headerValue) ? headerValue.join(\",\") : headerValue\n\t\t\t\t\t\t\t\t\t\t\t}`\n\t\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (!Is.undefined(example.response.body)) {\n\t\t\t\t\t\t\t\t\texamples ??= {};\n\t\t\t\t\t\t\t\t\texamples[example.id] = {\n\t\t\t\t\t\t\t\t\t\tsummary: example.description,\n\t\t\t\t\t\t\t\t\t\tvalue: example.response.body\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst statusExample = getHttpExampleFromType(responseType.type);\n\t\t\t\t\t\tif (statusExample) {\n\t\t\t\t\t\t\texamples = {};\n\t\t\t\t\t\t\texamples.exampleResponse = {\n\t\t\t\t\t\t\t\tvalue: statusExample\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlet mimeType: string;\n\t\t\t\t\tlet schemaType: string | undefined;\n\t\t\t\t\tlet schemaFormat: string | undefined;\n\t\t\t\t\tlet schemaRef: string | undefined;\n\t\t\t\t\tlet description = responseSchema?.description ?? responseType.type;\n\n\t\t\t\t\tif (Is.stringValue(responseType.mimeType)) {\n\t\t\t\t\t\tmimeType = responseType.mimeType;\n\t\t\t\t\t} else if (isBinaryOctetStream) {\n\t\t\t\t\t\tmimeType = \"application/octet-stream\";\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst hasBody = Is.notEmpty(responseSchema?.properties?.body);\n\t\t\t\t\t\tif (hasBody) {\n\t\t\t\t\t\t\tmimeType = MimeTypes.Json;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tmimeType = MimeTypes.PlainText;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\t// Perform some special handling for binary octet-streams to produce a nicer spec output\n\t\t\t\t\tif (isBinaryOctetStream) {\n\t\t\t\t\t\tschemaType = \"string\";\n\t\t\t\t\t\tschemaFormat = \"binary\";\n\t\t\t\t\t\tschemaRef = undefined;\n\t\t\t\t\t\tdescription = \"Binary data\";\n\t\t\t\t\t\tif (Is.objectValue<IOpenApiExample>(examples)) {\n\t\t\t\t\t\t\tconst exampleKeys = Object.keys(examples);\n\n\t\t\t\t\t\t\tconst firstExample = examples[exampleKeys[0]];\n\t\t\t\t\t\t\tdescription = firstExample.summary ?? description;\n\t\t\t\t\t\t\tfirstExample.summary = \"Binary Data\";\n\n\t\t\t\t\t\t\tfor (const exampleKey in examples) {\n\t\t\t\t\t\t\t\texamples[exampleKey].value = \"\";\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tschemaRef = `#/components/schemas/${StringHelper.stripPrefix(responseSchemaRefName ?? responseType.type)}`;\n\t\t\t\t\t}\n\n\t\t\t\t\tresponses.push({\n\t\t\t\t\t\tcode: responseType.statusCode,\n\t\t\t\t\t\tdescription,\n\t\t\t\t\t\tcontent:\n\t\t\t\t\t\t\tresponseType.type === \"ICreatedResponse\" || responseType.type === \"INoContentResponse\"\n\t\t\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\t\t\t[mimeType]: {\n\t\t\t\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\t\t\t\t$ref: schemaRef,\n\t\t\t\t\t\t\t\t\t\t\t\ttype: schemaType,\n\t\t\t\t\t\t\t\t\t\t\t\tformat: schemaFormat\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t\texamples\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\theaders\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (inputPath.responseCodes.length > 0) {\n\t\t\t\tfor (const responseCode of inputPath.responseCodes) {\n\t\t\t\t\tconst responseCodeDetails = HTTP_STATUS_CODE_MAP[responseCode];\n\t\t\t\t\t// Only include the response code if it hasn't already been\n\t\t\t\t\t// included with a specific response\n\t\t\t\t\tif (!responseTypes.some(r => r.statusCode === responseCodeDetails.code)) {\n\t\t\t\t\t\tif (!responseCodes.includes(responseCode)) {\n\t\t\t\t\t\t\tresponseCodes.push(responseCode);\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tlet examples: { [id: string]: IOpenApiExample } | undefined;\n\n\t\t\t\t\t\tif (responseCodeDetails.example) {\n\t\t\t\t\t\t\texamples = {\n\t\t\t\t\t\t\t\texampleResponse: {\n\t\t\t\t\t\t\t\t\tvalue: responseCodeDetails.example\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tconst responseCodeSchema = resolveSchema(schemas, responseCodeDetails.responseType);\n\t\t\t\t\t\tif (responseCodeSchema) {\n\t\t\t\t\t\t\tconst responseCodeSchemaRefName = resolveResponseSchemaRefName(\n\t\t\t\t\t\t\t\tschemas,\n\t\t\t\t\t\t\t\tresponseCodeDetails.responseType\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tresponses.push({\n\t\t\t\t\t\t\t\tcode: responseCodeDetails.code,\n\t\t\t\t\t\t\t\tdescription: responseCodeSchema.description ?? responseCodeDetails.responseType,\n\t\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t\t[MimeTypes.Json]: {\n\t\t\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\t\t\t$ref: `#/components/schemas/${StringHelper.stripPrefix(responseCodeSchemaRefName ?? responseCodeDetails.responseType)}`\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\texamples\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst pathQueryHeaderParams: {\n\t\t\t\tname: string;\n\t\t\t\tdescription?: string;\n\t\t\t\trequired: boolean;\n\t\t\t\tin: IOpenApiParameter[\"in\"];\n\t\t\t\tschema: IJsonSchema;\n\t\t\t\tstyle?: IOpenApiParameter[\"style\"];\n\t\t\t\texample?: unknown;\n\t\t\t}[] = inputPath.pathParameters.map(p => ({\n\t\t\t\tname: p,\n\t\t\t\tdescription: \"\",\n\t\t\t\trequired: true,\n\t\t\t\tschema: {\n\t\t\t\t\ttype: \"string\"\n\t\t\t\t},\n\t\t\t\tin: \"path\",\n\t\t\t\tstyle: \"simple\"\n\t\t\t}));\n\n\t\t\tconst requestExample = inputPath.requestExamples?.[0]?.request as {\n\t\t\t\tpathParams: { [id: string]: string };\n\t\t\t\theaders: { [id: string]: string };\n\t\t\t\tquery: { [id: string]: string };\n\t\t\t};\n\n\t\t\tif (Is.object(requestExample?.pathParams)) {\n\t\t\t\tfor (const pathOrQueryParam of pathQueryHeaderParams) {\n\t\t\t\t\tif (requestExample.pathParams[pathOrQueryParam.name]) {\n\t\t\t\t\t\tpathOrQueryParam.example = requestExample.pathParams[pathOrQueryParam.name];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tlet requestObject: IJsonSchema | undefined = inputPath.requestType\n\t\t\t\t? resolveSchema(schemas, inputPath.requestType)\n\t\t\t\t: undefined;\n\n\t\t\tif (requestObject?.properties) {\n\t\t\t\t// If there are any properties other than body, query, pathParams and headers\n\t\t\t\t// we should throw an error as we don't know what to do with them\n\t\t\t\tconst otherKeys = Object.keys(requestObject.properties).filter(\n\t\t\t\t\tk => ![\"body\", \"query\", \"pathParams\", \"headers\"].includes(k)\n\t\t\t\t);\n\t\t\t\tif (otherKeys.length > 0) {\n\t\t\t\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-openapi.unsupportedProperties\", {\n\t\t\t\t\t\tkeys: otherKeys.join(\", \")\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// If there is a path params object convert these to params\n\t\t\t\tif (Is.object<IJsonSchema>(requestObject.properties.pathParams)) {\n\t\t\t\t\tfor (const pathParam of pathQueryHeaderParams) {\n\t\t\t\t\t\tconst prop = requestObject.properties.pathParams.properties?.[pathParam.name];\n\t\t\t\t\t\tif (Is.object<IJsonSchema>(prop)) {\n\t\t\t\t\t\t\tpathParam.description = prop.description ?? pathParam.description;\n\t\t\t\t\t\t\tpathParam.schema = {\n\t\t\t\t\t\t\t\ttype: prop.type,\n\t\t\t\t\t\t\t\tenum: prop.enum,\n\t\t\t\t\t\t\t\t$ref: prop.$ref\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\tpathParam.required = true;\n\t\t\t\t\t\t\tdelete requestObject.properties.pathParams.properties?.[pathParam.name];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdelete requestObject.properties.pathParams;\n\t\t\t\t}\n\n\t\t\t\t// If there is a query object convert these to params as well\n\t\t\t\tif (Is.object<IJsonSchema>(requestObject.properties.query)) {\n\t\t\t\t\tfor (const prop in requestObject.properties.query.properties) {\n\t\t\t\t\t\tconst queryProp = requestObject.properties.query.properties[prop];\n\t\t\t\t\t\tif (Is.object<IJsonSchema>(queryProp)) {\n\t\t\t\t\t\t\tlet example: unknown;\n\t\t\t\t\t\t\tif (Is.object(requestExample.query) && requestExample.query[prop]) {\n\t\t\t\t\t\t\t\texample = requestExample.query[prop];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tpathQueryHeaderParams.push({\n\t\t\t\t\t\t\t\tname: prop,\n\t\t\t\t\t\t\t\tdescription: queryProp.description,\n\t\t\t\t\t\t\t\trequired: Boolean(requestObject.required?.includes(prop)),\n\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\ttype: queryProp.type,\n\t\t\t\t\t\t\t\t\tenum: queryProp.enum,\n\t\t\t\t\t\t\t\t\t$ref: queryProp.$ref\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tin: \"query\",\n\t\t\t\t\t\t\t\texample\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tdelete requestObject.properties.query.properties[prop];\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdelete requestObject.properties.query;\n\t\t\t\t}\n\n\t\t\t\t// If there are headers in the object convert these to spec params\n\t\t\t\tif (Is.object<IJsonSchema>(requestObject.properties.headers)) {\n\t\t\t\t\tconst headerProperties = requestObject.properties.headers.properties;\n\n\t\t\t\t\tfor (const prop in headerProperties) {\n\t\t\t\t\t\tconst headerSchema = headerProperties[prop];\n\t\t\t\t\t\tif (Is.object<IJsonSchema>(headerSchema)) {\n\t\t\t\t\t\t\tlet example: unknown;\n\t\t\t\t\t\t\tif (Is.object(requestExample.headers) && requestExample.headers[prop]) {\n\t\t\t\t\t\t\t\texample = requestExample.headers[prop];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tpathQueryHeaderParams.push({\n\t\t\t\t\t\t\t\tname: prop,\n\t\t\t\t\t\t\t\tdescription: headerSchema.description,\n\t\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\ttype: \"string\"\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\tin: \"header\",\n\t\t\t\t\t\t\t\tstyle: \"simple\",\n\t\t\t\t\t\t\t\texample\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tdelete requestObject.properties.headers;\n\t\t\t\t}\n\n\t\t\t\t// If we have used all the properties from the object in the\n\t\t\t\t// path we should remove it.\n\t\t\t\tif (Object.keys(requestObject.properties).length === 0 && inputPath.requestType) {\n\t\t\t\t\tdeleteSchema(schemas, inputPath.requestType);\n\t\t\t\t\trequestObject = undefined;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (config.restRoutes) {\n\t\t\t\tlet fullPath = StringHelper.trimTrailingSlashes(inputPath.path);\n\t\t\t\tif (fullPath.length === 0) {\n\t\t\t\t\tfullPath = \"/\";\n\t\t\t\t}\n\t\t\t\topenApi.paths ??= {};\n\t\t\t\tconst openApiPaths = openApi.paths;\n\t\t\t\topenApiPaths[fullPath] ??= {};\n\t\t\t\tconst pathItem = openApiPaths[fullPath];\n\n\t\t\t\tconst method = inputPath.method.toLowerCase() as keyof Pick<\n\t\t\t\t\tIOpenApiPathItem,\n\t\t\t\t\t\"get\" | \"put\" | \"post\" | \"delete\" | \"options\" | \"head\" | \"patch\"\n\t\t\t\t>;\n\n\t\t\t\tconst operation = {\n\t\t\t\t\toperationId: inputPath.operationId,\n\t\t\t\t\tsummary: inputPath.summary,\n\t\t\t\t\ttags: [inputPath.tag],\n\t\t\t\t\tparameters:\n\t\t\t\t\t\tpathQueryHeaderParams.length > 0\n\t\t\t\t\t\t\t? pathQueryHeaderParams.map(p => ({\n\t\t\t\t\t\t\t\t\tname: p.name,\n\t\t\t\t\t\t\t\t\tdescription: p.description,\n\t\t\t\t\t\t\t\t\tin: p.in,\n\t\t\t\t\t\t\t\t\trequired: p.required,\n\t\t\t\t\t\t\t\t\tschema: p.schema,\n\t\t\t\t\t\t\t\t\tstyle: p.style,\n\t\t\t\t\t\t\t\t\texample: p.example\n\t\t\t\t\t\t\t\t}))\n\t\t\t\t\t\t\t: undefined\n\t\t\t\t} as IOpenApiPathMethod;\n\t\t\t\tpathItem[method] = operation;\n\n\t\t\t\tconst pathOperation: IOpenApiPathMethod | undefined = pathItem[method];\n\n\t\t\t\tif (pathSpecificAuthSecurity.length > 0) {\n\t\t\t\t\tif (pathOperation) {\n\t\t\t\t\t\tpathOperation.security = pathSpecificAuthSecurity;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (requestObject && inputPath.requestType) {\n\t\t\t\t\tlet examples: { [id: string]: IOpenApiExample } | undefined;\n\t\t\t\t\tif (Is.arrayValue(inputPath.requestExamples)) {\n\t\t\t\t\t\tfor (const example of inputPath.requestExamples) {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tIs.object<{ body: unknown }>(example.request) &&\n\t\t\t\t\t\t\t\t!Is.undefined(example.request.body)\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\texamples ??= {};\n\t\t\t\t\t\t\t\texamples[example.id] = {\n\t\t\t\t\t\t\t\t\tsummary: example.description,\n\t\t\t\t\t\t\t\t\tvalue: example.request.body\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tlet requestMimeType: string;\n\t\t\t\t\tif (Is.stringValue(inputPath.requestMimeType)) {\n\t\t\t\t\t\trequestMimeType = inputPath.requestMimeType;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst requestSchema = resolveSchema(schemas, inputPath.requestType);\n\t\t\t\t\t\tconst hasBody = Is.notEmpty(requestSchema?.properties?.body);\n\t\t\t\t\t\tif (hasBody) {\n\t\t\t\t\t\t\trequestMimeType = MimeTypes.Json;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trequestMimeType = MimeTypes.PlainText;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (pathOperation) {\n\t\t\t\t\t\tpathOperation.requestBody = {\n\t\t\t\t\t\t\tdescription: requestObject.description,\n\t\t\t\t\t\t\trequired: true,\n\t\t\t\t\t\t\tcontent: {\n\t\t\t\t\t\t\t\t[requestMimeType]: {\n\t\t\t\t\t\t\t\t\tschema: {\n\t\t\t\t\t\t\t\t\t\t$ref: `#/components/schemas/${StringHelper.stripPrefix(inputPath.requestType)}`\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\texamples\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t};\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (responses.length > 0) {\n\t\t\t\t\tconst openApiResponses: { [code: string]: IOpenApiResponse } = {};\n\t\t\t\t\tfor (const response of responses) {\n\t\t\t\t\t\tconst code = response.code;\n\t\t\t\t\t\tif (code) {\n\t\t\t\t\t\t\tdelete response.code;\n\t\t\t\t\t\t\topenApiResponses[code] ??= { description: \"\" };\n\t\t\t\t\t\t\topenApiResponses[code] = ObjectHelper.merge(openApiResponses[code], response);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tif (pathOperation) {\n\t\t\t\t\t\tpathOperation.responses = openApiResponses;\n\t\t\t\t\t}\n\t\t\t\t} else if (pathOperation) {\n\t\t\t\t\tpathOperation.responses = {};\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tawait finaliseOutput(schemas, openApi, securitySchemes, config.externalReferences, outputFile);\n}\n\n/**\n * Finalise the schemas and output the spec.\n * @param schemas The schemas.\n * @param openApi The OpenAPI spec.\n * @param securitySchemes The security schemes.\n * @param externalReferences The external references.\n * @param outputFile The output file.\n */\nasync function finaliseOutput(\n\tschemas: { [id: string]: IJsonSchema },\n\topenApi: IOpenApi,\n\tsecuritySchemes: { [name: string]: IOpenApiSecurityScheme },\n\texternalReferences: { [type: string]: string } | undefined,\n\toutputFile: string\n): Promise<void> {\n\tCLIDisplay.break();\n\tCLIDisplay.task(I18n.formatMessage(\"commands.ts-to-openapi.progress.finalisingSchemas\"));\n\n\tconst { finalSchemas, substituteSchemas } = prepareFinalSchemas(schemas, externalReferences);\n\n\tremoveStandardSchemas(finalSchemas);\n\tapplyRefOnlySchemaSubstitutions(openApi, substituteSchemas);\n\n\tconst sortedSchemas = buildSortedPrunedSchemas(openApi, finalSchemas);\n\n\t// Schemas that have been kept as local component schemas must not have their\n\t// $ref values in paths rewritten to external URLs.\n\tconst localSchemaNames = new Set(Object.keys(sortedSchemas));\n\trewriteExternalSchemaReferences(sortedSchemas, externalReferences);\n\trewriteExternalSchemaReferences(openApi.paths, externalReferences, localSchemaNames);\n\n\topenApi.components = {\n\t\tschemas: sortedSchemas,\n\t\tsecuritySchemes\n\t};\n\n\tvalidateComponentSchemaRefs(openApi);\n\n\tCLIDisplay.task(\n\t\tI18n.formatMessage(\"commands.ts-to-openapi.progress.writingOutputFile\"),\n\t\toutputFile\n\t);\n\n\ttry {\n\t\tawait mkdir(path.dirname(outputFile), { recursive: true });\n\t} catch {}\n\tawait writeFile(outputFile, `${JSON.stringify(openApi, undefined, \"\\t\")}\\n`);\n}\n\n/**\n * Collect all local component schema $ref names referenced anywhere in a value.\n * @param value The value to scan.\n * @param refs The set of ref names to populate.\n */\nfunction collectComponentSchemaRefs(value: unknown, refs: Set<string>): void {\n\tif (Is.array(value)) {\n\t\tfor (const item of value) {\n\t\t\tcollectComponentSchemaRefs(item, refs);\n\t\t}\n\t\treturn;\n\t}\n\tif (Is.object(value)) {\n\t\tif (Is.string(value.$ref) && value.$ref.startsWith(\"#/components/schemas/\")) {\n\t\t\trefs.add(value.$ref.slice(\"#/components/schemas/\".length));\n\t\t}\n\t\tfor (const child of Object.values(value)) {\n\t\t\tcollectComponentSchemaRefs(child, refs);\n\t\t}\n\t}\n}\n\n/**\n * Validate that every local component schema $ref in paths resolves to a defined schema.\n * @param openApi The OpenAPI spec to validate.\n * @throws GeneralError if any local component schema $ref does not resolve to a defined schema.\n */\nfunction validateComponentSchemaRefs(openApi: IOpenApi): void {\n\tconst refs = new Set<string>();\n\tcollectComponentSchemaRefs(openApi.paths, refs);\n\tconst schemas = openApi.components?.schemas ?? {};\n\tconst missing = [...refs].filter(name => !(name in schemas));\n\tif (missing.length > 0) {\n\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-openapi.unresolvedComponentRefs\", {\n\t\t\trefs: missing.join(\", \")\n\t\t});\n\t}\n}\n\n/**\n * Prepare schemas for final component output and collect schema substitutions.\n * @param schemas The schema map.\n * @param externalReferences The external reference mappings.\n * @returns The prepared schemas and substitutions.\n */\nfunction prepareFinalSchemas(\n\tschemas: { [id: string]: IJsonSchema },\n\texternalReferences: { [type: string]: string } | undefined\n): {\n\tfinalSchemas: { [id: string]: IJsonSchema };\n\tsubstituteSchemas: { from: string; to: string }[];\n} {\n\tconst substituteSchemas: { from: string; to: string }[] = [];\n\tconst finalSchemas: { [id: string]: IJsonSchema } = {};\n\n\tfor (const schema in schemas) {\n\t\tconst props = schemas[schema].properties;\n\t\tlet skipSchema = false;\n\t\tlet isLocalWrapper = false;\n\n\t\tif (Is.object<{ [id: string]: IJsonSchema | boolean }>(props)) {\n\t\t\ttidySchemaProperties(props, true);\n\n\t\t\t// Any request/response objects should be added to the final schemas\n\t\t\t// but only the body property, if there is no body then we don't\n\t\t\t// need to add it to the schemas\n\t\t\tif (schema.endsWith(\"Response\") || schema.endsWith(\"Request\")) {\n\t\t\t\tif (Is.object<IJsonSchema>(props.body)) {\n\t\t\t\t\tschemas[schema] = props.body;\n\t\t\t\t\t// Body was extracted from a local API wrapper type; external reference\n\t\t\t\t\t// patterns must not override this — the schema stays in components.\n\t\t\t\t\tisLocalWrapper = true;\n\t\t\t\t} else {\n\t\t\t\t\t// Body is absent or a boolean schema (true = any, false = never).\n\t\t\t\t\t// Emit an empty schema {} to prevent dangling $refs in paths that\n\t\t\t\t\t// reference this type, while still keeping it in components.\n\t\t\t\t\tschemas[schema] = {};\n\t\t\t\t\tisLocalWrapper = true;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// If the schema is external then remove it from the final schemas.\n\t\t// Local API wrapper types (Request/Response schemas whose body was extracted)\n\t\t// are always kept as local component schemas regardless of external ref patterns.\n\t\tif (!isLocalWrapper && resolveExternalReference(schema, externalReferences)) {\n\t\t\tskipSchema = true;\n\t\t}\n\n\t\tif (!skipSchema) {\n\t\t\t// If the final schema has no properties and is just a ref to another object type\n\t\t\t// then replace the references with that of the referenced type.\n\t\t\tconst ref = schemas[schema].$ref;\n\t\t\tif (!Is.arrayValue(schemas[schema].properties) && Is.stringValue(ref)) {\n\t\t\t\tsubstituteSchemas.push({ from: schema, to: ref });\n\t\t\t} else {\n\t\t\t\tfinalSchemas[StringHelper.stripPrefix(schema)] = schemas[schema];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn {\n\t\tfinalSchemas,\n\t\tsubstituteSchemas\n\t};\n}\n\n/**\n * Remove standard schemas that should not appear in the final OpenAPI output.\n * @param finalSchemas The final schemas map.\n */\nfunction removeStandardSchemas(finalSchemas: { [id: string]: IJsonSchema }): void {\n\tconst removeTypes = [\"HttpStatusCode\", ...Constants.ARRAY_NUMBER_TYPE_NAMES];\n\tfor (const type of removeTypes) {\n\t\tdelete finalSchemas[type];\n\t}\n}\n\n/**\n * Apply substitutions for ref-only wrapper schemas to path refs.\n * @param openApi The OpenAPI document.\n * @param substituteSchemas The collected schema substitutions.\n */\nfunction applyRefOnlySchemaSubstitutions(\n\topenApi: IOpenApi,\n\tsubstituteSchemas: { from: string; to: string }[]\n): void {\n\tconst refOnlySubstitutions: { from: string; to: string }[] = [];\n\tconst componentsPrefix = \"#/components/schemas/\";\n\n\tfor (const substitution of substituteSchemas) {\n\t\tif (substitution.to.startsWith(componentsPrefix)) {\n\t\t\trefOnlySubstitutions.push({\n\t\t\t\tfrom: StringHelper.stripPrefix(substitution.from),\n\t\t\t\tto: StringHelper.stripPrefix(substitution.to.slice(componentsPrefix.length))\n\t\t\t});\n\t\t}\n\t}\n\n\tif (refOnlySubstitutions.length > 0) {\n\t\trewriteSchemaRefs(openApi.paths, refOnlySubstitutions);\n\t}\n}\n\n/**\n * Apply equivalent-response schema substitutions to paths and final schemas.\n * @param openApi The OpenAPI document.\n * @param finalSchemas The final schemas map.\n * @param substituteSchemas The collected schema substitutions.\n */\n/**\n * Build sorted and tidied schemas from the current OpenAPI references.\n * @param openApi The OpenAPI document.\n * @param finalSchemas The candidate schemas.\n * @returns The sorted schema map.\n */\nfunction buildSortedPrunedSchemas(\n\topenApi: IOpenApi,\n\tfinalSchemas: { [id: string]: IJsonSchema }\n): { [id: string]: IJsonSchema } {\n\tconst prunedSchemas = pruneToReferencedSchemas(openApi, finalSchemas);\n\tconst prunedSchemaKeys = Object.keys(prunedSchemas);\n\tprunedSchemaKeys.sort();\n\n\tconst sortedSchemas: { [id: string]: IJsonSchema } = {};\n\tfor (const key of prunedSchemaKeys) {\n\t\ttidySchemaProperties(prunedSchemas[key], false);\n\t\tdelete prunedSchemas[key].title;\n\t\tsortedSchemas[key] = prunedSchemas[key];\n\t}\n\n\treturn sortedSchemas;\n}\n\n/**\n * Prune schemas to only those referenced by the OpenAPI document and their transitive dependencies.\n * @param openApi The generated OpenAPI document.\n * @param schemas The candidate schemas.\n * @returns The pruned schemas.\n */\nfunction pruneToReferencedSchemas(\n\topenApi: IOpenApi,\n\tschemas: { [id: string]: IJsonSchema }\n): { [id: string]: IJsonSchema } {\n\tconst referencedSchemaNames = new Set<string>();\n\tconst pendingSchemaNames: string[] = [];\n\n\tconst enqueueSchemaRef = (ref: string): void => {\n\t\tconst schemaName = normaliseSchemaRefName(ref, schemas);\n\t\tif (schemaName && !referencedSchemaNames.has(schemaName)) {\n\t\t\treferencedSchemaNames.add(schemaName);\n\t\t\tpendingSchemaNames.push(schemaName);\n\t\t}\n\t};\n\n\tcollectSchemaRefs(openApi.paths, enqueueSchemaRef);\n\n\twhile (pendingSchemaNames.length > 0) {\n\t\tconst schemaName = pendingSchemaNames.pop();\n\t\tif (schemaName) {\n\t\t\tcollectSchemaRefs(schemas[schemaName], enqueueSchemaRef);\n\t\t}\n\t}\n\n\tconst prunedSchemas: { [id: string]: IJsonSchema } = {};\n\tfor (const schemaName of referencedSchemaNames) {\n\t\tprunedSchemas[schemaName] = schemas[schemaName];\n\t}\n\n\treturn prunedSchemas;\n}\n\n/**\n * Rewrite schema refs using the provided substitutions.\n * @param value The value to rewrite.\n * @param substitutions The schema substitutions.\n */\nfunction rewriteSchemaRefs(value: unknown, substitutions: { from: string; to: string }[]): void {\n\tif (Is.array(value)) {\n\t\tfor (const item of value) {\n\t\t\trewriteSchemaRefs(item, substitutions);\n\t\t}\n\t\treturn;\n\t}\n\n\tif (Is.object<{ $ref?: unknown }>(value)) {\n\t\tif (Is.stringValue(value.$ref)) {\n\t\t\tfor (const substitution of substitutions) {\n\t\t\t\tif (value.$ref === `#/components/schemas/${substitution.from}`) {\n\t\t\t\t\tvalue.$ref = `#/components/schemas/${substitution.to}`;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const objectValue of Object.values(value)) {\n\t\t\trewriteSchemaRefs(objectValue, substitutions);\n\t\t}\n\t}\n}\n\n/**\n * Collect schema references from a value.\n * @param value The value to inspect.\n * @param onRef The callback for each schema ref.\n */\nfunction collectSchemaRefs(value: unknown, onRef: (ref: string) => void): void {\n\tif (Is.array(value)) {\n\t\tfor (const item of value) {\n\t\t\tcollectSchemaRefs(item, onRef);\n\t\t}\n\t\treturn;\n\t}\n\n\tif (Is.object<{ $ref?: unknown }>(value)) {\n\t\tif (Is.stringValue(value.$ref)) {\n\t\t\tonRef(value.$ref);\n\t\t}\n\n\t\tfor (const objectValue of Object.values(value)) {\n\t\t\tcollectSchemaRefs(objectValue, onRef);\n\t\t}\n\t}\n}\n\n/**\n * Normalise a schema ref to a component schema name.\n * @param ref The schema ref.\n * @param schemas The available schemas.\n * @returns The normalised schema name if it exists.\n */\nfunction normaliseSchemaRefName(\n\tref: string,\n\tschemas: { [id: string]: IJsonSchema }\n): string | undefined {\n\tconst refParts = ref.split(\"/\");\n\tconst rawName = refParts[refParts.length - 1];\n\tif (!Is.stringValue(rawName)) {\n\t\treturn undefined;\n\t}\n\n\tconst schemaName = StringHelper.stripPrefix(rawName);\n\n\treturn schemas[schemaName] ? schemaName : undefined;\n}\n\n/**\n * Rewrite component schema refs to external refs when configured.\n * @param value The object to walk and rewrite in place.\n * @param externalReferences The external reference mappings.\n * @param preservedSchemas An optional set of local component schema names whose refs must not be rewritten.\n */\nfunction rewriteExternalSchemaReferences(\n\tvalue: unknown,\n\texternalReferences: { [type: string]: string } | undefined,\n\tpreservedSchemas?: Set<string>\n): void {\n\tif (!Is.object(externalReferences)) {\n\t\treturn;\n\t}\n\n\tif (Is.array(value)) {\n\t\tfor (const item of value) {\n\t\t\trewriteExternalSchemaReferences(item, externalReferences, preservedSchemas);\n\t\t}\n\t\treturn;\n\t}\n\n\tif (Is.object<{ $ref?: unknown }>(value)) {\n\t\tif (Is.stringValue(value.$ref)) {\n\t\t\tconst schemaPrefix = \"#/components/schemas/\";\n\t\t\tif (value.$ref.startsWith(schemaPrefix)) {\n\t\t\t\tconst schemaName = value.$ref.slice(schemaPrefix.length);\n\t\t\t\tif (!preservedSchemas?.has(schemaName)) {\n\t\t\t\t\tconst externalReference = resolveExternalReference(schemaName, externalReferences);\n\t\t\t\t\tif (Is.stringValue(externalReference)) {\n\t\t\t\t\t\tvalue.$ref = externalReference;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tfor (const objectValue of Object.values(value)) {\n\t\t\trewriteExternalSchemaReferences(objectValue, externalReferences, preservedSchemas);\n\t\t}\n\t}\n}\n\n/**\n * Resolve a schema name to an external reference URL if configured.\n * @param schemaName The schema name.\n * @param externalReferences The external reference mappings.\n * @returns The external reference URL if matched.\n */\nfunction resolveExternalReference(\n\tschemaName: string,\n\texternalReferences: { [type: string]: string } | undefined\n): string | undefined {\n\tif (!Is.object(externalReferences)) {\n\t\treturn undefined;\n\t}\n\n\tconst schemaCandidates = [schemaName, StringHelper.stripPrefix(schemaName)].filter(candidate =>\n\t\tIs.stringValue(candidate)\n\t);\n\n\tfor (const external in externalReferences) {\n\t\tconst re = new RegExp(`^${external}$`);\n\t\tfor (const candidate of schemaCandidates) {\n\t\t\tif (re.test(candidate)) {\n\t\t\t\treturn candidate.replace(re, externalReferences[external]);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\n/**\n * Build the security schemas from the config.\n * @param config The configuration.\n * @param securitySchemes The security schemes.\n * @param authSecurity The auth security.\n */\nfunction buildSecurity(\n\tconfig: ITsToOpenApiConfig,\n\tsecuritySchemes: { [name: string]: IOpenApiSecurityScheme },\n\tauthSecurity: { [name: string]: string[] }[]\n): void {\n\tif (Is.arrayValue(config.authMethods)) {\n\t\tfor (const authMethod of config.authMethods) {\n\t\t\tconst security: { [name: string]: string[] } = {};\n\t\t\tif (authMethod === \"basic\") {\n\t\t\t\tsecuritySchemes.basicAuthScheme = {\n\t\t\t\t\ttype: \"http\",\n\t\t\t\t\tscheme: \"basic\"\n\t\t\t\t};\n\t\t\t\tsecurity.basicAuthScheme = [];\n\t\t\t} else if (authMethod === \"jwtBearer\") {\n\t\t\t\tsecuritySchemes.jwtBearerAuthScheme = {\n\t\t\t\t\ttype: \"http\",\n\t\t\t\t\tscheme: \"bearer\",\n\t\t\t\t\tbearerFormat: \"JWT\"\n\t\t\t\t};\n\t\t\t\tsecurity.jwtBearerAuthScheme = [];\n\t\t\t} else if (authMethod === \"jwtCookie\") {\n\t\t\t\tsecuritySchemes.jwtCookieAuthScheme = {\n\t\t\t\t\ttype: \"apiKey\",\n\t\t\t\t\tin: \"cookie\",\n\t\t\t\t\tname: \"auth_token\"\n\t\t\t\t};\n\t\t\t\tsecurity.jwtCookieAuthScheme = [];\n\t\t\t}\n\t\t\tauthSecurity.push(security);\n\t\t}\n\t}\n}\n\n/**\n * Process the REST details for a package.\n * @param baseDir The base directory other locations are relative to.\n * @param prefix The prefix.\n * @param restDetails The package details.\n * @returns The paths and schemas for the input.\n * @internal\n */\nasync function processPackageRestDetails(restRoutes: IRestRoute[]): Promise<IInputPath[]> {\n\tconst paths: IInputPath[] = [];\n\n\tCLIDisplay.task(I18n.formatMessage(\"commands.ts-to-openapi.progress.processingRoutes\"));\n\n\tfor (const route of restRoutes) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.labels.route\"),\n\t\t\t`${route.operationId} ${route.method} ${route.path}`,\n\t\t\t1\n\t\t);\n\t\tconst pathParameters: string[] = [];\n\n\t\tconst pathPaths = route.path.split(\"/\");\n\t\tconst finalPathParts = [];\n\t\tfor (const part of pathPaths) {\n\t\t\tif (part.startsWith(\":\")) {\n\t\t\t\tfinalPathParts.push(`{${part.slice(1)}}`);\n\t\t\t\tpathParameters.push(part.slice(1));\n\t\t\t} else {\n\t\t\t\tfinalPathParts.push(part);\n\t\t\t}\n\t\t}\n\n\t\tconst responseType: {\n\t\t\tstatusCode: HttpStatusCode;\n\t\t\ttype: string;\n\t\t\tmimeType?: string;\n\t\t\tdescription?: string;\n\t\t\texamples?: {\n\t\t\t\tid: string;\n\t\t\t\tdescription?: string;\n\t\t\t\tresponse: unknown;\n\t\t\t}[];\n\t\t}[] = [];\n\n\t\t// If there is no response type automatically add a success\n\t\tif (Is.empty(route.responseType)) {\n\t\t\t// But only if we haven't got a response already for different content type\n\t\t\tif (responseType.length === 0) {\n\t\t\t\tresponseType.push({\n\t\t\t\t\ttype: \"IOkResponse\",\n\t\t\t\t\tstatusCode: HttpStatusCode.ok\n\t\t\t\t});\n\t\t\t}\n\t\t} else if (Is.array(route.responseType)) {\n\t\t\t// Find the response codes for the response types\n\t\t\tfor (const rt of route.responseType) {\n\t\t\t\tconst responseCode = getHttpStatusCodeFromType(rt.type);\n\t\t\t\tresponseType.push({\n\t\t\t\t\t...rt,\n\t\t\t\t\tmimeType: rt.mimeType,\n\t\t\t\t\tstatusCode: responseCode,\n\t\t\t\t\texamples: rt.examples\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tconst inputPath: IInputPath = {\n\t\t\tpath: finalPathParts.join(\"/\"),\n\t\t\tmethod: route.method,\n\t\t\tpathParameters,\n\t\t\toperationId: route.operationId,\n\t\t\ttag: route.tag,\n\t\t\tsummary: route.summary,\n\t\t\trequestType: route.requestType?.type,\n\t\t\trequestMimeType: route.requestType?.mimeType,\n\t\t\trequestExamples: route.requestType?.examples,\n\t\t\tresponseType,\n\t\t\tresponseCodes: [\"badRequest\", \"internalServerError\"],\n\t\t\tskipAuth: route.skipAuth ?? false\n\t\t};\n\n\t\tconst handlerSource = route.handler.toString();\n\n\t\tlet match;\n\t\tconst re = /httpstatuscode\\.([_a-z]*)/gi;\n\t\twhile ((match = re.exec(handlerSource)) !== null) {\n\t\t\tinputPath.responseCodes.push(match[1]);\n\t\t}\n\n\t\tpaths.push(inputPath);\n\t}\n\n\tCLIDisplay.break();\n\n\treturn paths;\n}\n\n/**\n * Generate schemas for the models.\n * @param modelDirWildcards The filenames for all the models.\n * @returns The generated schemas.\n * @internal\n */\nasync function generateSchemas(modelDirWildcards: string[]): Promise<{\n\t[id: string]: IJsonSchema;\n}> {\n\tconst allSchemas: { [id: string]: IJsonSchema } = {};\n\tconst typeScriptToSchema = new TypeScriptToSchema();\n\tconst packageSchemas: { [id: string]: { [id: string]: IJsonSchema } } = {};\n\n\tfor (const files of modelDirWildcards) {\n\t\tCLIDisplay.value(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.progress.models\"),\n\t\t\tfiles.replace(/\\\\/g, \"/\"),\n\t\t\t1\n\t\t);\n\n\t\tconst schemas = await typeScriptToSchema.generateSchema(\n\t\t\t\"#/components/schemas/\",\n\t\t\t\"@twin.org/ts-to-openapi\",\n\t\t\tpackageSchemas,\n\t\t\tfiles\n\t\t);\n\n\t\tfor (const schemaName in schemas) {\n\t\t\tallSchemas[schemaName] ??= schemas[schemaName];\n\t\t}\n\t}\n\n\treturn allSchemas;\n}\n\n/**\n * Resolve a schema by its raw or stripped interface type name.\n * @param schemas The schema map.\n * @param typeName The type name.\n * @returns The resolved schema if present.\n */\nfunction resolveSchema(\n\tschemas: { [id: string]: IJsonSchema },\n\ttypeName: string | undefined\n): IJsonSchema | undefined {\n\tif (!Is.stringValue(typeName)) {\n\t\treturn undefined;\n\t}\n\n\treturn schemas[typeName] ?? schemas[StringHelper.stripPrefix(typeName)];\n}\n\n/**\n * Resolve a response type to the schema component name that should be referenced in OpenAPI.\n * @param schemas The schema map.\n * @param typeName The response type name.\n * @returns The canonical component name if one can be determined.\n */\nfunction resolveResponseSchemaRefName(\n\tschemas: { [id: string]: IJsonSchema },\n\ttypeName: string | undefined\n): string | undefined {\n\tif (!Is.stringValue(typeName)) {\n\t\treturn undefined;\n\t}\n\n\treturn typeName;\n}\n\n/**\n * Delete a schema by its raw or stripped interface type name.\n * @param schemas The schema map.\n * @param typeName The type name.\n */\nfunction deleteSchema(schemas: { [id: string]: IJsonSchema }, typeName: string | undefined): void {\n\tif (!Is.stringValue(typeName)) {\n\t\treturn;\n\t}\n\n\tdelete schemas[typeName];\n\tdelete schemas[StringHelper.stripPrefix(typeName)];\n}\n\n/**\n * Tidy up schemas for OpenAPI context.\n * Removes unsupported schema keywords and normalises nested property schemas.\n * @param value The schema value to tidy.\n * @internal\n */\nfunction tidySchemaProperties(value: unknown, removeRefDescriptions: boolean): void {\n\tif (Is.array(value)) {\n\t\tfor (const item of value) {\n\t\t\ttidySchemaProperties(item, removeRefDescriptions);\n\t\t}\n\t\treturn;\n\t}\n\n\tif (Is.object<{ [id: string]: unknown; $ref?: unknown; description?: unknown }>(value)) {\n\t\tdelete value.$schema;\n\t\tdelete value.$id;\n\t\tdelete value.$comment;\n\n\t\tif (removeRefDescriptions) {\n\t\t\tfor (const prop of Object.keys(value)) {\n\t\t\t\tconst schemaProperty = value[prop];\n\t\t\t\tif (Is.object<IJsonSchema>(schemaProperty)) {\n\t\t\t\t\t// For OpenAPI we don't include a description for items that have refs.\n\t\t\t\t\tif (schemaProperty.$ref) {\n\t\t\t\t\t\tdelete schemaProperty.description;\n\t\t\t\t\t}\n\n\t\t\t\t\tif (schemaProperty.properties) {\n\t\t\t\t\t\ttidySchemaProperties(schemaProperty.properties, true);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tschemaProperty.items &&\n\t\t\t\t\t\tIs.object<IJsonSchema>(schemaProperty.items) &&\n\t\t\t\t\t\tIs.object<IJsonSchema>(schemaProperty.items.properties)\n\t\t\t\t\t) {\n\t\t\t\t\t\ttidySchemaProperties(schemaProperty.items.properties, true);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\tfor (const objectValue of Object.values(value)) {\n\t\t\t\ttidySchemaProperties(objectValue, false);\n\t\t\t}\n\t\t}\n\t}\n}\n\n/**\n * Load the packages from config and get the routes and tags from them.\n * @param tsToOpenApiConfig The app config.\n * @param outputWorkingDir The working directory.\n * @param typeRoots The model roots.\n * @returns The routes and tags for each package.\n * @internal\n */\nasync function loadPackages(\n\ttsToOpenApiConfig: ITsToOpenApiConfig,\n\toutputWorkingDir: string,\n\ttypeRoots: string[]\n): Promise<\n\t{\n\t\trestRoutes: IRestRoute[];\n\t\ttags: ITag[];\n\t}[]\n> {\n\tconst restRoutes: {\n\t\trestRoutes: IRestRoute[];\n\t\ttags: ITag[];\n\t}[] = [];\n\n\tlet localNpmRoot = await CLIUtils.findNpmRoot(process.cwd());\n\tlocalNpmRoot = localNpmRoot.replace(/[/\\\\]node_modules/, \"\");\n\n\tconst packages: string[] = [];\n\tconst localPackages: string[] = [];\n\n\tfor (const configRestRoutes of tsToOpenApiConfig.restRoutes) {\n\t\tif (Is.stringValue(configRestRoutes.package)) {\n\t\t\tconst existsLocally = await CLIUtils.dirExists(\n\t\t\t\tpath.join(localNpmRoot, \"node_modules\", configRestRoutes.package)\n\t\t\t);\n\t\t\tif (existsLocally) {\n\t\t\t\tif (!localPackages.includes(configRestRoutes.package)) {\n\t\t\t\t\tlocalPackages.push(configRestRoutes.package);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tconst version = configRestRoutes.version ?? \"latest\";\n\t\t\t\tconst newPackage = `${configRestRoutes.package}@${version}`;\n\t\t\t\tif (!packages.includes(newPackage)) {\n\t\t\t\t\tpackages.push(`${configRestRoutes.package}@${version}`);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tif (packages.length > 0) {\n\t\tCLIDisplay.task(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.progress.installingNpmPackages\"),\n\t\t\tpackages.join(\" \")\n\t\t);\n\t\tawait CLIUtils.runShellCmd(\"npm\", [\"install\", ...packages], outputWorkingDir);\n\t\tCLIDisplay.break();\n\t}\n\n\tfor (const configRestRoutes of tsToOpenApiConfig.restRoutes) {\n\t\tconst typeFolders = [\"models\", \"errors\"];\n\t\tconst packageName = configRestRoutes.package;\n\t\tconst packageRoot = configRestRoutes.packageRoot;\n\t\tif (!Is.stringValue(packageName) && !Is.stringValue(packageRoot)) {\n\t\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-openapi.packageNameOrRootMissing\");\n\t\t}\n\n\t\tlet rootFolder;\n\t\tlet npmResolveFolder;\n\t\tif (Is.stringValue(packageName)) {\n\t\t\tif (localPackages.includes(packageName)) {\n\t\t\t\tnpmResolveFolder = localNpmRoot;\n\t\t\t\trootFolder = path.join(localNpmRoot, \"node_modules\", packageName);\n\t\t\t} else {\n\t\t\t\tnpmResolveFolder = outputWorkingDir;\n\t\t\t\trootFolder = path.join(outputWorkingDir, \"node_modules\", packageName);\n\n\t\t\t\tconst downloadedPackageExists = await CLIUtils.dirExists(rootFolder);\n\t\t\t\tif (!downloadedPackageExists) {\n\t\t\t\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-openapi.packageResolutionFailed\", {\n\t\t\t\t\t\tpackage: packageName,\n\t\t\t\t\t\tworkingDir: outputWorkingDir\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\trootFolder = path.resolve(packageRoot ?? \"\");\n\t\t\tnpmResolveFolder = rootFolder;\n\t\t}\n\n\t\tconst pkgJson = (await CLIUtils.readJsonFile<IPackageJson>(\n\t\t\tpath.join(rootFolder, \"package.json\")\n\t\t)) ?? { name: \"\" };\n\t\tCLIDisplay.task(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.progress.processingPackage\"),\n\t\t\tpkgJson.name\n\t\t);\n\n\t\tfor (const typeFolder of typeFolders) {\n\t\t\tconst typesDir = path.join(rootFolder, \"dist\", \"types\", typeFolder);\n\t\t\tif (await CLIUtils.dirExists(typesDir)) {\n\t\t\t\tconst newRoot = path.join(typesDir, \"**/*.ts\");\n\t\t\t\tif (!typeRoots.includes(newRoot)) {\n\t\t\t\t\ttypeRoots.push(newRoot);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (pkgJson.dependencies) {\n\t\t\tconst nodeModulesFolder = await CLIUtils.findNpmRoot(npmResolveFolder);\n\t\t\tfor (const dep in pkgJson.dependencies) {\n\t\t\t\tif (dep.startsWith(\"@twin.org\")) {\n\t\t\t\t\tfor (const typeFolder of typeFolders) {\n\t\t\t\t\t\tconst typesDirDep = path.join(nodeModulesFolder, dep, \"dist\", \"types\", typeFolder);\n\t\t\t\t\t\tif (await CLIUtils.dirExists(typesDirDep)) {\n\t\t\t\t\t\t\tconst newRoot = path.join(typesDirDep, \"**/*.ts\");\n\t\t\t\t\t\t\tif (!typeRoots.includes(newRoot)) {\n\t\t\t\t\t\t\t\ttypeRoots.push(newRoot);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tCLIDisplay.task(\n\t\t\tI18n.formatMessage(\"commands.ts-to-openapi.progress.importingModule\"),\n\t\t\tpkgJson.name\n\t\t);\n\n\t\tconst pkg = await import(pathToFileURL(path.join(rootFolder, \"dist/es/index.js\")).href);\n\n\t\tif (!Is.array(pkg.restEntryPoints)) {\n\t\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-openapi.missingRestRoutesEntryPoints\", {\n\t\t\t\tmethod: \"restEntryPoints\",\n\t\t\t\tpackage: pkgJson.name\n\t\t\t});\n\t\t}\n\n\t\tconst packageEntryPoints: IRestRouteEntryPoint[] = pkg.restEntryPoints;\n\n\t\tconst entryPoints: ITsToOpenApiConfigEntryPoint[] =\n\t\t\tconfigRestRoutes.entryPoints ?? packageEntryPoints.map(e => ({ name: e.name }));\n\n\t\tfor (const entryPoint of entryPoints) {\n\t\t\tconst packageEntryPoint = packageEntryPoints.find(e => e.name === entryPoint.name);\n\n\t\t\tif (!Is.object<IRestRouteEntryPoint>(packageEntryPoint)) {\n\t\t\t\tthrow new GeneralError(\"commands\", \"commands.ts-to-openapi.missingRestRoutesEntryPoint\", {\n\t\t\t\t\tentryPoint: entryPoint.name,\n\t\t\t\t\tpackage: pkgJson.name\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tlet baseRouteName = StringHelper.trimTrailingSlashes(\n\t\t\t\tentryPoint.baseRoutePath ?? packageEntryPoint.defaultBaseRoute ?? \"\"\n\t\t\t);\n\n\t\t\tif (baseRouteName.length > 0) {\n\t\t\t\tbaseRouteName = `/${StringHelper.trimLeadingSlashes(baseRouteName)}`;\n\t\t\t}\n\n\t\t\tlet routes: IRestRoute[] = packageEntryPoint.generateRoutes(baseRouteName, \"dummy-service\");\n\n\t\t\troutes = routes.filter(r => !(r.excludeFromSpec ?? false));\n\n\t\t\tif (Is.stringValue(entryPoint.operationIdDistinguisher)) {\n\t\t\t\tfor (const route of routes) {\n\t\t\t\t\troute.operationId = `${route.operationId}${entryPoint.operationIdDistinguisher}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\trestRoutes.push({\n\t\t\t\trestRoutes: routes,\n\t\t\t\ttags: packageEntryPoint.tags\n\t\t\t});\n\t\t}\n\n\t\tCLIDisplay.break();\n\t}\n\n\treturn restRoutes;\n}\n"]}
package/docs/changelog.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.18](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.3-next.17...ts-to-openapi-v0.0.3-next.18) (2026-03-19)
4
+
5
+
6
+ ### Features
7
+
8
+ * add jsdoc default value to schema ([7886a84](https://github.com/twinfoundation/tools/commit/7886a84961e692d2054f223e2e99205a654b76a6))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/tools-core bumped from 0.0.3-next.17 to 0.0.3-next.18
16
+ * @twin.org/tools-models bumped from 0.0.3-next.17 to 0.0.3-next.18
17
+
3
18
  ## [0.0.3-next.17](https://github.com/twinfoundation/tools/compare/ts-to-openapi-v0.0.3-next.16...ts-to-openapi-v0.0.3-next.17) (2026-03-19)
4
19
 
5
20
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/ts-to-openapi",
3
- "version": "0.0.3-next.17",
3
+ "version": "0.0.3-next.18",
4
4
  "description": "Generate OpenAPI specifications from REST route definitions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,8 +17,8 @@
17
17
  "@twin.org/cli-core": "next",
18
18
  "@twin.org/core": "next",
19
19
  "@twin.org/nameof": "next",
20
- "@twin.org/tools-core": "0.0.3-next.17",
21
- "@twin.org/tools-models": "0.0.3-next.17",
20
+ "@twin.org/tools-core": "0.0.3-next.18",
21
+ "@twin.org/tools-models": "0.0.3-next.18",
22
22
  "@twin.org/web": "next",
23
23
  "commander": "14.0.3",
24
24
  "glob": "13.0.6"