使用swagger-jsdoc记录Express API的确切步骤是什么?

Tal*_*har 5 javascript api node.js express swagger

我想使用NPM的swagger-jsdoc记录我的快速路由器端点。我从来没有用过用户,我想知道在我的代码中编写它的确切步骤,以及最终我将如何生成YAML / JSON文档文件。


router.post('/docToSafe', (req, res, next) => {

  let SafeProperties = req.body.SafeProperties;
  let DocumentsArray = req.body.Documents;


  if ((SafeProperties.PathToSafe) && (SafeProperties.ZipName) && (DocumentsArray[0].DocID)) {

    res.writeHead(200, { 'content-type': 'text/plain' });
    res.end();

  }

  else {

    res.writeHead(500, { 'content-type': 'text/plain' });
    res.end();

  }
}

Run Code Online (Sandbox Code Playgroud)