Esempio n. 1
0
        public static void Register(HttpConfiguration config)
        {
            Swashbuckle.Bootstrapper.Init(config);

            //     config.Routes.MapHttpRoute(
            //    "swagger_versioned_api_docs",
            //    "swagger/{apiVersion}/api-docs/{resourceName}",
            //    new { resourceName = RouteParameter.Optional },
            //    null,
            //    new SwaggerSpecHandler());

            //config.Routes.MapHttpRoute(
            //    "swagger_api_docs",
            //    "swagger/api-docs/{resourceName}",
            //    new { resourceName = RouteParameter.Optional },
            //    null,
            //    new SwaggerSpecHandler());

            SwaggerSpecConfig.Customize(c =>
            {
                c.IgnoreObsoleteActions();
                c.GroupDeclarationsBy(ResolveResourceName);
                c.ResolveBasePathUsing(ResolveBasePath);
                c.IncludeXmlComments(HostingEnvironment.MapPath("~/App_Data/Northwind.Api.xml"));
            });

            SwaggerUiConfig.Customize(c =>
            {
                c.SupportHeaderParams = true;
                c.DocExpansion        = DocExpansion.List;
                //var ass  = Assembly.GetExecutingAssembly();
                //string[] names = ass.GetManifestResourceNames();
                c.CustomRoute("index.html", Assembly.GetExecutingAssembly(), "Northwind.Api.Swaggerui.index.html");
            });
        }
Esempio n. 2
0
        public static void Customize()
        {
            SwaggerSpecConfig.Customize(c =>
            {
                c.IgnoreObsoleteActions = true;

                c.SubTypesOf <Product>()
                .Include <Book>()
                .Include <Album>()
                .Include <Service>();

                c.SubTypesOf <Service>()
                .Include <Shipping>()
                .Include <Packaging>();

                c.PostFilter <AddStandardErrorCodes>();
                c.PostFilter <AddAuthorizationErrorCodes>();
                c.OperationFilter <ApplyCustomResponseTypes>();

                // Uncomment below to support documentation from Xml Comments
                // c.PostFilter(new ExtractXmlComments());
            });

            SwaggerUiConfig.Customize(c =>
            {
                c.SupportHeaderParams    = true;
                c.DocExpansion           = DocExpansion.List;
                c.SupportedSubmitMethods = new[] { HttpMethod.Get, HttpMethod.Post, HttpMethod.Put, HttpMethod.Head };
                c.AddOnCompleteScript(typeof(SwaggerConfig).Assembly, "Swashbuckle.TestApp.SwaggerExtensions.onComplete.js");
                c.AddStylesheet(typeof(SwaggerConfig).Assembly, "Swashbuckle.TestApp.SwaggerExtensions.customStyles.css");
            });
        }
Esempio n. 3
0
        public static void Register(HttpConfiguration config)
        {
            Swashbuckle.Bootstrapper.Init(config);

            SwaggerSpecConfig.Customize(c =>
            {
                c.ResolveTargetVersionUsing((req) => "2.0");

                c.IgnoreObsoleteActions();

                c.PolymorphicType <Product>(pc => pc
                                            .DiscriminateBy(p => p.Type)
                                            .SubType <Book>()
                                            .SubType <Album>()
                                            .SubType <Service>(sc => sc
                                                               .SubType <Shipping>()
                                                               .SubType <Packaging>()));

                c.OperationFilter <AddStandardResponseCodes>();
                c.OperationFilter <AddAuthResponseCodes>();

                c.IncludeXmlComments(GetXmlCommentsPath());
            });

            SwaggerUiConfig.Customize(c =>
            {
                c.SupportHeaderParams    = true;
                c.DocExpansion           = DocExpansion.List;
                c.SupportedSubmitMethods = new[] { HttpMethod.Get, HttpMethod.Post, HttpMethod.Put, HttpMethod.Head };
                c.InjectJavaScript(typeof(SwaggerConfig).Assembly, "Swashbuckle.Dummy.SwaggerExtensions.testScript1.js");
                c.InjectStylesheet(typeof(SwaggerConfig).Assembly, "Swashbuckle.Dummy.SwaggerExtensions.testStyles1.css");
            });
        }
Esempio n. 4
0
        public void SetUp()
        {
            _swaggerSpecConfig = new SwaggerSpecConfig();
            Handler            = new SwaggerSpecHandler(_swaggerSpecConfig);

            SetUpDefaultRoutesFor(new[] { typeof(ProductsController), typeof(CustomersController) });
        }
Esempio n. 5
0
        public void SetUp()
        {
            _swaggerSpecConfig = new SwaggerSpecConfig();
            Handler            = new SwaggerSpecHandler(_swaggerSpecConfig);

            SetUpDefaultRouteFor <ProductsController>();
        }
