@trapi/swagger
Version:
Generate Swagger files from a decorator APIs.
34 lines • 1.22 kB
JavaScript
;
/*
* Copyright (c) 2021-2023.
* Author Peter Placzek (tada5hi)
* For the full copyright and license information,
* view the LICENSE file that was distributed with this source code.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.buildMetadata = buildMetadata;
exports.generate = generate;
const metadata_1 = require("@trapi/metadata");
const constants_1 = require("../constants");
const v2_1 = require("./v2");
const v3_1 = require("./v3");
async function buildMetadata(options, tsConfig) {
if ((0, metadata_1.isMetadata)(options.metadata)) {
return options.metadata;
}
return (0, metadata_1.generateMetadata)(options.metadata, tsConfig);
}
async function generate(context) {
const metadata = await buildMetadata(context.options, context.tsConfig);
switch (context.version) {
case constants_1.Version.V3: {
const generator = new v3_1.V3Generator(metadata, context.options);
return await generator.build();
}
default: {
const generator = new v2_1.V2Generator(metadata, context.options);
return await generator.build();
}
}
}
//# sourceMappingURL=module.js.map