/// <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('/'));
        }
Пример #2
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",
            });
        }
Пример #3
0
 private static void Configure(string version, SwaggerDocsConfig config)
 {
     config.SingleApiVersion(version, "Demo.Api");
     config.UseFullTypeNameInSchemaIds();
 }
Пример #4
0
 private void ConfigureSwaggerDocs(SwaggerDocsConfig swaggerDocsConfig)
 {
     swaggerDocsConfig.SingleApiVersion("v1", this.GetType().Assembly.GetName().Name);
     swaggerDocsConfig.UseFullTypeNameInSchemaIds();
 }