Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate WebAPI documentation in swagger json format

I have created a WebAPI using .Net 4.5 and want to document this API using Swagger. I have added swagger-ui in my .Net project. Now when i browse to ../swagger-ui/index.html it successfully opens pet store api-docs (json) in swagger UI format.

My question is how can I create such (swagger) json for my WebAPI controllers and models? As I have put in required XML summaries/comments to c# classes and attributes.

I saw that Swagger.Net and Swashbuckle are there doing similar things but I could not really understand how to generate swagger-json file using any of them. There might be very small mistake I am doing but unable to point out.

Please help.

like image 778
theGeekster Avatar asked Jan 24 '14 15:01

theGeekster


People also ask

How do I create API document with Swagger?

Head over to Swagger Inspector, and insert the end point of the resource you want to have documented. You can then navigate to the right panel from the History section of Swagger Inspector, and click "Create API definition" to create the OAS definition.

Is REST API documentation template available on Swagger?

Note that Swagger not only helps us to design and document REST APIs, it also lets us build (Server Stub) and Consume (Rest Clients) REST APIs. The major Swagger tools include: Swagger Editor — browser-based editor where one can write OpenAPI specification.


1 Answers

As stated, /swagger takes you to the swagger UI.

If you're using Swashbuckle, then /swagger/docs/v1 should take you to the swagger.json file - I found this using Chrome Dev tools.

Edit: if you're using Swashbuckle.AspNetCore, then the url is slightly different - /swagger/v1/swagger.json

like image 90
Matt Frear Avatar answered Oct 06 '22 07:10

Matt Frear