web API help pages with Swagger / OpenAPI
When consuming a Web API, understanding its various methods can be challenging for a developer. Swagger, also known as OpenAPI, solves the problem of generating useful documentation and help pages for Web APIs. It provides benefits such as interactive documentation, client SDK generation, and API discoverability.
In this article, the Swashbuckle.AspNetCore and NSwag .NET Swagger implementations are showcased:
Swashbuckle.AspNetCore is an open source project for generating Swagger documents for ASP.NET Core Web APIs.
NSwag is another open source project for generating Swagger documents and integrating Swagger UI or ReDoc into ASP.NET Core web APIs. Additionally, NSwag offers approaches to generate C# and TypeScript client code for your API.
What is Swagger / OpenAPI?
Swagger is a language-agnostic specification for describing REST APIs.
The Swagger project was donated to the OpenAPI Initiative, where it's now referred to as OpenAPI.
Both names are used interchangeably; however, OpenAPI is preferred.
It allows both computers and humans to understand the capabilities of a service without any direct access to the implementation (source code, network access, documentation).
One goal is to minimize the amount of work needed to connect disassociated services.
Another goal is to reduce the amount of time needed to accurately document a service.
Swagger specification (swagger.json)
The core to the Swagger flow is the Swagger specification—by default, a document named swagger.json.
It's generated by the Swagger tool chain (or third-party implementations of it) based on your service.
It describes the capabilities of your API and how to access it with HTTP.
It drives the Swagger UI and is used by the tool chain to enable discovery and client code generation.
Here's an example of a Swagger specification, reduced for brevity:
Swagger UI
Swagger UI offers a web-based UI that provides information about the service, using the generated Swagger specification.
Both Swashbuckle and NSwag include an embedded version of Swagger UI, so that it can be hosted in your ASP.NET Core app using a middleware registration call.
The web UI looks like this:
Each public action method in your controllers can be tested from the UI.
Click a method name to expand the section.
Add any necessary parameters, and click Try it out!.
The Swagger UI version used for the screenshots is version 2. For a version 3 example, see Petstore example.
web API help pages with Swagger / OpenAPI的更多相关文章
- ASP.NET Web API Help Pages using Swagger
Understanding the various methods of an API can be a challenge for a developer when building a consu ...
- 利用Swashbuckle生成Web API Help Pages
利用Swashbuckle生成Web API Help Pages 这系列文章是参考了.NET Core文档和源码,可能有人要问,直接看官方的英文文档不就可以了吗,为什么还要写这些文章呢? 原因如下: ...
- 利用Swashbuckle生成Web API Help Pages
利用Swashbuckle生成Web API Help Pages 本文将通过Swagger的.NET Core的实现封装工具Swashbuckle来生成上一篇-<创建ASP.NET Core ...
- 使用ASP.NET Web API Help Pages 创建在线接口文档
操作步骤 1.新建Web API项目 2.在项目Areas文件夹下找到以下文件,取消注释图中代码. 3.右键解决方案,属性,如图设置. 4.运行程序,点击右上角API 接口列表: 详情-无参数: 详情 ...
- Web Api 接口测试工具:Swagger
前言:WebApi接口开发完毕后,交付给前端人员或手机端开发者时接口说明文档是必不可少的配套设备,如果公司流程不规范大家使用口口相传的交接方式,而且没有改进的欲望,那你可以到此为止了.Swagger是 ...
- 在.net core web api项目中安装swagger展示api接口(相当于生成api文档)
1, 建立或打开项目后,在“程序包管理器控制台”中执行以下命令添加包引用: Install-Package Swashbuckle.AspNetCore 2,在项目中打开Startup.cs文件,找 ...
- ASP.NET Core 中文文档 第二章 指南 (09) 使用 Swagger 生成 ASP.NET Web API 在线帮助测试文档
原文:ASP.NET Web API Help Pages using Swagger 作者:Shayne Boyer 翻译:谢炀(kiler) 翻译:许登洋(Seay) 对于开发人员来说,构建一个消 ...
- Swagger 生成 ASP.NET Web API
使用 Swagger 生成 ASP.NET Web API 在线帮助测试文档 原文:ASP.NET Web API Help Pages using Swagger作者:Shayne Boyer翻译: ...
- Web API design
Web API design 28 minutes to read Most modern web applications expose APIs that clients can use to i ...
随机推荐
- 邮件发送模型及其Python应用实例
SMTP(Simple Mail Transfer Protocol) 制定: First:RFC 788 in 1981 Last:RFC 5321 in 2008 端口: TCP 25(SMTP) ...
- iOS xcode6.0使用7.1运行程序 iphone5上下有黑条
转自:http://stackoverflow.com/questions/25817562/black-bars-appear-in-app-when-targeting-ios7-1-or-7-0 ...
- 《从零开始学Swift》学习笔记(Day 62)——Core Foundation框架之内存托管对象与非托管对象
原创文章,欢迎转载.转载请注明:关东升的博客 内存托管对象 Swift中调用Core Foundation函数获得对象时候,对象分为:内存托管对象和内存非托管对象. 内存托管对象就是由编译器帮助管理内 ...
- angular的过滤器
angular有一些自带的过滤器,今天我就来写一下. 首先还是先把导入一个angular插件,再在我们的js中把模块和控制台写上(别忘了在html中写入模块名和在body中写入控制台名,当然控制台名可 ...
- jquery全景拖动查看效果
http://sc.chinaz.com/jiaoben/140722166830.htm
- 删除Windows服务
或者开始→运行 ,输入“regedit”,在HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services 下找到需要删除的服务名,直接删除即可.
- 原!!mysql,几十万条数据中随机抽取1万以内的数据
想了几种方法: 1.将所有符合条件的对象集合都查出来,在代码里做随机. 2.先查出所有符合条件的id,再代码随机需要抽查数量的id,再 到数据库 中 in. 3.利用order by rand() l ...
- 洛谷 P4451 [国家集训队]整数的lqp拆分
洛谷 这个题目是黑题,本来想打表的,但是表调不出来(我逊毙了)! 然后随便打了一个递推,凑出了样例, 竟然. 竟然.. 竟然... A了!!!!!!! 直接:\(f[i]=f[i-1]*2+f[i-2 ...
- 初识python(二)
初识python(二) 1.变量 变量:把程序运行的中间结果临时的存在内存里,以便后续的代码调用. 1.1 声明变量: #!/usr/bin/env python # -*- coding: utf- ...
- 【我的Android进阶之旅】Android Studio如何轻松整理字符串到string.xml中
使用Android Studio一段时间了,还有很多小技巧没有掌握.比如:平常将字符串整理到string.xml中,都是手动的去复制字符串到string.xml中,然后再回来修改引用该字符串的代码,这 ...