Esempio n. 6
0
        public void SetUp()
        {
            var swaggerSpecConfig = new SwaggerSpecConfig();

            Handler = new SwaggerSpecHandler(swaggerSpecConfig);

            SetUpDefaultRouteFor <FromUriParamsController>();
        }
Esempio n. 7
0
        public void Setup()
        {
            SetUpDefaultRouteFor <ProductsController>();

            _swaggerSpecConfig = new SwaggerSpecConfig();
            _swaggerUiConfig   = new SwaggerUiConfig();
            Handler            = new SwaggerUiHandler(_swaggerSpecConfig, _swaggerUiConfig);
        }
Esempio n. 8
0
 public SwaggerGenerator(SwaggerSpecConfig config)
 {
     _config = config;
     _operationSpecGenerator = new OperationSpecGenerator(
         config.CustomTypeMappings,
         config.SubTypesLookup,
         config.OperationFilters,
         config.OperationSpecFilters);
 }
Esempio n. 9
0
        public static void Register()
        {
            Swashbuckle.Bootstrapper.Init(GlobalConfiguration.Configuration);

            // NOTE: If you want to customize the generated swagger or UI, use SwaggerSpecConfig and/or SwaggerUiConfig here ...
            SwaggerSpecConfig.Customize(c =>
            {
                c.IncludeXmlComments(GetXmlCommentsPath());
            });
        }
Esempio n. 10
0
        public void SetUp()
        {
            var swaggerSpecConfig = new SwaggerSpecConfig();

            swaggerSpecConfig.IncludeXmlComments(String.Format(@"{0}\XmlComments.xml", AppDomain.CurrentDomain.BaseDirectory));

            Handler = new SwaggerSpecHandler(swaggerSpecConfig);

            SetUpDefaultRouteFor <ProductsController>();
        }
Esempio n. 11
0
        public static void Register()
        {
            // NOTE: Don't remove this line, it's required to wire-up the swagger routes
            Bootstrapper.Init(GlobalConfiguration.Configuration);

            // NOTE: If you want to customize the generated swagger or UI, use SwaggerSpecConfig and/or SwaggerUiConfig here ...
            SwaggerSpecConfig.Customize(c =>
            {
                c.ResolveTargetVersionUsing(VersionFromApiKey);
                c.ResolveVersionSupportUsing(VersionSupportByAttribute);
            });
        }
Esempio n. 12
0
        public void Setup()
        {
            // Basic config
            _config = new SwaggerSpecConfig()
                      .ResolveBasePath(() => "http://tempuri.org");

            // Get ApiExplorer for TestApp
            var httpConfiguration = new HttpConfiguration();

            WebApiConfig.Register(httpConfiguration);
            _apiExplorer = new ApiExplorer(httpConfiguration);
        }
Esempio n. 13
0
        public static void Register()
        {
            Swashbuckle.Bootstrapper.Init(GlobalConfiguration.Configuration);

            SwaggerSpecConfig.Customize(c =>
            {
                c.IncludeXmlComments(GetXmlCommentsPath());
            });
            //var thisAssembly = typeof(SwaggerConfig).Assembly;

            //GlobalConfiguration.Configuration
            //    .EnableSwagger(c =>
            //    {
            //        c.IncludeXmlComments(GetXmlCommentsPath());
            //        c.SingleApiVersion("v1", "GMfacet");
            //    }
            //).EnableSwaggerUi(c => { });
        }
Esempio n. 14
0
        public static void Register()
        {
            Swashbuckle.Bootstrapper.Init(GlobalConfiguration.Configuration);

            // NOTE: If you want to customize the generated swagger or UI, use SwaggerSpecConfig and/or SwaggerUiConfig here ...
            SwaggerSpecConfig.Customize(c =>
            {
                //c.IgnoreObsoleteActions();
                c.OperationFilter <AddStandardResponseCodes>();
                c.IncludeXmlComments(GetXmlCommentsPath());
            });

            SwaggerUiConfig.Customize(c =>
            {
                c.SupportHeaderParams = true;
                c.DocExpansion        = DocExpansion.Full;
                c.InjectJavaScript(typeof(SwaggerConfig).Assembly, "Microbrewit.Api.Scripts.test.js");
            });
        }
