zgq
2021-03-25 bc81b23e1d91484507deddc6d4c74fe162042ebd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
using System.Web.Http;
using WebActivatorEx;
using WebAPI;
using Swashbuckle.Application;
 
[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]
 
namespace WebAPI
{
    public class SwaggerConfig
    {
        public static void Register()
        {
            //var thisAssembly = typeof(SwaggerConfig).Assembly;
 
            //GlobalConfiguration.Configuration 
            //    .EnableSwagger(c =>
            //        {
            //            c.SingleApiVersion("v1", "WebAPI");
 
            //            c.MultipleApiVersions(
            //                (apiDesc, targetApiVersion) => ResolveVersionSupportByRouteConstraint(apiDesc, targetApiVersion),
            //                (vc) =>
            //                {
            //                    vc.Version("v2", "Swashbuckle Dummy API V2");
            //                    vc.Version("v1", "Swashbuckle Dummy API V1");
            //                });
 
            //            c.BasicAuth("basic")
            //                .Description("Basic HTTP Authentication");
 
            //            c.ApiKey("apiKey")
            //                .Description("API Key Authentication")
            //                .Name("apiKey")
            //                .In("header");
 
            //            c.OAuth2("oauth2")
            //                .Description("OAuth2 Implicit Grant")
            //                .Flow("implicit")
            //                .AuthorizationUrl("http://petstore.swagger.wordnik.com/api/oauth/dialog")
            //                //.TokenUrl("https://tempuri.org/token")
            //                .Scopes(scopes =>
            //                {
            //                    scopes.Add("read", "Read access to protected resources");
            //                    scopes.Add("write", "Write access to protected resources");
            //                });
 
            //            c.IgnoreObsoleteActions();
 
            //            c.GroupActionsBy(apiDesc => apiDesc.HttpMethod.ToString());
 
            //            c.OrderActionGroupsBy(new DescendingAlphabeticComparer());
 
            //            c.MapType<ProductType>(() => new Schema { type = "integer", format = "int32" });
 
            //            c.SchemaFilter<ApplySchemaVendorExtensions>();
 
            //            c.IgnoreObsoleteProperties();
 
            //            c.UseFullTypeNameInSchemaIds();
 
            //            c.DescribeAllEnumsAsStrings();
 
            //            c.OperationFilter<AddDefaultResponse>();
                        
            //            c.OperationFilter<AssignOAuth2SecurityRequirements>();
 
            //            c.DocumentFilter<ApplyDocumentVendorExtensions>();
 
            //            c.IncludeXmlComments(GetXmlCommentsPath());
 
            //            c.ResolveConflictingActions(apiDescriptions => apiDescriptions.First());
            //        })
            //    .EnableSwaggerUi(c =>
            //        {
            //            c.InjectStylesheet(containingAssembly, "Swashbuckle.Dummy.SwaggerExtensions.testStyles1.css");
 
            //            c.InjectJavaScript(thisAssembly, "Swashbuckle.Dummy.SwaggerExtensions.testScript1.js");
 
            //            c.BooleanValues(new[] { "0", "1" });
 
            //            c.DocExpansion(DocExpansion.List);
 
            //            c.CustomAsset("index", containingAssembly, "YourWebApiProject.SwaggerExtensions.index.html");
 
            //            c.EnableDiscoveryUrlSelector();
 
            //            c.EnableOAuth2Support("test-client-id", "test-realm", "Swagger UI");
            //        });
        }
    }
}