Swagger for WebApi

Swashbuckle - Swagger for WebApi

 Recently I had faced issue while working with large team; more or less currently, we are targeting our application architecture as SOA/ Rest. While doing so we sometimes face issue related to documentation for method/api action part and keep trailing for input/ output signature for the entity to implement. Therefore, I thought to write a step to ease this problem with proper documentation and  API explorer




Swagger
Swagger is a unique technique to represent RESTfull Web API. We can configure Swagger in web application. It’s easy to use and integrate inside our MVC WebAPI project.

In other words, we can say, Swagger is technique, which enable cross team / Dev/UX to seamlessly work with integrated environment without any hurdle, which includes each and everything from the front-end user interfaces.We can say this is  API management solutions.

Command Options

Via Solution
  Right click on Solution =>click on "Manage NuGet Packages" and search "swagger"




Via PMC





PM>Install-Package Swashbuckle -Version 5.6.0



Setting to default swagger UI as output
public static class WebApiConfig
    {
        public static void Register(HttpConfiguration config)
        {
            // Web API configuration and services

            // Web API routes
            config.MapHttpAttributeRoutes();

            config.Routes.MapHttpRoute(
            name: "swagger_root",
            routeTemplate: "",
            defaults: null,
            constraints: null,
            handler: new RedirectHandler((message => message.RequestUri.ToString()), "swagger"));

            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
            );
        }
    }



Run the solution


Multiple option to test / check you function with parameters from web pages.   
Swagger for WebApi Reviewed by Rupesh on 21:15 Rating: 5

No comments:

All Rights Reserved by Technology from Developers Eye © 2014 - 2015
Powered By Blogger, Designed by Aadics
Disclaimers:: The information provided within this blogsite is for general informational purposes only. While we try to keep the information up-to-date and correct, there are no representations or warranties, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the information, products, services, or related graphics contained in this blogsite for any purpose.The author does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause.

Contact Form

Name

Email *

Message *

Powered by Blogger.