在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:swagger-api/swagger-node开源软件地址:https://github.com/swagger-api/swagger-node开源编程语言:JavaScript 80.1%开源软件介绍:The Remember, one great thing about this approach is that all of the Swagger validation logic is handled for you, and all of the routing logic is managed through the Swagger configuration. You don't have to code (or recode!) any of that stuff yourself. Your swagger API in five steps1. Install the swagger moduleInstall using npm. For complete instructions, see the install page. $ npm install -g swagger 2. Create a new swagger projectUse the CLI to create and manage projects. Learn more on the quick start page. $ swagger project create hello-world 3. Design your API in the Swagger EditorThe interactive, browser-based Swagger Editor is built in. It provides Swagger 2.0 validation and endpoint routing, generates docs on the fly, and consumes easy-to-read YAML. $ swagger project edit 4. Write controller code in Node.jsCode your API's business logic in Node.js. function hello(req, res) {
var name = req.swagger.params.name.value || 'stranger';
var hello = util.format('Hello, %s!', name);
res.json({ "message": hello });
} If you look at the Swagger file in the editor (shown in step 3 above), the paths:
/hello:
x-swagger-router-controller: hello_world Controller source code is always placed in The 5. Run the serverRun the project server. $ swagger project start Now, call the API!It just works! $ curl http://127.0.0.1:10010/hello?name=Scott
{ "message": "Hello, Scott!" } Installing the swagger moduleSee the Installing swagger for details. Using the swagger moduleGo to the swagger module doc page. It includes all the information you need to get started. About this projectThis initiative grew out of Apigee-127, an API design-first development framework using Swagger. Apigee donated the code to create the swagger-node project in 2015.
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论