예제 #1
0
        private void Configure()
        {
            var documentationCreator = new DocumentationCreator();

            this.ApplicationBuilder.UseSwagger();
            this.ApplicationBuilder.UseSwaggerUI(options =>
            {
                options.RoutePrefix = this.SwaggerDocumentationRoute;
                documentationCreator.SetConfigurationSwaggerUIMenu(options);
                options.DocExpansion(DocExpansion.List);
                if (this.WithInjectStyleSheet)
                {
                    options.InjectStylesheet(path: this.RelativePathInjectStyleSheet);
                }
            });
        }
예제 #2
0
        private void ConfigureServices()
        {
            var documentationCreator = new DocumentationCreator();

            this.ServiceCollection.AddSwaggerGen(options =>
            {
                documentationCreator.SetConfigurationSwaggerDoc(options);

                options.IncludeXmlComments(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, System.AppDomain.CurrentDomain.FriendlyName + @".xml"));
                options.DescribeAllEnumsAsStrings();
                options.AddSecurityDefinition(this.TokenType, this.ApiKeyScheme);
                options.AddSecurityRequirement(new Dictionary <string, IEnumerable <string> > {
                    { this.TokenType, Enumerable.Empty <string>() }
                });

                options.DocInclusionPredicate((version, apiDescription) => { return(documentationCreator.ShowOnlyVersionMethodsInSwagger(version, apiDescription)); });
            });
        }
예제 #3
0
        private void ConfigureServices()
        {
            var documentationCreator = new DocumentationCreator();

            this.ServiceCollection.AddSwaggerGen(options =>
            {
                documentationCreator.SetConfigurationSwaggerDoc(options);

                options.IncludeXmlComments(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, System.AppDomain.CurrentDomain.FriendlyName + @".xml"));

                if (this.HasAuthentication)
                {
                    options.AddSecurityDefinition(this.SecurityDefinitionName, this.SecurityScheme);
                    options.AddSecurityRequirement(this.SecurityRequirement);
                }

                options.DocInclusionPredicate((version, apiDescription) => { return(documentationCreator.ShowOnlyVersionMethodsInSwagger(version, apiDescription)); });
            });
        }