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 ...
随机推荐
- http协议详解(2)
HTTP报文是面向文本的,报文中的每一个字段都是一些ASCII码串,各个字段的长度是不确定的.HTTP有两类报文:请求报文和响应报文. HTTP请求报文 一个HTTP请求报文由请求行(request ...
- 【BZOJ3439】Kpm的MC密码 Trie树+可持久化线段树
[BZOJ3439]Kpm的MC密码 Description 背景 想Kpm当年为了防止别人随便进入他的MC,给他的PC设了各种奇怪的密码和验证问题(不要问我他是怎么设的...),于是乎,他现在理所当 ...
- 用angular做的模糊搜索
今天大家来试一试用angular做一下简单的搜索功能吧: 首先我们需要写html的部分,我们需要设置几个条件,比如按什么来排序,按升序还是降序搜索,和一个文本框来设置模糊搜索: <nav> ...
- 【IE兼容性】代码中多语言样式+IE不兼容解决
一.代码中样式根据不同语言对IE做不兼容解决 二.代码逻辑: 1. 后台返回语言信息: result.addObject("language",getLocaleStr()); ...
- 《挑战程序设计竞赛》2.3 动态规划-优化递推 POJ1742 3046 3181
POJ1742 http://poj.org/problem?id=1742 题意 有n种面额的硬币,面额个数分别为Ai.Ci,求最多能搭配出几种不超过m的金额? 思路 据说这是传说中的男人8题呢,对 ...
- mysql 使用命令执行外部sql文件
语句 source e:\\phpPro\\fileName.sql 注意,不需要再后面加 分号 !!!!!
- kibana 创建饼图
1.在 visualize 里面选择饼图 2.选择数据源 3.选择 terms 聚合类型. 选择字段 xxx.keyword 保存即可.
- 生成vuejs项目
生成项目 npm i -g vue-cli > mkdir my-project && cd my-project > vue init webpack npm i ...
- ORACLE性能优化- Buffer cache 的调整与优化
Buffer Cache是SGA的重要组成部分,主要用于缓存数据块,其大小也直接影响系统的性能.当Buffer Cache过小的时候,将会造成更多的 free buffer waits事件. 下面将具 ...
- Deeplearning——动态图 vs. 静态图
动态图 vs. 静态图 在 fast.ai,我们在选择框架时优先考虑程序员编程的便捷性(能更方便地进行调试和更直观地设计),而不是框架所能带来的模型加速能力.这也正是我们选择 PyTorch 的理由, ...