Exemplo n.º 1
0
        public static IHost GenerateOpenApiDocument(this IHost host)
        {
            string API_DOCUMENT   = Environment.GetEnvironmentVariable("API_DOCUMENT");
            string CONTAINER_HOST = Environment.GetEnvironmentVariable("CONTAINER_HOST");
            string CONTAINER_PATH = Environment.GetEnvironmentVariable("CONTAINER_PATH");

            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }

            ISwaggerProvider provider = (ISwaggerProvider)host.Services.GetService(typeof(ISwaggerProvider));
            OpenApiDocument  document = provider.GetSwagger("api", CONTAINER_HOST, CONTAINER_PATH);

            StringWriter writer = new StringWriter();

            document.SerializeAsV3(new OpenApiJsonWriter(writer));

            string path = Path.Combine(AppContext.BaseDirectory, API_DOCUMENT);

            Directory.CreateDirectory(Path.GetDirectoryName(path));
            File.WriteAllText(path, writer.ToString());

            return(host);
        }
        public async Task Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
        {
            if (!RequestingSwaggerDocument(httpContext.Request, out string documentName))
            {
                await _next(httpContext);

                return;
            }

            var basePath = string.IsNullOrEmpty(httpContext.Request.PathBase)
                ? null
                : httpContext.Request.PathBase.ToString();

            try
            {
                var swagger = swaggerProvider.GetSwagger(documentName, null, basePath);

                // One last opportunity to modify the Swagger Document - this time with request context
                foreach (var filter in _options.PreSerializeFilters)
                {
                    filter(swagger, httpContext.Request);
                }

                await RespondWithSwaggerJson(httpContext.Response, swagger);
            }
            catch (UnknownSwaggerDocument)
            {
                RespondWithNotFound(httpContext.Response);
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ODataSwaggerProvider" /> class.
 /// Use this constructor for self-hosted scenarios.
 /// </summary>
 /// <param name="defaultProvider">The default provider.</param>
 /// <param name="swaggerDocsConfig">The swagger docs configuration.</param>
 /// <param name="httpConfig">The HttpConfiguration that contains the OData Edm Model.</param>
 public ODataSwaggerProvider(ISwaggerProvider defaultProvider, SwaggerDocsConfig swaggerDocsConfig, HttpConfiguration httpConfig)
     : this(defaultProvider, DefaultCompositionRoot.GetSwaggerProviderOptions(swaggerDocsConfig), DefaultCompositionRoot.GetApiVersions(swaggerDocsConfig), DefaultCompositionRoot.GetApiExplorer(httpConfig), httpConfig)
 {
     Contract.Requires(defaultProvider != null);
     Contract.Requires(swaggerDocsConfig != null);
     Contract.Requires(httpConfig != null);
 }
Exemplo n.º 4
0
        private static void Api(ISwaggerProvider swaggerProvider, string resourceName, string apiPath, Action <Api> applyAssertions)
        {
            var api = swaggerProvider.GetDeclaration(RequestedBasePath, RequestedVersion, resourceName).Apis
                      .Single(a => a.Path == apiPath);

            applyAssertions(api);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ODataSwaggerProvider" /> class.
 /// Use this constructor for self-hosted scenarios.
 /// </summary>
 /// <param name="defaultProvider">The default provider.</param>
 /// <param name="swaggerDocsConfig">The swagger docs configuration.</param>
 /// <param name="httpConfig">The HttpConfiguration that contains the OData Edm Model.</param>
 public ODataSwaggerProvider(ISwaggerProvider defaultProvider, SwaggerDocsConfig swaggerDocsConfig, HttpConfiguration httpConfig)
     : this(defaultProvider, DefaultCompositionRoot.GetSwaggerProviderOptions(swaggerDocsConfig), DefaultCompositionRoot.GetApiVersions(swaggerDocsConfig), DefaultCompositionRoot.GetApiExplorer(httpConfig), httpConfig)
 {
     Contract.Requires(defaultProvider != null);
     Contract.Requires(swaggerDocsConfig != null);
     Contract.Requires(httpConfig != null);
 }
        public string Build(
            HttpRequest httpRequest,
            ISwaggerProvider swaggerProvider,
            string documentName)
        {
            var basePath = string.IsNullOrEmpty(httpRequest.PathBase)
                ? null
                : httpRequest.PathBase.ToString();

            var swagger =
                swaggerProvider.GetSwagger(documentName, null, basePath);

            // One last opportunity to modify the Swagger Document - this time with request context
            foreach (var filter in _options.PreSerializeFilters)
            {
                filter(swagger, httpRequest);
            }

            using (var textWriter = new StringWriter())
            {
                var jsonWriter = new OpenApiJsonWriter(textWriter);

                if (_options.SerializeAsV2)
                {
                    swagger.SerializeAsV2(jsonWriter);
                }
                else
                {
                    swagger.SerializeAsV3(jsonWriter);
                }

                return(textWriter.ToString());
            }
        }
Exemplo n.º 7
0
 public SwaggerDocsHandler(
     Func <HttpRequest, string> rootUrlResolver,
     ISwaggerProvider swaggerProvider)
 {
     _rootUrlResolver = rootUrlResolver;
     _swaggerProvider = swaggerProvider;
 }
Exemplo n.º 8
0
 public SwaggerDocsHandler(
     IRootUrlResolver rootUrlResolver,
     ISwaggerProvider swaggerProvider)
 {
     _rootUrlResolver = rootUrlResolver;
     _swaggerProvider = swaggerProvider;
 }
Exemplo n.º 9
0
        private static void Operation(ISwaggerProvider swaggerProvider, string resourceName, string apiPath, int index, string httpMethod,
                                      Action <Operation> applyAssertions)
        {
            var api = swaggerProvider.GetDeclaration(RequestedBasePath, RequestedVersion, resourceName).Apis
                      .Single(a => a.Path == apiPath);

            Operation(api, httpMethod, index, applyAssertions);
        }
Exemplo n.º 10
0
 public SwaggerMiddleware(
     RequestDelegate next,
     ISwaggerProvider swaggerProvider,
     IOptions <MvcJsonOptions> mvcJsonOptionsAccessor,
     IOptions <SwaggerOptions> optionsAccessor)
     : this(next, swaggerProvider, mvcJsonOptionsAccessor, optionsAccessor.Value)
 {
 }
Exemplo n.º 11
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="logger"></param>
 /// <param name="jwtProvider"></param>
 /// <param name="clientFactory"></param>
 /// <param name="mapper"></param>
 /// <param name="swaggerProvider"></param>
 public ValuesController(ILogger <ValuesController> logger, IJwtProvider jwtProvider, IHttpClientFactory clientFactory, IMapper mapper, ISwaggerProvider swaggerProvider)
 {
     _logger          = logger;
     _jwtProvider     = jwtProvider;
     _clientFactory   = clientFactory;
     _mapper          = mapper;
     _swaggerProvider = swaggerProvider;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ODataSwaggerProvider" /> class.
        /// Use this constructor for self-hosted scenarios.
        /// </summary>
        /// <param name="defaultProvider">The default provider.</param>
        /// <param name="swaggerDocsConfig">The swagger docs configuration.</param>
        /// <param name="httpConfig">The HttpConfiguration that contains the OData Edm Model.</param>
        public ODataSwaggerProvider(ISwaggerProvider defaultProvider, SwaggerDocsConfig swaggerDocsConfig, HttpConfiguration httpConfig)
        {
            Contract.Requires(defaultProvider != null);
            Contract.Requires(swaggerDocsConfig != null);
            Contract.Requires(httpConfig != null);

            _defaultProvider = defaultProvider;
            _config = new ODataSwaggerDocsConfig(swaggerDocsConfig, httpConfig);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ODataSwaggerProvider" /> class.
        /// Use this constructor for self-hosted scenarios.
        /// </summary>
        /// <param name="defaultProvider">The default provider.</param>
        /// <param name="swaggerDocsConfig">The swagger docs configuration.</param>
        /// <param name="httpConfig">The HttpConfiguration that contains the OData Edm Model.</param>
        public ODataSwaggerProvider(ISwaggerProvider defaultProvider, SwaggerDocsConfig swaggerDocsConfig, HttpConfiguration httpConfig)
        {
            Contract.Requires(defaultProvider != null);
            Contract.Requires(swaggerDocsConfig != null);
            Contract.Requires(httpConfig != null);

            _defaultProvider = defaultProvider;
            _config          = new ODataSwaggerDocsConfig(swaggerDocsConfig, httpConfig);
        }
 public DocumentProvider(
     IOptions <SwaggerGeneratorOptions> generatorOptions,
     IOptions <SwaggerOptions> options,
     ISwaggerProvider swaggerProvider)
 {
     _generatorOptions = generatorOptions.Value;
     _options          = options.Value;
     _swaggerProvider  = swaggerProvider;
 }
 /// <summary>
 /// Middleware of Open Api
 /// </summary>
 /// <param name="next"></param>
 public OpenApiMiddleware(RequestDelegate next,
                          ISwaggerProvider swaggerProvider,
                          IOptions <MvcJsonOptions> mvcJsonOptions)
 {
     _next               = next;
     _swaggerProvider    = swaggerProvider;
     _swaggerSerializer  = SwaggerSerializerFactory.Create(mvcJsonOptions);
     _requestMatcher     = new TemplateMatcher(TemplateParser.Parse("swagger/{documentName}/swagger.json"), new RouteValueDictionary());
     PreSerializeFilters = new List <Action <SwaggerDocument, HttpRequest> >();
 }
        public MultiOperationSwaggerGenerator(ISwaggerProvider sp)
        {
            var sg            = (SwaggerGenerator)sp;
            var privateFields = sg.GetType().GetFields(BindingFlags.Instance | BindingFlags.NonPublic);

            _apiExplorer            = privateFields.First(pf => pf.Name == "_apiExplorer").GetValue(sg) as IApiExplorer;
            _jsonSerializerSettings = privateFields.First(pf => pf.Name == "_jsonSerializerSettings").GetValue(sg) as JsonSerializerSettings;
            _apiVersions            = privateFields.First(pf => pf.Name == "_apiVersions").GetValue(sg) as IDictionary <string, Info>;
            _options = privateFields.First(pf => pf.Name == "_options").GetValue(sg) as SwaggerGeneratorOptions;
        }
 public SwaggerYamlMiddleware(
     RequestDelegate next,
     ISwaggerProvider swaggerProvider,
     SwaggerYamlOptions options)
 {
     _next              = next;
     _swaggerProvider   = swaggerProvider;
     _swaggerSerializer = SwaggerYamlSerializerFactory.Create(options);
     _options           = options;
     _requestMatcher    = new TemplateMatcher(TemplateParser.Parse(_options.SwaggerOptions.RouteTemplate), new RouteValueDictionary());
 }
Exemplo n.º 18
0
 public RenderSwaggerDocument(
     ISwaggerProvider swaggerProvider,
     IApiDescriptionGroupCollectionProvider collectionProvider,
     IEnumerable <IApiDescriptionProvider> descriptionProviders,
     OpenApiInfo info)
 {
     _swaggerProvider      = swaggerProvider;
     _collectionProvider   = collectionProvider;
     _descriptionProviders = descriptionProviders;
     _info = info;
 }
        public SwaggerModule(ISwaggerProvider provider)
            : base(StaticConfiguration.ModulePath)
        {
            // Register resource listing route
            Get["/"] = _ => CreateStreamedJsonResponse(provider.GetResourceListing(this.ModulePath));

            foreach (var apiDeclaration in provider.GetApiDeclarations())
            {
                Get["/swagger" + apiDeclaration.BasePath] = _ => CreateStreamedJsonResponse(apiDeclaration);
            }
        }
 public SwaggerMiddleware(
     RequestDelegate next,
     ISwaggerProvider swaggerProvider,
     IOptions <MvcNewtonsoftJsonOptions> mvcJsonOptions,
     SwaggerOptions options)
 {
     _next              = next;
     _swaggerProvider   = swaggerProvider;
     _swaggerSerializer = SwaggerSerializerFactory.Create(mvcJsonOptions);
     _options           = options;
     _requestMatcher    = new TemplateMatcher(TemplateParser.Parse(options.RouteTemplate), new RouteValueDictionary());
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ODataSwaggerProvider" /> class.
        /// Use this constructor to customize all <see cref="ODataSwaggerProvider" /> dependencies.
        /// </summary>
        /// <param name="defaultProvider">The default provider.</param>
        /// <param name="options">The options.</param>
        /// <param name="apiVersions">The version information.</param>
        /// <param name="odataApiExplorer">The API explorer.</param>
        /// <param name="httpConfig">The HttpConfiguration that contains the OData Edm Model.</param>
        internal ODataSwaggerProvider(ISwaggerProvider defaultProvider, SwaggerProviderOptions options, IDictionary <string, Info> apiVersions, IApiExplorer odataApiExplorer, HttpConfiguration httpConfig)
        {
            Contract.Requires(defaultProvider != null);
            Contract.Requires(odataApiExplorer != null);
            Contract.Requires(httpConfig != null);
            Contract.Requires(options != null);

            _defaultProvider  = defaultProvider;
            _httpConfig       = httpConfig;
            _options          = new ODataSwaggerProviderOptions(options);
            _apiVersions      = apiVersions;
            _odataApiExplorer = odataApiExplorer;
        }
Exemplo n.º 22
0
 public SwaggerMiddleware(
     RequestDelegate next,
     ISwaggerProvider swaggerProvider,
     IOptions <MvcJsonOptions> mvcJsonOptions,
     Action <HttpRequest, SwaggerDocument> documentFilter,
     string routeTemplate)
 {
     _next              = next;
     _swaggerProvider   = swaggerProvider;
     _swaggerSerializer = SwaggerSerializerFactory.Create(mvcJsonOptions);
     _documentFilter    = documentFilter;
     _requestMatcher    = new TemplateMatcher(TemplateParser.Parse(routeTemplate), new RouteValueDictionary());
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ODataSwaggerProvider" /> class.
        /// Use this constructor to customize all <see cref="ODataSwaggerProvider" /> dependencies.
        /// </summary>
        /// <param name="defaultProvider">The default provider.</param>
        /// <param name="options">The options.</param>
        /// <param name="apiVersions">The version information.</param>
        /// <param name="odataApiExplorer">The API explorer.</param>
        /// <param name="httpConfig">The HttpConfiguration that contains the OData Edm Model.</param>
        internal ODataSwaggerProvider(ISwaggerProvider defaultProvider, SwaggerProviderOptions options, IDictionary<string, Info> apiVersions, IApiExplorer odataApiExplorer, HttpConfiguration httpConfig)
        {
            Contract.Requires(defaultProvider != null);
            Contract.Requires(odataApiExplorer != null);
            Contract.Requires(httpConfig != null);
            Contract.Requires(options != null);

            _defaultProvider = defaultProvider;
            _httpConfig = httpConfig;
            _options = new ODataSwaggerProviderOptions(options);
            _apiVersions = apiVersions;
            _odataApiExplorer = odataApiExplorer;
        }
Exemplo n.º 24
0
 public SwaggerGenMiddleware(
     RequestDelegate next,
     ISwaggerProvider swaggerProvider,
     string routeTemplate)
 {
     _next              = next;
     _swaggerProvider   = swaggerProvider;
     _requestMatcher    = new TemplateMatcher(TemplateParser.Parse(routeTemplate), new RouteValueDictionary());
     _swaggerSerializer = new JsonSerializer
     {
         NullValueHandling = NullValueHandling.Ignore,
         ContractResolver  = new SwaggerGenContractResolver()
     };
 }
Exemplo n.º 25
0
 public SwaggerDocsMiddleware(
     RequestDelegate next,
     ISwaggerProvider swaggerProvider,
     string routeTemplate)
 {
     _next = next;
     _swaggerProvider = swaggerProvider;
     _requestMatcher = new TemplateMatcher(TemplateParser.Parse(routeTemplate), new RouteValueDictionary());
     _swaggerSerializer = new JsonSerializer
     {
         NullValueHandling = NullValueHandling.Ignore,
         ContractResolver = new SwaggerDocsContractResolver()
     };
 }
Exemplo n.º 26
0
        public async Task Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
        {
            if (!RequestingSwaggerDocument(httpContext.Request, out string documentName))
            {
                await _next(httpContext);

                return;
            }

            var basePath = string.IsNullOrEmpty(httpContext.Request.PathBase)
                ? null
                : httpContext.Request.PathBase.ToString();

            try
            {
                SwaggerDocument swagger;

                //if it version 2.0 schemes are not mandatory
                //but to use the Microsoft OpenAPI.NET we need at least one scheme
                if (_optionsOpenAPI.CompabilityLayerActive &&
                    _optionsOpenAPI.Version == OpenApiSpecVersion.OpenApi2_0)
                {
                    swagger = swaggerProvider.GetSwagger(documentName, null, basePath, httpContext.Request.IsHttps ? new string[] { "https" } : new string [] { "http" });
                }
                else
                {
                    swagger = swaggerProvider.GetSwagger(documentName, null, basePath);
                }

                // One last opportunity to modify the Swagger Document - this time with request context
                foreach (var filter in _options.PreSerializeFilters)
                {
                    filter(swagger, httpContext.Request);
                }

                if (_optionsOpenAPI.CompabilityLayerActive)
                {
                    await RespondWithOpenApiJson(httpContext.Response, swagger);
                }
                else
                {
                    await RespondWithSwaggerJson(httpContext.Response, swagger);
                }
            }
            catch (UnknownSwaggerDocument)
            {
                RespondWithNotFound(httpContext.Response);
            }
        }
Exemplo n.º 27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SwaggerForOcelotMiddleware"/> class.
 /// </summary>
 /// <param name="next">The next delegate.</param>
 /// <param name="options">The options.</param>
 /// <param name="routes">The Ocelot Routes configuration.</param>
 /// <param name="swaggerEndPoints">The swagger end points.</param>
 /// <param name="httpClientFactory">The HTTP client factory.</param>
 /// <param name="transformer">The SwaggerJsonTransformer</param>
 public SwaggerForOcelotMiddleware(
     RequestDelegate next,
     SwaggerForOcelotUIOptions options,
     IOptions <List <RouteOptions> > routes,
     ISwaggerJsonTransformer transformer,
     ISwaggerProvider swaggerProvider,
     ISwaggerDownstreamInterceptor downstreamInterceptor = null)
 {
     _transformer           = Check.NotNull(transformer, nameof(transformer));
     _next                  = Check.NotNull(next, nameof(next));
     _routes                = Check.NotNull(routes, nameof(routes));
     _options               = options;
     _downstreamInterceptor = downstreamInterceptor;
     _swaggerProvider       = swaggerProvider;
 }
Exemplo n.º 28
0
        /// <summary>
        /// Generate Swagger as Json
        /// Set this:
        /// app__AddSwagger = true
        /// app__AddSwaggerExport = true
        /// </summary>
        /// <param name="swaggerProvider">Swagger provider</param>
        /// <param name="docName">document name</param>
        /// <returns></returns>
        internal static string GenerateSwagger(ISwaggerProvider swaggerProvider, string docName)
        {
            if (swaggerProvider == null)
            {
                return(string.Empty);
            }

            var swaggerDocument = swaggerProvider.GetSwagger(docName, null, "/");

            return(JsonConvert.SerializeObject(swaggerDocument, Formatting.Indented,
                                               new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                ContractResolver = new DefaultContractResolver()
            }));
        }
 public CoverageCalculator(
     ISwaggerProvider swaggerProvider,
     ISwaggerParser swaggerParser,
     IResponseLogProvider responseLogProvider,
     IResponseLogParser responseLogParser,
     IApiAnalyzerFactory analyzerFactory,
     IReportPersister reportPersister,
     IResponseFilter responseFilter)
 {
     _swaggerProvider     = swaggerProvider ?? throw new ArgumentNullException(nameof(swaggerProvider));
     _swaggerParser       = swaggerParser ?? throw new ArgumentNullException(nameof(swaggerParser));
     _responseLogProvider = responseLogProvider ?? throw new ArgumentNullException(nameof(responseLogProvider));
     _responseLogParser   = responseLogParser ?? throw new ArgumentNullException(nameof(responseLogParser));
     _analyzerFactory     = analyzerFactory ?? throw new ArgumentNullException(nameof(analyzerFactory));
     _reportPersister     = reportPersister ?? throw new ArgumentNullException(nameof(reportPersister));
     _responseFilter      = responseFilter ?? throw new ArgumentNullException(nameof(responseFilter));
 }
Exemplo n.º 30
0
        public async Task Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
        {
            if (!RequestingSwaggerDocument(httpContext.Request, out string documentName))
            {
                await _next(httpContext);

                return;
            }

            try
            {
                var basePath = httpContext.Request.PathBase.HasValue
                    ? httpContext.Request.PathBase.Value
                    : null;

                var swagger = swaggerProvider.GetSwagger(
                    documentName: documentName,
                    host: null,
                    basePath: basePath);

                // One last opportunity to modify the Swagger Document - this time with request context
                foreach (var filter in _options.PreSerializeFilters)
                {
                    filter(swagger, httpContext.Request);
                }

                if (Path.GetExtension(httpContext.Request.Path.Value) == ".yaml")
                {
                    await RespondWithSwaggerYaml(httpContext.Response, swagger);
                }
                else
                {
                    await RespondWithSwaggerJson(httpContext.Response, swagger);
                }
            }
            catch (UnknownSwaggerDocument)
            {
                RespondWithNotFound(httpContext.Response);
            }
        }
Exemplo n.º 31
0
        protected override Task <HttpResponseMessage> SendAsync(
            HttpRequestMessage request,
            CancellationToken cancellationToken)
        {
            ISwaggerProvider swaggerProvider = this._config.GetSwaggerProvider(request);
            string           rootUrl         = this._config.GetRootUrl(request);
            string           apiVersion      = HttpRequestMessageExtensions.GetRouteData(request).get_Values()["apiVersion"].ToString();

            try
            {
                SwaggerDocument swagger     = swaggerProvider.GetSwagger(rootUrl, apiVersion);
                HttpContent     httpContent = this.ContentFor(request, swagger);
                return(this.TaskFor(new HttpResponseMessage()
                {
                    Content = httpContent
                }));
            }
            catch (UnknownApiVersion ex)
            {
                return(this.TaskFor(HttpRequestMessageExtensions.CreateErrorResponse(request, HttpStatusCode.NotFound, (Exception)ex)));
            }
        }
        public async Task Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
        {
            if (!RequestingSwaggerDocument(httpContext.Request, out string documentName))
            {
                await _next(httpContext);

                return;
            }

            try
            {
                var swaggerDocument =
                    _swaggerDocumentBuilder.Build(
                        httpContext.Request,
                        swaggerProvider,
                        documentName);

                await RespondWithSwaggerJson(httpContext.Response, swaggerDocument);
            }
            catch (UnknownSwaggerDocument)
            {
                RespondWithNotFound(httpContext.Response);
            }
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="swaggerProvider"></param>
 /// <param name="xml">xml文档路径</param>
 public SwaggerControllerDescProvider(ISwaggerProvider swaggerProvider, string xml)
 {
     _swaggerProvider = swaggerProvider;
     _xml             = xml;
 }
Exemplo n.º 34
0
 private static void ApiDeclaration(ISwaggerProvider swaggerProvider, string resourceName, Action<ApiDeclaration> applyAssertions)
 {
     var declaration = swaggerProvider.GetDeclaration(RequestedBasePath, RequestedVersion, resourceName);
     applyAssertions(declaration);
 }
Exemplo n.º 35
0
        private static void Api(ISwaggerProvider swaggerProvider, string resourceName, string apiPath, Action<Api> applyAssertions)
        {
            var api = swaggerProvider.GetDeclaration(RequestedBasePath, RequestedVersion, resourceName).Apis
                .Single(a => a.Path == apiPath);

            applyAssertions(api);
        }
		public CachedSwaggerProviderWrapper(ISwaggerProvider swaggerProvider, ICacheManager<object> cacheManager)
		{
			_cacheManager = cacheManager;
			_swaggerProvider = swaggerProvider;
		}
 /// <summary>
 /// Initializes a new instance of the <see cref="ODataSwaggerProvider" /> class.
 /// </summary>
 /// <param name="defaultProvider">The default provider.</param>
 /// <param name="swaggerDocsConfig">The swagger docs configuration.</param>
 public ODataSwaggerProvider(ISwaggerProvider defaultProvider, SwaggerDocsConfig swaggerDocsConfig) 
     : this(defaultProvider, swaggerDocsConfig, GlobalConfiguration.Configuration)
 {
     Contract.Requires(defaultProvider != null);
     Contract.Requires(swaggerDocsConfig != null);
 }
		public CachedSwaggerProviderWrapper(ISwaggerProvider swaggerProvider, CacheManager cacheManager)
		{
			_cacheManager = cacheManager;
			_swaggerProvider = swaggerProvider;
		}
Exemplo n.º 39
0
 public CachingSwaggerProvider(ISwaggerProvider swaggerProvider)
 {
     _swaggerProvider = swaggerProvider;
 }
 public SwaggerToPostmanConverter(ISwaggerProvider swaggerProvider, IOperationObjectConverter operationConverter)
 {
     this.swaggerProvider     = swaggerProvider;
     this.operationConverter  = operationConverter;
     this.defaultValueFactory = new DefaultValueFactory();
 }
 public CachingSwaggerProvider(ISwaggerProvider swaggerProvider, ICacheManager<object> cacheManager, string cacheKey)
 {
     _swaggerProvider = swaggerProvider;
     _cacheManager = cacheManager;
     _cacheKey = cacheKey;
 }
        private static void Operation(ISwaggerProvider swaggerProvider, string resourceName, string apiPath, int index, string httpMethod,
            Action<Operation> applyAssertions)
        {
            var api = swaggerProvider.GetDeclaration(RequestedBasePath, RequestedVersion, resourceName).Apis
                .Single(a => a.Path == apiPath);

            Operation(api, httpMethod, index, applyAssertions);
        }
Exemplo n.º 43
0
 public TemplateSwagger(ISwaggerProvider swaggerProvider, IEnumerable<Template> templates)
 {
     _swaggerProvider = swaggerProvider;
     _templates = templates;
 }