public ApiDocsController() { var apiExplorer = GlobalConfiguration.Configuration.Services.GetApiExplorer(); _swaggerSpec = SwaggerGenerator.Instance.Generate(apiExplorer); _serializerSettings = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }; }
public SwaggerSpec SwaggerSpec() { lock (SyncRoot) { if (_swaggerSpec == null) { var swaggerGenerator = new SwaggerGenerator(); var apiExplorer = GlobalConfiguration.Configuration.Services.GetApiExplorer(); _swaggerSpec = swaggerGenerator.ApiExplorerToSwaggerSpec(apiExplorer); } } return _swaggerSpec; }
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); }
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); }
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); }
private static void ApiDeclaration(SwaggerSpec swaggerSpec, string resourcePath, Action<ApiDeclaration> applyAssertions) { var declaration = swaggerSpec.Declarations[resourcePath]; applyAssertions(declaration); }