Ejemplo n.º 1
0
        private void SetVersionAndComments(SwaggerDocsConfig config, string version, string title)
        {
            string str = string.Empty;

            try
            {
                config.SingleApiVersion(version, title);
                char[] trimChars = new char[] { '\\' };
                str = AppDomain.CurrentDomain.BaseDirectory.Trim(trimChars);
                string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                if (directoryName != null)
                {
                    char[] chArray2 = new char[] { '\\' };
                    if (directoryName.Trim(chArray2) != str)
                    {
                        str = Path.Combine(str, "bin");
                    }
                }
            }
            catch { }
            if (!string.IsNullOrEmpty(str))
            {
                foreach (string str3 in Directory.EnumerateFiles(str, "*.XML").ToArray <string>())
                {
                    config.IncludeXmlComments(str3);
                }
            }
        }
Ejemplo n.º 2
0
 private static void EnableSwagger(SwaggerDocsConfig swaggerDocsConfig)
 {
     swaggerDocsConfig.SingleApiVersion(AppSettings.ApiVersion, $"{AppSettings.ApplicationName} {AppSettings.ApiVersion}");
     swaggerDocsConfig.RootUrl(GetRootUrlFromAppConfig);
     swaggerDocsConfig.IncludeXmlComments(GetXmlCommentsPath());
     swaggerDocsConfig.OperationFilter <SwaggerCorrelationIdHeader>();
     swaggerDocsConfig.OperationFilter <FormatXmlCommentProperties>();
     swaggerDocsConfig.OperationFilter <SwaggerAuthorizationHeader>();
 }
Ejemplo n.º 3
0
 private static void Configure(SwaggerDocsConfig swaggerConf)
 {
     //todo reflection
     swaggerConf.SingleApiVersion("v1", "My Thai Star Email Service");
     //Add swagger documentation
     foreach (var doc in GetXmlDocumentsForSwagger())
     {
         swaggerConf.IncludeXmlComments(GetXmlCommentsPath(doc));
     }
 }
        internal static SwaggerDocsConfig GetDefaultConfigWithTRex()
        {
            SwaggerDocsConfig config = new SwaggerDocsConfig();

            config.SingleApiVersion("v1", "TRexTestApi");
            config.ReleaseTheTRex();
            config.OperationFilter <IncludeParameterNamesInOperationIdFilter>();

            return(config);
        }
