Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Auto Generate Documentation for ASP.net WebAPI

I currently have a MVC project in ASP.Net that is using a WebApi. Most of the code for the controllers is written in c#. I'd like to automatically generate a description of API calls including:

1.) The url of the page/endpoint

2.) Description of what endpoint/page does

3.) List of arguments with descriptions and datatypes.

4.) HTTP Verb (get, post, put, delete)

5.) The permissions required for the page

The description will have to be written manually.

I've read quite a few other articles that result in the individual using a 3rd party application like Swagger. Is there something built in to ASP.Net to help with this? If I wanted to try to generate documentation myself (without using 3rd party software), how would I get started on creating such documentation?

I've spent a fair amount of time googling various queries and can't seem to find an answer.

Edit: What's the benefit of using Swagger over ASP.Net help pages in my case?

like image 513
Speerian Avatar asked Jun 12 '15 14:06

Speerian


People also ask

How does Swagger generate documentation?

Use Swagger Inspector to quickly generate your OAS-based documentation for existing REST APIs by calling each end point and using the associated response to generate OAS-compliant documentation, or string together a series of calls to generate a full OAS document for multiple API endpoints.


2 Answers

As an alternative to Swagger you can make use of the 'Help Pages' for ASP.NET Web API.

Entries within this documentation are generated automatically and will contain information such as:

  • Relative URI

  • HTTP Method

  • Sample Request/Response data

  • A description of the API purpose (derived from XML comments)

If using a third party component is possible then I would recommend you use Swagger (Use the Swashbuckle NuGet package) to achieve API documentation.

like image 55
Jamie Keeling Avatar answered Oct 22 '22 03:10

Jamie Keeling


Swagger does not just list your api uris. Users actually try them out and see the response

Swagger has tools to create the documentation before you implement it.

It can also add description using the comments.

like image 5
Nick Avatar answered Oct 22 '22 02:10

Nick