Ejemplo n.º 1
0
        protected void Application_Start(object sender, EventArgs e)
        {
            RouteTable.Routes.Add(new ServiceRoute("v1/rest", new WebServiceHostFactory(), typeof(IService1)));
            RouteTable.Routes.Add(new ServiceRoute("api-docs", new WebServiceHostFactory(), typeof(SwaggerWcfEndpoint)));

            var info = new Info
            {
                Description = "Sample Service to test SwaggerWCF",
                Version     = "0.0.1"
            };

            var security = new SecurityDefinitions
            {
                {
                    "api-gateway", new SecurityAuthorization
                    {
                        Type        = "oauth2",
                        Name        = "api-gateway",
                        Description = "Forces authentication with credentials via an api gateway",
                        Flow        = "implicit",
                        Scopes      = new Dictionary <string, string>
                        {
                            { "fu", "use fu scope" },
                            { "bar", "use bar scope" },
                        },
                        AuthorizationUrl = "http://yourapi.net/oauth/token"
                    }
                }
            };

            //
            SwaggerWcfEndpoint.Configure(info, security);
        }
Ejemplo n.º 2
0
        protected void Application_Start(object sender, EventArgs e)
        {
            RouteTable.Routes.Add(new ServiceRoute("v1/rest", new WebServiceHostFactory(), typeof(BookStore)));
            RouteTable.Routes.Add(new ServiceRoute("api-docs", new WebServiceHostFactory(), typeof(SwaggerWcfEndpoint)));

            var info = new Info
            {
                Title       = "Sample Service",
                Description = "Sample Service to test SwaggerWCF",
                Version     = "0.0.1"
                              // etc
            };

            SwaggerWcfEndpoint.Configure(info);
        }
Ejemplo n.º 3
0
        private static SwaggerSchema BuildServiceCommon(string path, Action <SwaggerSchema, IList <string>, List <string>, IList <Type> > buildPaths)
        {
            const string      sectionName = "swaggerwcf";
            SwaggerWcfSection config      =
                (SwaggerWcfSection)(ConfigurationManager.GetSection(sectionName) ?? new SwaggerWcfSection());

            List <Type>   definitionsTypesList = new List <Type>();
            SwaggerSchema service     = new SwaggerSchema();
            List <string> hiddenTags  = SwaggerWcfEndpoint.FilterHiddenTags(path, GetHiddenTags(config));
            List <string> visibleTags = SwaggerWcfEndpoint.FilterVisibleTags(path, GetVisibleTags(config));
            IReadOnlyDictionary <string, string> settings = GetSettings(config);

            ProcessSettings(service, settings);

            buildPaths(service, hiddenTags, visibleTags, definitionsTypesList);

            service.Definitions = DefinitionsBuilder.Process(hiddenTags, visibleTags, definitionsTypesList);

            return(service);
        }