<commit_before>// Copyright (c) <NAME>, 2017. All rights reserved.
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information.

namespace MartinCostello.LondonTravel.Site.Extensions
{
    using System;
    using System.IO;
    using System.Reflection;
    using MartinCostello.LondonTravel.Site.Swagger;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.DependencyInjection;
    using Options;
    using Swashbuckle.AspNetCore.Swagger;
    using Swashbuckle.AspNetCore.SwaggerGen;

    /// <summary>
    /// A class containing Swagger-related extension methods for the <see cref="IServiceCollection"/> interface. This class cannot be inherited.
    /// </summary>
    public static class SwaggerServiceCollectionExtensions
    {
        /// <summary>
        /// Adds Swagger to the services.
        /// </summary>
        /// <param name="value">The <see cref="IServiceCollection"/> to add the service to.</param>
        /// <param name="environment">The current hosting environment.</param>
        /// <returns>
        /// The value specified by <paramref name="value"/>.
        /// </returns>
        public static IServiceCollection AddSwagger(this IServiceCollection value, IHostingEnvironment environment)
        {
            return value.AddSwaggerGen(
                (p) =>
                {
                    var provider = value.BuildServiceProvider();
                    var options = provider.GetRequiredService<SiteOptions>();

                    var terms = new UriBuilder()
                    {
                        Scheme = "https",
                        Host = options.Metadata.Domain,
                        Path = "terms-of-service/",
                    };

                    var info = new Info()
                    {
                        Contact = new Contact()
                        {
                            Name = options.Metadata.Author.Name,
                            Url = options.Metadata.Repository,
                        },
                        Description = options.Metadata.Description,
                        License = new License()
                        {
                            Name = "Apache 2.0",
                            Url = "http://www.apache.org/licenses/LICENSE-2.0.html",
                        },
                        TermsOfService = terms.Uri.ToString(),
                        Title = options.Metadata.Name,
                        Version = string.Empty,
                    };

                    p.DescribeAllEnumsAsStrings();
                    p.DescribeStringEnumsInCamelCase();

                    p.IgnoreObsoleteActions();
                    p.IgnoreObsoleteProperties();

                    AddXmlCommentsIfExists(p, environment, "LondonTravel.Site.xml");

                    p.SwaggerDoc("api", info);<commit_msg>HTTPS for licence URL<commit_after>// Copyright (c) <NAME>, 2017. All rights reserved.
// Licensed under the Apache 2.0 license. See the LICENSE file in the project root for full license information.

namespace MartinCostello.LondonTravel.Site.Extensions
{
    using System;
    using System.IO;
    using System.Reflection;
    using MartinCostello.LondonTravel.Site.Swagger;
    using Microsoft.AspNetCore.Hosting;
    using Microsoft.Extensions.DependencyInjection;
    using Options;
    using Swashbuckle.AspNetCore.Swagger;
    using Swashbuckle.AspNetCore.SwaggerGen;

    /// <summary>
    /// A class containing Swagger-related extension methods for the <see cref="IServiceCollection"/> interface. This class cannot be inherited.
    /// </summary>
    public static class SwaggerServiceCollectionExtensions
    {
        /// <summary>
        /// Adds Swagger to the services.
        /// </summary>
        /// <param name="value">The <see cref="IServiceCollection"/> to add the service to.</param>
        /// <param name="environment">The current hosting environment.</param>
        /// <returns>
        /// The value specified by <paramref name="value"/>.
        /// </returns>
        public static IServiceCollection AddSwagger(this IServiceCollection value, IHostingEnvironment environment)
        {
            return value.AddSwaggerGen(
                (p) =>
                {
                    var provider = value.BuildServiceProvider();
                    var options = provider.GetRequiredService<SiteOptions>();

                    var terms = new UriBuilder()
                    {
                        Scheme = "https",
                        Host = options.Metadata.Domain,
                        Path = "terms-of-service/",
                    };

                    var info = new Info()
                    {
                        Contact = new Contact()
                        {
                            Name = options.Metadata.Author.Name,
                            Url = options.Metadata.Repository,
                        },
                        Description = options.Metadata.Description,
                        License = new License()
                        {
                            Name = "Apache 2.0",
                            Url = "https://www.apache.org/licenses/LICENSE-2.0.html",
                        },
                        TermsOfService = terms.Uri.ToString(),
                        Title = options.Metadata.Name,
                        Version = string.Empty,
                    };

                    p.DescribeAllEnumsAsStrings();
                    p.DescribeStringEnumsInCamelCase();

                    p.IgnoreObsoleteActions();
                    p.IgnoreObsoleteProperties();

                    AddXmlCommentsIfExists(p, environment, "LondonTravel.Site.xml");

                    p.SwaggerDoc("api", info);
{'fraction_non_alphanumeric': 0.09342263438090331, 'fraction_numerical': 0.003434655675768504, 'mean_word_length': 1.416597510373444, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 35, 'https://': 1, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4045891', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1268, 'n_words': 324}