Ejemplo n.º 5
0
        protected void SetUpHandler(Action <SwaggerDocsConfig> configure = null)
        {
            var swaggerDocsConfig = new SwaggerDocsConfig();

            swaggerDocsConfig.SingleApiVersion("v1", "Test API");
            swaggerDocsConfig.IncludeAllXmlComments(typeof(SwaggerTestBase).Assembly, AppDomain.CurrentDomain.BaseDirectory);

            configure?.Invoke(swaggerDocsConfig);

            Handler = new SwaggerDocsHandler(swaggerDocsConfig);
        }
        /// <summary>
        /// Configures Swagger and how it integrates into the Http Server
        /// </summary>
        /// <param name="docsConfig"></param>
        private static void ConfigureSwagger(SwaggerDocsConfig docsConfig)
        {
            var assemblyName = Assembly.GetExecutingAssembly().GetName();

            docsConfig.SingleApiVersion(assemblyName.Version.ToString().Replace('.', '_'), $"{assemblyName.Name}.API");
            docsConfig.IncludeXmlComments(HostingEnvironment.MapPath($"~/bin/{assemblyName.Name}.xml"));
            docsConfig.UseFullTypeNameInSchemaIds();

            // This line is specifically for running this api in a virtual directory
            // See https://github.com/domaindrivendev/Swashbuckle/issues/305
            docsConfig.RootUrl(req => req.RequestUri.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~/").TrimEnd('/'));
        }
Ejemplo n.º 7
0
        protected void SetUpHandler(Action <SwaggerDocsConfig> configure = null)
        {
            var swaggerDocsConfig = new SwaggerDocsConfig();

            swaggerDocsConfig.SingleApiVersion("v1", "Test API");

            configure?.Invoke(swaggerDocsConfig);

            Handler = new SwaggerDocsHandler(swaggerDocsConfig)
            {
                IsAuthenticated = () => true
            };
        }
Ejemplo n.º 8
0
        public void SetUpHandler(Action <SwaggerDocsConfig> configure = null)
        {
            var swaggerDocsConfig = new SwaggerDocsConfig();

            swaggerDocsConfig.SingleApiVersion("v1", "Test API");

            if (configure != null)
            {
                configure(swaggerDocsConfig);
            }

            Handler = new SwaggerDocsHandler(swaggerDocsConfig);
        }
Ejemplo n.º 9
0
        internal static void Configure(HttpConfiguration config)
        {
            var swConfig = new SwaggerDocsConfig();

            swConfig.RootUrl(m => GetOwinAppBasePath(m.GetOwinContext()));
            swConfig.OperationFilter(() => new ODataResponcesOperationFilter());
            swConfig.OperationFilter(() => new AddExtendedMetadataOperationFilter());
            swConfig.DocumentFilter(() => new ODataRemoveNotAllowedOperationFilter());
            swConfig.SingleApiVersion("v2", "BlackCoffeeTalk oData Services");
            swConfig.CustomProvider(defaultProvider => new ODataSwaggerProvider(defaultProvider, swConfig, config)
                                    .Configure(odatasw => {
                odatasw.EnableSwaggerRequestCaching();
                odatasw.IncludeNavigationProperties();
            }));
            swConfig.ApiKey("Token")
            .Description("Filling bearer token.")
            .Name("Authorization")
            .In("header");

            config.Routes.MapHttpRoute("swagger_docs", "", new { apiVersion = "v2" }, null, new SwaggerDocsHandler(swConfig));
        }
Ejemplo n.º 10
0
        public static void SetupSwaggerConfig(SwaggerDocsConfig swaggerDocsConfig)
        {
            Contract.Requires(swaggerDocsConfig != null);

            swaggerDocsConfig.SingleApiVersion("v1", "Api_Learn");
        }
Ejemplo n.º 11
0
        public static void SetupSwaggerConfig(SwaggerDocsConfig swaggerDocsConfig)
        {
            Contract.Requires(swaggerDocsConfig != null);

            swaggerDocsConfig.SingleApiVersion("v1", "Api_Learn");
        }
		public static void SetupSwaggerConfig(SwaggerDocsConfig swaggerDocsConfig)
		{
			Contract.Requires(swaggerDocsConfig != null);

			swaggerDocsConfig.SingleApiVersion("v1", "magic_application_name_magic");
		}
Ejemplo n.º 13
0
 private static void UpdateConfig(SwaggerDocsConfig c)
 {
     c.Schemes(new[] { "http", "https" });
     c.SingleApiVersion("v1", "DemoAPI").Description("Specification for Demo API");
 }
Ejemplo n.º 14
0
        public void ConfigureSwagger(SwaggerDocsConfig config)
        {
            config.SingleApiVersion("v1", "HomeLibrary");

            logger.Debug("Swagger doc config completed ...");
        }
Ejemplo n.º 15
0
 private static void Configure(string version, SwaggerDocsConfig config)
 {
     config.SingleApiVersion(version, "Demo.Api");
     config.UseFullTypeNameInSchemaIds();
 }
Ejemplo n.º 16
0
 private static void Configure(SwaggerDocsConfig config)
 {
     config.SingleApiVersion("V1", "Komplett.MobileSignUp.Api");
 }
Ejemplo n.º 17
0
        public void ConfigureSwagger(SwaggerDocsConfig config)
        {
            config.SingleApiVersion("v1", Service.GetName());

            logger.Debug("Swagger doc config completed ...");
        }
Ejemplo n.º 18
0
        public static void SetupSwaggerConfig(SwaggerDocsConfig swaggerDocsConfig)
        {
            Contract.Requires(swaggerDocsConfig != null);

            swaggerDocsConfig.SingleApiVersion("v1", "magic_api_app_title_magic");
        }
Ejemplo n.º 19
0
 private void ConfigureSwaggerDocs(SwaggerDocsConfig swaggerDocsConfig)
 {
     swaggerDocsConfig.SingleApiVersion("v1", this.GetType().Assembly.GetName().Name);
     swaggerDocsConfig.UseFullTypeNameInSchemaIds();
 }