public SwaggerDocument GetSwagger(
            string documentName,
            string host      = null,
            string basePath  = null,
            string[] schemes = null)
        {
            var schemaRegistry = _schemaRegistryFactory.Create();

            Info info;

            if (!_settings.SwaggerDocs.TryGetValue(documentName, out info))
            {
                throw new UnknownSwaggerDocument(documentName);
            }

            var apiDescriptions = _apiDescriptionsProvider.ApiDescriptionGroups.Items
                                  .SelectMany(group => group.Items)
                                  .Where(apiDesc => _settings.DocInclusionPredicate(documentName, apiDesc))
                                  .Where(apiDesc => !_settings.IgnoreObsoleteActions || !apiDesc.IsObsolete())
                                  .OrderBy(_settings.SortKeySelector);

            var paths = apiDescriptions
                        .GroupBy(apiDesc => apiDesc.RelativePathSansQueryString())
                        .ToDictionary(group => "/" + group.Key, group => CreatePathItem(group, schemaRegistry));

            var securityDefinitions  = _settings.SecurityDefinitions;
            var securityRequirements = _settings.SecurityRequirements;

            var swaggerDoc = new SwaggerDocument
            {
                Info                = info,
                Host                = host,
                BasePath            = basePath,
                Schemes             = schemes,
                Paths               = paths,
                Definitions         = schemaRegistry.Definitions,
                SecurityDefinitions = securityDefinitions.Any() ? securityDefinitions : null,
                Security            = securityRequirements.Any() ? securityRequirements : null
            };

            var filterContext = new DocumentFilterContext(
                _apiDescriptionsProvider.ApiDescriptionGroups,
                apiDescriptions,
                schemaRegistry);

            foreach (var filter in _settings.DocumentFilters)
            {
                filter.Apply(swaggerDoc, filterContext);
            }

            return(swaggerDoc);
        }
        public SwaggerDocument GetSwagger(
            string documentName,
            string host      = null,
            string basePath  = null,
            string[] schemes = null)
        {
            if (!_settings.SwaggerDocs.TryGetValue(documentName, out Info info))
            {
                throw new UnknownSwaggerDocument(documentName);
            }

            var applicableApiDescriptions = _apiDescriptionsProvider.ApiDescriptionGroups.Items
                                            .SelectMany(group => group.Items)
                                            .Where(apiDesc => _settings.DocInclusionPredicate(documentName, apiDesc))
                                            .Where(apiDesc => !_settings.IgnoreObsoleteActions || !apiDesc.IsObsolete());

            var schemaRegistry = _schemaRegistryFactory.Create();

            var swaggerDoc = new SwaggerDocument
            {
                Info                = info,
                Host                = host,
                BasePath            = basePath,
                Schemes             = schemes,
                Paths               = CreatePathItems(applicableApiDescriptions, schemaRegistry),
                Definitions         = schemaRegistry.Definitions,
                SecurityDefinitions = _settings.SecurityDefinitions.Any() ? _settings.SecurityDefinitions : null,
                Security            = _settings.SecurityRequirements.Any() ? _settings.SecurityRequirements : null
            };

            var filterContext = new DocumentFilterContext(
                _apiDescriptionsProvider.ApiDescriptionGroups,
                applicableApiDescriptions,
                schemaRegistry);

            foreach (var filter in _settings.DocumentFilters)
            {
                filter.Apply(swaggerDoc, filterContext);
            }

            return(swaggerDoc);
        }