コード例 #1
0
        public ApiDocsController()
        {
            var apiExplorer = GlobalConfiguration.Configuration.Services.GetApiExplorer();
            _swaggerSpec = SwaggerGenerator.Instance.Generate(apiExplorer);

            _serializerSettings = new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore
            };
        }
コード例 #2
0
        public SwaggerSpec SwaggerSpec()
        {
            lock (SyncRoot)
            {
                if (_swaggerSpec == null)
                {
                    var swaggerGenerator = new SwaggerGenerator();
                    var apiExplorer = GlobalConfiguration.Configuration.Services.GetApiExplorer();
                    _swaggerSpec = swaggerGenerator.ApiExplorerToSwaggerSpec(apiExplorer);
                }
            }

            return _swaggerSpec;
        }
コード例 #3
0
        public void Setup()
        {
            SwaggerSpecConfig.Customize(c =>
                {
                    c.ResolveBasePath(() => "http://tempuri.org");
                    c.PostFilter<AddStandardErrorCodes>();
                    c.PostFilter<AddAuthorizationErrorCodes>();
                });

            // Get ApiExplorer for TestApp
            var httpConfiguration = new HttpConfiguration();
            WebApiConfig.Register(httpConfiguration);
            var apiExplorer = new ApiExplorer(httpConfiguration);

            _swaggerSpec = SwaggerSpec.CreateFrom(apiExplorer);
        }
コード例 #4
0
        private static void OperationSpec(SwaggerSpec swaggerSpec, string resourcePath, string apiPath, int index, string httpMethod,
            Action<OperationSpec> applyAssertions)
        {
            var apiSpec = swaggerSpec.Declarations[resourcePath].Apis
                .Single(api => api.Path == apiPath);

            OperationSpec(apiSpec, httpMethod, index, applyAssertions);
        }
コード例 #5
0
        private static void ApiSpec(SwaggerSpec swaggerSpec, string resourcePath, string apiPath, Action<ApiSpec> applyAssertions)
        {
            var apiSpec = swaggerSpec.Declarations[resourcePath].Apis
                .Single(api => api.Path == apiPath);

            applyAssertions(apiSpec);
        }
コード例 #6
0
 private static void ApiDeclaration(SwaggerSpec swaggerSpec, string resourcePath, Action<ApiDeclaration> applyAssertions)
 {
     var declaration = swaggerSpec.Declarations[resourcePath];
     applyAssertions(declaration);
 }