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 ...
随机推荐
- 【BZOJ5070】危险的迷宫 最小费用最大流
[BZOJ5070]危险的迷宫 Description JudgeOnline/upload/201710/55.doc Input 第一行是两个整数A与B(1≤A,B≤10),中间用空格分隔,表示该 ...
- 慎用System.Web.HttpContext.Current
每当控制流离开页面派生的Web表单上的代码的时候,HttpContext类的静态属性Current可能是有用的. 使用这个属性,我们可以获取当前请求(Request),响应(Response),会话( ...
- cocos2d-X学习之主要类介绍:精灵角色(CCSprite)
CCSprite是一副2D图像,CCSprite可以通过图像或者图像中的一个矩形子区域创建 如果它的父节点或者任意继承树上的节点是CCspriteBatchNode则具有下述特性: 父节点是CCSpr ...
- 【Redis】redis分页查询理解
偶然在代码中发现一个接口,接口定义说是分页查询,但逻辑实现是Redis.不太理解,Redis怎么分页?后来看到一篇文章,然后了解了. 1.Zrevrange实现 通过SortedSet的zrevran ...
- Oracle Schema Objects——Tables——TableType
Oracle Schema Objects Object Tables object type An Oracle object type is a user-defined type with a ...
- Vmware VsPhere下的VM安装Hyper-v服务
问题:Vmware VsPhere下的VM无法安装Hyper-v服务 解决方案:打开vmware vm的安装目录,然后找到.vmx的文件,然后进行修改 打开w-c-w2012.vmx文件 添加如下 h ...
- client-side internet transfers
curl https://curl.haxx.se/ curl - Open Collective https://opencollective.com/curl#backers curl/curl: ...
- macro-name replacement-text 宏 调试开关可以使用一个宏来实现
C++ 预处理器_w3cschool https://www.w3cschool.cn/cpp/cpp-preprocessor.html C++ 预处理器 预处理器是一些指令,指示编译器在实际编译之 ...
- x265探索与研究(六):main()函数
x265探索与研究(六):main()函数 x265源代码的入口函数是main(),本文分析main()的主要功能. 首先给出main()函数的功能及其代码结构:其次给出main()函数源代码以及分析 ...
- java正则匹配
java正则提取需要用到Matcher类,下面给出案例示例供参考 需要提取车牌号中最后一个数字,比如说:苏A7865提取5,苏A876X提取6import java.util.regex.Matche ...