Esempio n. 1
0
        private static void ApplyCommonSwaggerConfiguration(SwaggerDocsConfig c, IUnityContainer container, string cacheKey, string[] xmlCommentsFilePaths)
        {
            var cacheManager = container.Resolve <ICacheManager <object> >();

            c.CustomProvider(defaultProvider => new CachingSwaggerProvider(defaultProvider, cacheManager, cacheKey));
            c.MapType <object>(() => new Schema {
                type = "object"
            });
            c.IgnoreObsoleteProperties();
            c.DescribeAllEnumsAsStrings();
            c.OperationFilter(() => new OptionalParametersFilter());
            c.OperationFilter(() => new FileResponseTypeFilter());
            c.OperationFilter(() => new FileUploadOperationFilter());
            c.OperationFilter(() => new AssignOAuth2SecurityOperationFilter());
            c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
            c.RootUrl(message => new Uri(ComputeHostAsSeenByOriginalClient(message), message.GetRequestContext().VirtualPathRoot).ToString());
            c.PrettyPrint();
            c.OAuth2("OAuth2")
            .Description("OAuth2 Resource Owner Password Grant flow")
            .Flow("password")
            .TokenUrl(HttpRuntime.AppDomainAppVirtualPath?.TrimEnd('/') + "/token");

            foreach (var path in xmlCommentsFilePaths)
            {
                c.IncludeXmlComments(path);
            }
        }
Esempio n. 2
0
        private static void ApplyCommonSwaggerConfiguration(SwaggerDocsConfig c, IUnityContainer container, string cacheKey, string[] xmlCommentsFilePaths)
        {
            var cacheManager = container.Resolve <ICacheManager <object> >();

            c.CustomProvider(defaultProvider => new CachingSwaggerProvider(defaultProvider, cacheManager, cacheKey));
            c.MapType <object>(() => new Schema {
                type = "object"
            });
            c.IgnoreObsoleteProperties();
            c.DescribeAllEnumsAsStrings();
            c.OperationFilter(() => new OptionalParametersFilter());
            c.OperationFilter(() => new FileResponseTypeFilter());
            c.OperationFilter(() => new FileUploadOperationFilter());
            c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
            c.RootUrl(message => new Uri(ComputeHostAsSeenByOriginalClient(message), message.GetRequestContext().VirtualPathRoot).ToString());
            c.PrettyPrint();
            c.ApiKey("apiKey")
            .Description("API Key Authentication")
            .Name("api_key")
            .In("header");

            foreach (var path in xmlCommentsFilePaths)
            {
                c.IncludeXmlComments(path);
            }
        }
        public static void ApplyCqlDefaults(this SwaggerDocsConfig c)
        {
            c.OperationFilter <AddAuthorizationHeaderParameterOperationFilter>();
            c.OperationFilter <SupportFlaggedEnums>();
            c.OperationFilter <HideCancellationToken>();

            c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());

            c.DescribeAllEnumsAsStrings();
        }
Esempio n. 4
0
        private static void ApplyCommonSwaggerConfiguration(SwaggerDocsConfig c, IUnityContainer container, string cacheKey, string[] xmlCommentsFilePaths)
        {
            var cacheManager = container.Resolve<ICacheManager<object>>();

            c.CustomProvider(defaultProvider => new CachingSwaggerProvider(defaultProvider, cacheManager, cacheKey));
            c.MapType<object>(() => new Schema { type = "object" });
            c.IgnoreObsoleteProperties();
            c.DescribeAllEnumsAsStrings();
            c.OperationFilter(() => new OptionalParametersFilter());
            c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
            c.RootUrl(message => new Uri(message.RequestUri, message.GetRequestContext().VirtualPathRoot).ToString());
            c.PrettyPrint();
            c.ApiKey("apiKey")
                .Description("API Key Authentication")
                .Name("api_key")
                .In("header");

            foreach (var path in xmlCommentsFilePaths)
            {
                c.IncludeXmlComments(path);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Configures the Swashbuckle document generation, as per Zinc needs.
        /// </summary>
        /// <param name="config">
        /// Swagger configuration options.
        /// </param>
        public static void ZincConfigure(this SwaggerDocsConfig config)
        {
            config.UseFullTypeNameInSchemaIds();
            config.DescribeAllEnumsAsStrings();
            config.SchemaFilter <ZincSchemaFilter>();


            /*
             * Custom types
             */
            config.MapType <Duration>(() => new Swashbuckle.Swagger.Schema()
            {
                type    = "string",
                format  = "duration",
                example = "PT1H",
            });

            config.MapType <Duration?>(() => new Swashbuckle.Swagger.Schema()
            {
                type    = "string",
                format  = "duration",
                example = "PT1H",
            });
        }