Esempio n. 15
0
        public static void Customize()
        {
            SwaggerSpecConfig.Customize(c =>
            {
                c.PostFilter(new AddErrorCodeFilter(200, "It's all good!"));
                c.PostFilter(new AddErrorCodeFilter(400, "Something's up!"));
                // uncomment this to parse documentation field when using XmlCommentDocumentationProvider
                //c.PostFilter(new AddXmlCommentsParsingFilter());
            });

            SwaggerUiConfig.Customize(c =>
            {
                c.SupportHeaderParams    = true;
                c.DocExpansion           = DocExpansion.Full;
                c.SupportedSubmitMethods = new[] { HttpMethod.Get, HttpMethod.Post, HttpMethod.Put, HttpMethod.Head };
                c.AddOnCompleteScript(typeof(SwaggerConfig).Assembly, "Swashbuckle.TestApp.swagger_ui.ext.onComplete.js");
                c.AddStylesheet(typeof(SwaggerConfig).Assembly, "Swashbuckle.TestApp.swagger_ui.ext.embeddedStylesheet.css");
            });
        }
Esempio n. 16
0
        public void Configuration(IAppBuilder app)
        {
            HttpConfiguration config = new HttpConfiguration();

            //Swashbuckle の設定
            Swashbuckle.Bootstrapper.Init(config);
            SwaggerSpecConfig.Customize(c =>
            {
                var xmlPath = System.String.Format(@"{0}\SwashbuckleOwinHostSample.XML", System.AppDomain.CurrentDomain.BaseDirectory);
                // Self-host でない場合は HttpContext.Current.Server.MapPath("~/bin/SwashbuckleOwinHostSample.XML");

                c.IncludeXmlComments(xmlPath);
            });

            // ASP.NET Web API のルーティング設定
            config.Routes.MapHttpRoute(
                name: "DefaultApi",
                routeTemplate: "api/{controller}/{id}",
                defaults: new { id = RouteParameter.Optional }
                );

            app.UseWebApi(config);
        }
Esempio n. 17
0
        public static void Register(HttpConfiguration config)
        {
            Bootstrapper.Init(config);

            SwaggerSpecConfig.Customize(c =>
            {
                c.ResolveTargetVersionUsing((req) => "2.0");

                c.IgnoreObsoleteActions();

                c.PolymorphicType <Product>(pc => pc
                                            .DiscriminateBy(p => p.Type)
                                            .SubType <Book>()
                                            .SubType <Album>()
                                            .SubType <Service>(sc => sc
                                                               .SubType <Shipping>()
                                                               .SubType <Packaging>()));

                c.OperationFilter <AddStandardResponseCodes>();
                c.OperationFilter <AddAuthorizationResponseCodes>();

                c.IncludeXmlComments(GetXmlCommentsPath());
            });

            SwaggerUiConfig.Customize(c =>
            {
                c.SupportHeaderParams    = true;
                c.DocExpansion           = DocExpansion.List;
                c.SupportedSubmitMethods = new[] { HttpMethod.Get, HttpMethod.Post, HttpMethod.Put, HttpMethod.Head };
                c.InjectJavaScript(typeof(SwaggerConfig).Assembly, "Swashbuckle.TestApp.SwaggerExtensions.customScript.js");
                c.InjectStylesheet(typeof(SwaggerConfig).Assembly, "Swashbuckle.TestApp.SwaggerExtensions.customStyles.css");

                // Experimenting with a custom routing feature - to override index.html and/or serve up additional content
                c.CustomRoute("index.html", typeof(SwaggerConfig).Assembly, "Swashbuckle.TestApp.SwaggerExtensions.index.html");
            });
        }
Esempio n. 18
0
 public SwaggerUiHandler(SwaggerSpecConfig swaggerSpecConfig, SwaggerUiConfig config)
 {
     _swaggerSpecConfig = swaggerSpecConfig;
     _swaggerUiConfig = config;
 }
