Generate JSON Schema for ASP.Net Web API

2020-06-12 03:47发布

问题:

I'm looking to generate JSON Schema for a WebAPI, including documentation from the XML comments. Its primarily so that I can then import that into our API docs (using apiary.io) I've managed to get a workaround solution by adding swagger (and swashbuckle) and then using the raw link on each service - but ideally I'd like something a bit cleaner, that works across all apis (this has to be done per service / controller), and didnt have so many dependencies.

Before I go and look at how swagger is doing this and seeing if it can be extracted, would be good to know if there are existing ways to do this?

回答1:

Yes, you can depend on Swagger and there is extension for it named swashbuckle which you can use it with Web API easily, check this post http://bitoftech.net/2014/08/25/asp-net-web-api-documentation-using-swagger/