private static HttpResponseMessage ListingResponse(SwaggerSpec swaggerSpec)
 {
     return new HttpResponseMessage(HttpStatusCode.OK)
     {
         Content = new StringContent(JsonTextFor(swaggerSpec.Listing), Encoding.UTF8, "application/json")
     };
 }
 private static HttpResponseMessage DeclarationResponse(SwaggerSpec swaggerSpec, string declarationName)
 {
     var declaration = swaggerSpec.Declarations["/" + declarationName];
     return new HttpResponseMessage(HttpStatusCode.OK)
     {
         Content = new StringContent(JsonTextFor(declaration), Encoding.UTF8, "application/json")
     };
 }
        private SwaggerSpec GetSwaggerSpec(HttpRequestMessage request)
        {
            lock (SyncRoot)
            {
                if (_cachedSwaggerSpec == null)
                {
                    var generator = new SwaggerGenerator(
                        apiVersion: _config.VersionResolver(request),
                        basePath: _config.BasePathResolver(request),
                        ignoreObsoleteActions: _config.IgnoreObsoleteActionsFlag, declarationKeySelector: _config.DeclarationKeySelector, operationFilters: _config.OperationFilters, customTypeMappings: _config.CustomTypeMappings, polymorphicTypes: _config.PolymorphicTypes);

                    var apiExplorer = request.GetConfiguration().Services.GetApiExplorer();

                    _cachedSwaggerSpec = generator.ApiExplorerToSwaggerSpec(apiExplorer);
                }
            }

            return _cachedSwaggerSpec;
        }
        private static void Operation(SwaggerSpec swaggerSpec, string resourcePath, string apiPath, int index, string httpMethod,
            Action<Operation> applyAssertions)
        {
            var api = swaggerSpec.Declarations[resourcePath].Apis
                .Single(a => a.Path == apiPath);

            Operation(api, httpMethod, index, applyAssertions);
        }
 private static void ApiDeclaration(SwaggerSpec swaggerSpec, string resourcePath, Action<ApiDeclaration> applyAssertions)
 {
     var declaration = swaggerSpec.Declarations[resourcePath];
     applyAssertions(declaration);
 }
        private static void Api(SwaggerSpec swaggerSpec, string resourcePath, string apiPath, Action<Api> applyAssertions)
        {
            var api = swaggerSpec.Declarations[resourcePath].Apis
                .Single(a => a.Path == apiPath);

            applyAssertions(api);
        }