# swagger_nodejs **Repository Path**: openks/swagger_nodejs ## Basic Information - **Project Name**: swagger_nodejs - **Description**: swagger-node - **Primary Language**: NodeJS - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2017-04-26 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Skeleton project for Swagger nodejs_swagger mock服务器可自定义mock结构但是无法查看所有的mock文档 先安装依赖: `npm i ` 启动项目并使用项目数据 `npm start` 可以不用在`api/controllers`里写`resetfulAPI` 只在`mocks`里写模拟数据 查看全部的文档 `http://localhost:10010/docs` 全局安装`swagger` `npm install -g swagger` 使用mock数据 `swagger project start -m` 启动`Swagger editor` `swagger project edit` 也可在线启用[swager editer](http://editor.swagger.io/#/)并下载相关代码(下载下来的代码与该项目结构不同) 默认不包含`swigger-ui`启用`swigger-ui`方法[如下](https://github.com/swagger-api/swagger-node/issues/362) ``` SwaggerExpress.create(config, (err, swaggerExpress) => { if (err) { throw err; } // Serve the Swagger documents and Swagger UI app.use(swaggerExpress.runner.swaggerTools.swaggerUi()); // install middleware swaggerExpress.register(app); const port = process.env.PORT || 10010; app.listen(port, () => { console.log('Your server is listening on port %d (http://localhost:%d)', port, port); console.log('Swagger-ui is available on http://localhost:%d/docs', port); }); if (swaggerExpress.runner.swagger.paths['/hello']) { console.log(`try this:\ncurl http://127.0.0.1:${port}/hello?name=Scott`); } }); ``` [安装文档在这里](https://github.com/swagger-api/swagger-node) [更多其他文档](https://github.com/swagger-api/swagger-node/blob/master/docs/README.md)