简体   繁体   English

REST API使用Swagger和Node.js以及SQL Server作为数据库

[英]REST API using Swagger and Node.js with SQL Server as DB

I've created a working REST API with Node.js Express that operates CRUD operations within SQL Server. 我已经使用Node.js Express创建了一个有效的REST API,该API在SQL Server中运行CRUD操作。 Now, I am given task to document my API using Swagger. 现在,我得到了使用Swagger记录我的API的任务。 However, my API do not have Swagger modules installed during its creation. 但是,我的API在创建过程中未安装Swagger模块。

I've tried to create a copy of my API using SwaggerHub and generate Node.js server from the API, but found no solution to get it work with SQL Server. 我试图使用SwaggerHub创建我的API的副本并从该API生成Node.js服务器,但是没有找到使它与SQL Server一起使用的解决方案。

Can anyone please enlighten me on Swagger and how to connect my created Swagger API to SQL Server using Node.js Express? 谁能在Swagger上给我带来启发,以及如何使用Node.js Express将创建的Swagger API连接到SQL Server?

Swagger is a set of open-source tools built around the OpenAPI Specification that can help you design, build, document and consume REST APIs Swagger是围绕OpenAPI规范构建的一组开源工具,可以帮助您设计,构建,记录和使用REST API。

OpenAPI Specification (formerly Swagger Specification) is an API description format for REST APIs OpenAPI规范(以前的Swagger规范)是REST API的API描述格式

If you already created a swagger definition file for your API then you can use following tools to generate what you need 如果您已经为API创建了详尽的定义文件,则可以使用以下工具生成所需的内容

Either ways you will have to create database connection and map your data into db table and javascript model. 无论哪种方式,您都必须创建数据库连接并将数据映射到db表和javascript模型。 Like explained in here 就像在这里解释

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM