tsoa-next 8.2.0 → 8.2.1
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/spec.d.ts +6 -1
- package/dist/spec.js +40 -2
- package/dist/spec.js.map +1 -1
- package/package.json +3 -3
package/dist/spec.d.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import type { RuntimeSpecConfigSnapshot, SpecGenerator } from '@tsoa-next/runtime';
|
|
1
|
+
import type { EmbeddedSpecGeneratorArtifacts, RuntimeSpecConfigSnapshot, SpecGenerator } from '@tsoa-next/runtime';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a runtime spec generator from a prebuilt OpenAPI artifact embedded into generated route code.
|
|
4
|
+
* This keeps built-in `SpecPath` targets independent from source files and TypeScript analysis at request time.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createEmbeddedSpecGenerator(artifacts: EmbeddedSpecGeneratorArtifacts): SpecGenerator;
|
|
2
7
|
/**
|
|
3
8
|
* Creates a runtime spec generator that lazily builds the OpenAPI document once per generator instance using `@tsoa-next/cli`,
|
|
4
9
|
* then caches the generated spec object and serialized strings for subsequent reads.
|
package/dist/spec.js
CHANGED
|
@@ -33,13 +33,52 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.createEmbeddedSpecGenerator = createEmbeddedSpecGenerator;
|
|
36
37
|
exports.createOpenApiSpecGenerator = createOpenApiSpecGenerator;
|
|
38
|
+
const loadCli = async () => await Promise.resolve().then(() => __importStar(require('@tsoa-next/cli')));
|
|
37
39
|
function assertSpecConfig(config) {
|
|
38
40
|
if (!config) {
|
|
39
41
|
throw new Error('SpecPath requires spec generation settings. Provide spec configuration when generating routes so built-in spec targets can rebuild the OpenAPI document at runtime.');
|
|
40
42
|
}
|
|
41
43
|
return config;
|
|
42
44
|
}
|
|
45
|
+
function serializeEmbeddedJson(spec) {
|
|
46
|
+
return JSON.stringify(spec, null, '\t');
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Creates a runtime spec generator from a prebuilt OpenAPI artifact embedded into generated route code.
|
|
50
|
+
* This keeps built-in `SpecPath` targets independent from source files and TypeScript analysis at request time.
|
|
51
|
+
*/
|
|
52
|
+
function createEmbeddedSpecGenerator(artifacts) {
|
|
53
|
+
const specPromise = Promise.resolve(artifacts.spec);
|
|
54
|
+
const stringCache = new Map();
|
|
55
|
+
const getSpecObject = async () => specPromise;
|
|
56
|
+
const getSpecString = async (format) => {
|
|
57
|
+
const cached = stringCache.get(format);
|
|
58
|
+
if (cached) {
|
|
59
|
+
return cached;
|
|
60
|
+
}
|
|
61
|
+
let stringPromise;
|
|
62
|
+
if (format === 'json') {
|
|
63
|
+
stringPromise = Promise.resolve(artifacts.json ?? serializeEmbeddedJson(artifacts.spec));
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const yaml = artifacts.yaml;
|
|
67
|
+
if (yaml === undefined) {
|
|
68
|
+
stringPromise = Promise.reject(new Error('Embedded spec generator cannot produce YAML because no embedded YAML artifact was provided. Embed `artifacts.yaml` when generating routes, or use `createOpenApiSpecGenerator` if runtime CLI-based serialization is required.'));
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
stringPromise = Promise.resolve(yaml);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
stringCache.set(format, stringPromise);
|
|
75
|
+
return stringPromise;
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
getSpecObject,
|
|
79
|
+
getSpecString,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
43
82
|
/**
|
|
44
83
|
* Creates a runtime spec generator that lazily builds the OpenAPI document once per generator instance using `@tsoa-next/cli`,
|
|
45
84
|
* then caches the generated spec object and serialized strings for subsequent reads.
|
|
@@ -47,12 +86,11 @@ function assertSpecConfig(config) {
|
|
|
47
86
|
function createOpenApiSpecGenerator(config) {
|
|
48
87
|
let specPromise;
|
|
49
88
|
const stringCache = new Map();
|
|
50
|
-
const loadCli = async () => await Promise.resolve().then(() => __importStar(require('@tsoa-next/cli')));
|
|
51
89
|
const getSpecObject = async () => {
|
|
52
90
|
specPromise ??= (async () => {
|
|
53
91
|
const runtimeConfig = assertSpecConfig(config);
|
|
54
92
|
const cli = await loadCli();
|
|
55
|
-
return cli.buildSpec(runtimeConfig.spec, runtimeConfig.compilerOptions, runtimeConfig.ignore,
|
|
93
|
+
return cli.buildSpec(runtimeConfig.spec, runtimeConfig.compilerOptions, runtimeConfig.ignore, runtimeConfig.metadata, runtimeConfig.defaultNumberType);
|
|
56
94
|
})();
|
|
57
95
|
return specPromise;
|
|
58
96
|
};
|
package/dist/spec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../src/spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../src/spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,kEAoCC;AAMD,gEAuCC;AAnGD,MAAM,OAAO,GAAG,KAAK,IAAI,EAAE,CAAC,wDAAa,gBAAgB,GAAC,CAAA;AAE1D,SAAS,gBAAgB,CAAC,MAAkC;IAC1D,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,KAAK,CAAC,qKAAqK,CAAC,CAAA;IACxL,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED,SAAS,qBAAqB,CAAC,IAA4C;IACzE,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AACzC,CAAC;AAED;;;GAGG;AACH,SAAgB,2BAA2B,CAAC,SAAyC;IACnF,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,S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CAAC,CAAA;YAC9C,MAAM,GAAG,GAAG,MAAM,OAAO,EAAE,CAAA;YAC3B,OAAO,GAAG,CAAC,SAAS,CAClB,aAAa,CAAC,IAAI,EAClB,aAAa,CAAC,eAAmE,EACjF,aAAa,CAAC,MAAM,EACpB,aAAa,CAAC,QAAQ,EACtB,aAAa,CAAC,iBAAiB,CAChC,CAAA;QACH,CAAC,CAAC,EAAE,CAAA;QAEJ,OAAO,WAAW,CAAA;IACpB,CAAC,CAAA;IAED,MAAM,aAAa,GAAmC,KAAK,EAAC,MAAM,EAAC,EAAE;QACnE,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;QACtC,IAAI,MAAM,EAAE,CAAC;YACX,OAAO,MAAM,CAAA;QACf,CAAC;QAED,MAAM,aAAa,GAAG,CAAC,KAAK,IAAI,EAAE;YAChC,MAAM,GAAG,GAAG,MAAM,OAAO,EAAE,CAAA;YAC3B,OAAO,GAAG,CAAC,aAAa,CAAC,MAAM,aAAa,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC,CAAA;QACpE,CAAC,CAAC,EAAE,CAAA;QAEJ,WAAW,CAAC,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;QACtC,OAAO,aAAa,CAAA;IACtB,CAAC,CAAA;IAED,OAAO;QACL,aAAa;QACb,aAAa;KACd,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tsoa-next",
|
|
3
|
-
"version": "8.2.
|
|
3
|
+
"version": "8.2.1",
|
|
4
4
|
"description": "Build swagger-compliant REST APIs using TypeScript and Node",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"typings": "./dist/index.d.ts",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"author": "Vanna DiCatania <vanna@dicatania.me> (http://www.dicatania.me)",
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@tsoa-next/cli": "8.2.
|
|
36
|
-
"@tsoa-next/runtime": "8.2.
|
|
35
|
+
"@tsoa-next/cli": "8.2.1",
|
|
36
|
+
"@tsoa-next/runtime": "8.2.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@types/node": "24.12.0",
|