|
1 | 1 | ---
|
2 |
| -title: ASP.NET Core Web API help pages with Swagger / OpenAPI |
| 2 | +title: ASP.NET Core web API documentation with Swagger / OpenAPI |
3 | 3 | author: RicoSuter
|
4 |
| -description: This tutorial provides a walkthrough of adding Swagger to generate documentation and help pages for a Web API app. |
| 4 | +description: This tutorial provides a walkthrough of adding Swagger to generate documentation and help pages for a web API app. |
5 | 5 | ms.author: scaddie
|
6 | 6 | ms.custom: mvc
|
7 |
| -ms.date: 07/06/2020 |
| 7 | +ms.date: 10/29/2020 |
8 | 8 | no-loc: [appsettings.json, "ASP.NET Core Identity", cookie, Cookie, Blazor, "Blazor Server", "Blazor WebAssembly", "Identity", "Let's Encrypt", Razor, SignalR]
|
9 | 9 | uid: tutorials/web-api-help-pages-using-swagger
|
10 | 10 | ---
|
11 |
| -# ASP.NET Core web API help pages with Swagger / OpenAPI |
| 11 | +# ASP.NET Core web API documentation with Swagger / OpenAPI |
12 | 12 |
|
13 | 13 | By [Christoph Nienaber](https://twitter.com/zuckerthoben) and [Rico Suter](https://blog.rsuter.com/)
|
14 | 14 |
|
15 |
| -When consuming a web API, understanding its various methods can be challenging for a developer. [Swagger](https://swagger.io/), also known as [OpenAPI](https://www.openapis.org/), 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. |
| 15 | +Swagger (OpenAPI) is a language-agnostic specification for describing REST APIs. It allows both computers and humans to understand the capabilities of a REST API without direct access to the source code. Its main goals are to: |
16 | 16 |
|
17 |
| -In this article, the [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) and [NSwag](https://github.com/RicoSuter/NSwag) .NET Swagger implementations are showcased: |
| 17 | +* Minimize the amount of work needed to connect decoupled services. |
| 18 | +* Reduce the amount of time needed to accurately document a service. |
18 | 19 |
|
19 |
| -* **Swashbuckle.AspNetCore** is an open source project for generating Swagger documents for ASP.NET Core Web APIs. |
| 20 | +The two main OpenAPI implementations for .NET are [Swashbuckle](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) and [NSwag](https://github.com/RicoSuter/NSwag), see: |
20 | 21 |
|
21 |
| -* **NSwag** is another open source project for generating Swagger documents and integrating [Swagger UI](https://swagger.io/swagger-ui/) or [ReDoc](https://github.com/Rebilly/ReDoc) into ASP.NET Core web APIs. Additionally, NSwag offers approaches to generate C# and TypeScript client code for your API. |
| 22 | +* [Getting Started with Swashbuckle](xref:tutorials/get-started-with-swashbuckle) |
| 23 | +* [Getting Started with NSwag](xref:tutorials/get-started-with-nswag) |
22 | 24 |
|
23 |
| -## What is Swagger / OpenAPI? |
| 25 | +## OpenApi vs. Swagger |
24 | 26 |
|
25 |
| -Swagger is a language-agnostic specification for describing [REST](https://en.wikipedia.org/wiki/Representational_state_transfer) APIs. The Swagger project was donated to the [OpenAPI Initiative](https://www.openapis.org/), 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. |
| 27 | +The Swagger project was donated to the OpenAPI Initiative in 2015 and has since been referred to as OpenAPI. Both names are used interchangeably. However, "OpenAPI" refers to the specification. "Swagger" refers to the family of open-source and commercial products from SmartBear that work with the OpenAPI Specification. Subsequent open-source products, such as [OpenAPIGenerator](https://github.com/OpenAPITools/openapi-generator), also fall under the Swagger family name, despite not being released by SmartBear. |
| 28 | + |
| 29 | +In short: |
| 30 | + |
| 31 | +* OpenAPI is a specification. |
| 32 | +* Swagger is tooling that uses the OpenAPI specification. For example, OpenAPIGenerator and SwaggerUI. |
26 | 33 |
|
27 | 34 | ## OpenAPI specification (openapi.json)
|
28 | 35 |
|
29 |
| -The core to the OpenAPI flow is the specification—by default, a document named *openapi.json*. It's generated by the OpenAPI 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 an OpenAPI specification, reduced for brevity: |
| 36 | +The OpenAPI specification is a document that describes the capabilities of your API. The document is based on the XML and attribute annotations within the controllers and models. It's the core part of the OpenAPI flow and is used to drive tooling such as SwaggerUI. By default, it's named *openapi.json*. Here's an example of an OpenAPI specification, reduced for brevity: |
30 | 37 |
|
31 | 38 | ```json
|
32 | 39 | {
|
@@ -120,7 +127,7 @@ The core to the OpenAPI flow is the specification—by default, a document n
|
120 | 127 |
|
121 | 128 | 
|
122 | 129 |
|
123 |
| -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!**. |
| 130 | +Each public action method in your controllers can be tested from the UI. Select a method name to expand the section. Add any necessary parameters, and select **Try it out!**. |
124 | 131 |
|
125 | 132 | 
|
126 | 133 |
|
|
0 commit comments