📅  最后修改于: 2022-03-11 15:03:11.928000             🧑  作者: Mango
// To load your swagger specification yaml file you need to use a module able to convert
// yaml to json; for instance yamljs.
>> npm install --save yamljs
const express = require('express');
const app = express();
const swaggerUi = require('swagger-ui-express');
const YAML = require('yamljs');
const swaggerDocument = YAML.load('./swagger.yaml');
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));