Esempio n. 19
0
        public static void Register()
        {
            Swashbuckle.Bootstrapper.Init(GlobalConfiguration.Configuration);

            // NOTE: If you want to customize the generated swagger or UI, use SwaggerSpecConfig and/or SwaggerUiConfig here ...
            SwaggerSpecConfig.Customize(c =>
            {
                c.IgnoreObsoleteActions();

                c.ApiInfo(new Info
                {
                    Title       = "Welcome to SSO Architecture Reference API Interactive Documentation",
                    Description = "Architecture Reference API is a reference for restful service which cater's services to EXTJS and AngularJS Sample application created for TCCC-19.",
                    Contact     = "*****@*****.**"
                });


                c.IncludeXmlComments(GetXmlCommentsPath());

                c.OperationFilter <AddStandardResponseCodes>();
                c.OperationFilter <AddAuthResponseCodes>();
                c.OperationFilter <AddOAuth2Scopes>();

                c.Authorization("oauth2", new Authorization
                {
                    Type   = "oauth2",
                    Scopes = new List <Scope>
                    {
                        new Scope {
                            ScopeId = "default", Description = "Use this scope to perform default operations on the API"
                        }
                    },
                    GrantTypes = new GrantTypes
                    {
                        ImplicitGrant = new ImplicitGrant
                        {
                            LoginEndpoint = new LoginEndpoint
                            {
                                Url = Constants.AuthorizationServer.OAuth2AuthorizeEndpoint
                            },
                            TokenName = "access_token"
                        }
                    }
                });
            });

            SwaggerUiConfig.Customize(c =>
            {
                var thisAssembly = typeof(SwaggerConfig).Assembly;

                c.SupportHeaderParams    = true;
                c.DocExpansion           = DocExpansion.List;
                c.SupportedSubmitMethods = new[] { HttpMethod.Get, HttpMethod.Post, HttpMethod.Put, HttpMethod.Head };

                //Inject custom Javascript and Css Style's for Swagger
                c.InjectJavaScript(thisAssembly, "SSOWebApi.SwaggerExtensions.SwaggerScripts.js");
                c.InjectJavaScript(thisAssembly, "SSOWebApi.SwaggerExtensions.SwaggerOAuth.js");
                c.InjectStylesheet(thisAssembly, "SSOWebApi.SwaggerExtensions.SwaggerStyles.css");

                //Enable OAuth on the Swagger UI
                c.EnableOAuth2Support("implicit-SSOWebApi", "SSOWebApi", "SSOWebApi");
            });
        }
 public SwaggerSpecHandler(SwaggerSpecConfig config)
 {
     _swaggerSpecConfig = config;
 }
Esempio n. 21
0
 public void SetUp()
 {
     _swaggerSpecConfig = new SwaggerSpecConfig();
     Handler            = new SwaggerSpecHandler(_swaggerSpecConfig);
 }
Esempio n. 22
0
 public SwaggerSpecHandler()
 {
     _config = SwaggerSpecConfig.StaticInstance;
 }
Esempio n. 23
0
        public static void Register(HttpConfiguration config)
        {
            SwaggerSpecConfig.Customize(c =>
            {
                c.IgnoreObsoleteActions();

                //c.SupportMultipleApiVersions(
                //    new[] { "1.0", "2.0" },
                //    ResolveVersionSupportByRouteConstraint);

                //c.PolymorphicType<Animal>(ac => ac
                //    .DiscriminateBy(a => a.Type)
                //    .SubType<Kitten>());

                c.OperationFilter <AddStandardResponseCodes>();
                c.OperationFilter <AddAuthResponseCodes>();
                c.OperationFilter <AddOAuth2Scopes>();

                c.IncludeXmlComments(GetXmlCommentsPath());

                c.ApiInfo(new Info
                {
                    Title       = "Swashbuckle Dummy",
                    Description = "For testing and experimenting with Swashbuckle features",
                    Contact     = "*****@*****.**"
                });

                c.Authorization("oauth2", new Authorization
                {
                    Type   = "oauth2",
                    Scopes = new List <Scope>
                    {
                        new Scope {
                            ScopeId = "products.read", Description = "View products"
                        },
                        new Scope {
                            ScopeId = "products.manage", Description = "Manage products"
                        }
                    },
                    GrantTypes = new GrantTypes
                    {
                        ImplicitGrant = new ImplicitGrant
                        {
                            LoginEndpoint = new LoginEndpoint
                            {
                                Url = "http://petstore.swagger.wordnik.com/api/oauth/dialog"
                            },
                            TokenName = "access_token"
                        }
                    }
                });
                c.SetRootPath("panel");
                c.SetForceUseSsl(true);
            });

            SwaggerUiConfig.Customize(c =>
            {
                var thisAssembly = typeof(SwaggerConfig).Assembly;

                c.SupportHeaderParams    = true;
                c.DocExpansion           = DocExpansion.List;
                c.SupportedSubmitMethods = new[] { HttpMethod.Get, HttpMethod.Post, HttpMethod.Put, HttpMethod.Head };
                c.EnableDiscoveryUrlSelector();
                //c.InjectJavaScript(thisAssembly, "Swashbuckle.Dummy.SwaggerExtensions.testScript1.js");
                //c.InjectStylesheet(thisAssembly, "Swashbuckle.Dummy.SwaggerExtensions.testStyles1.css");

                c.EnableOAuth2Support("test-client-id", "test-realm", "Swagger UI");
            });
            Swashbuckle.Bootstrapper.Init(config);
        }
Esempio n. 24
0
        public void Setup()
        {
            // Basic config
            _config = new SwaggerSpecConfig()
                .ResolveBasePath(() => "http://tempuri.org");

            // Get ApiExplorer for TestApp
            var httpConfiguration = new HttpConfiguration();
            WebApiConfig.Register(httpConfiguration);
            _apiExplorer = new ApiExplorer(httpConfiguration);
        }