public SwaggerDocument GetSwagger( string documentName, string host = null, string basePath = null, string[] schemes = null) { if (!_options.SwaggerDocs.TryGetValue(documentName, out Info info)) { throw new UnknownSwaggerDocument(documentName); } var entry = _serviceEntryProvider.GetALLEntries(); entry = entry .Where(apiDesc => _options.DocInclusionPredicateV2(documentName, apiDesc)); var schemaRegistry = _schemaRegistryFactory.Create(); var swaggerDoc = new SwaggerDocument { Info = info, Host = host, BasePath = basePath, Schemes = schemes, Paths = CreatePathItems(entry, schemaRegistry), Definitions = schemaRegistry.Definitions, SecurityDefinitions = _options.SecurityDefinitions.Any() ? _options.SecurityDefinitions : null, Security = _options.SecurityRequirements.Any() ? _options.SecurityRequirements : null }; return(swaggerDoc); }
public SwaggerDocument GetSwagger( string documentName, string host = null, string basePath = null, string[] schemes = null) { if (!_options.SwaggerDocs.TryGetValue(documentName, out Info info)) { throw new UnknownSwaggerDocument(documentName); } var mapRoutePaths = Swagger.AppConfig.SwaggerConfig.Options?.MapRoutePaths; var entries = _serviceEntryProvider.GetALLEntries(); if (mapRoutePaths != null) { foreach (var path in mapRoutePaths) { var entry = entries.Where(p => p.RoutePath == path.SourceRoutePath).FirstOrDefault(); if (entry != null) { entry.RoutePath = path.TargetRoutePath; entry.Descriptor.RoutePath = path.TargetRoutePath; } } } entries = entries .Where(apiDesc => _options.DocInclusionPredicateV2(documentName, apiDesc)); var schemaRegistry = _schemaRegistryFactory.Create(); var swaggerDoc = new SwaggerDocument { Info = info, Host = host, BasePath = basePath, Schemes = schemes, Paths = CreatePathItems(entries, schemaRegistry), Definitions = schemaRegistry.Definitions, SecurityDefinitions = _options.SecurityDefinitions.Any() ? _options.SecurityDefinitions : null, Security = _options.SecurityRequirements.Any() ? _options.SecurityRequirements : null }; return(swaggerDoc); }