Esempio n. 1
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)); });
            });
        }
Esempio n. 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"));

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

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