Esempio n. 1
0
        public async Task It_supports_actions_that_accept_an_array_of_complex_types()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(SuppliersController))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);
                // Verify that the OData route and post data to the test controller is valid
                var suppliers = new SupplierDtos
                {
                    Suppliers = new List <SupplierDto>
                    {
                        new SupplierDto
                        {
                            Name        = "SupplierNameOne",
                            Code        = "CodeOne",
                            Description = "SupplierOneDescription"
                        },
                        new SupplierDto
                        {
                            Name        = "SupplierNameTwo",
                            Code        = "CodeTwo",
                            Description = "SupplierTwoDescription"
                        }
                    }
                };

                var result = await httpClient.PostAsJsonAsync("/odata/Suppliers/Default.PostArrayOfSuppliers", suppliers);

                result.IsSuccessStatusCode.Should().BeTrue();

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue("/odata/Suppliers/Default.PostArrayOfSuppliers", out pathItem);
                pathItem.Should().NotBeNull();
                pathItem.post.Should().NotBeNull();
                pathItem.post.parameters.Count.Should().Be(1);
                pathItem.post.parameters.Single()[email protected]().Be("body");
                pathItem.post.parameters.Single().name.Should().Be("parameters");
                pathItem.post.parameters.Single().schema.Should().NotBeNull();
                pathItem.post.parameters.Single().schema.type.Should().Be("object");
                pathItem.post.parameters.Single().schema.properties.Should().NotBeNull();
                pathItem.post.parameters.Single().schema.properties.Count.Should().Be(1);
                pathItem.post.parameters.Single().schema.properties.Should().ContainKey("suppliers");
                pathItem.post.parameters.Single().schema.properties.Single(pair => pair.Key == "suppliers").Value.type.Should().Be("array");
                pathItem.post.parameters.Single().schema.properties.Single(pair => pair.Key == "suppliers").Value.items.Should().NotBeNull();
                pathItem.post.parameters.Single().schema.properties.Single(pair => pair.Key == "suppliers")[email protected]().Be("#/definitions/SupplierDto");

                swaggerDocument.definitions.Keys.Should().Contain("SupplierDto");

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
Esempio n. 2
0
        public async Task OData_does_not_support_byte_parameters()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(ByteParametersController))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var result = await httpClient.GetAsync("/odata/ByteParameters/Default.ResponseTest(param=1)");

                // Assert
                result.IsSuccessStatusCode.Should().BeFalse();
                result.StatusCode.Should().Be(HttpStatusCode.InternalServerError);
            }
        }
Esempio n. 3
0
        public static async Task ValidateSwaggerJson()
        {
            // Arrange
            var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

            // Act
            var response = await httpClient.GetAsync("swagger/docs/v1");

            // Assert
            await response.ValidateSuccessAsync();

            await IsValidAgainstJsonSchemaAsync(response);

            await HasUniqueOperationIdsAsync(response);
        }
Esempio n. 4
0
        public async Task It_handles_a_null_route_prefix()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(PinsController))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);
                // Verify that the OData route in the test controller is valid
                var result = await httpClient.GetAsync("/Pins");

                result.IsSuccessStatusCode.Should().BeTrue();

                // Act and Assert
                await ValidationUtils.ValidateSwaggerJson();
            }
        }
        public async Task It_supports_actions_against_an_entity()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(SuppliersController))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);
                // Verify that the OData route in the test controller is valid
                var rating = new RatingDto
                {
                    Rating = 1
                };
                var result = await httpClient.PostAsJsonAsync("/odata/Suppliers(1)/Default.Rate", rating);

                result.IsSuccessStatusCode.Should().BeTrue();

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue("/odata/Suppliers({Id})/Default.Rate", out pathItem);
                pathItem.Should().NotBeNull();
                pathItem.post.Should().NotBeNull();
                pathItem.post.parameters.Count.Should().Be(2);

                var idParameter = pathItem.post.parameters.SingleOrDefault(parameter => parameter.@in == "path");
                idParameter.Should().NotBeNull();
                idParameter.type.Should().Be("integer");
                idParameter.format.Should().Be("int32");
                idParameter.name.Should().Be("Id");

                var bodyParameter = pathItem.post.parameters.SingleOrDefault(parameter => parameter.@in == "body");
                bodyParameter.Should().NotBeNull();
                [email protected]().Be("body");
                bodyParameter.schema.Should().NotBeNull();
                bodyParameter.schema.type.Should().Be("object");
                bodyParameter.schema.properties.Should().NotBeNull();
                bodyParameter.schema.properties.Count.Should().Be(1);
                bodyParameter.schema.properties.Should().ContainKey("Rating");
                bodyParameter.schema.properties.Single(pair => pair.Key == "Rating").Value.type.Should().Be("integer");
                bodyParameter.schema.properties.Single(pair => pair.Key == "Rating").Value.format.Should().Be("int32");
                bodyParameter.schema.required.Should().NotBeNull();
                bodyParameter.schema.required.Count.Should().Be(1);
                bodyParameter.schema.required.Should().Contain("Rating");

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
        public async Task It_generates_a_single_get_path_issue_28_problem_3()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(Products1Controller))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                swaggerDocument.paths.Count.Should().Be(2);

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
Esempio n. 7
0
        public async Task Schema_contains_nested_reference_types_for_web_api_controllers()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, builder => Configuration(builder, typeof(ClientsController))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                swaggerDocument.definitions["Client"].properties.ContainsKey("projects").Should().BeTrue();

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
        public async Task It_supports_odata_routes_that_dont_map_to_a_controller()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, builder => Configuration(builder)))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                swaggerDocument.Should().NotBeNull();

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
Esempio n. 9
0
        public async Task By_default_the_schema_does_not_contain_nested_reference_types_for_odata_controllers()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(CustomersController))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                swaggerDocument.definitions["Customer"].properties.ContainsKey("Orders").Should().BeFalse();
                swaggerDocument.definitions["Order"].properties.ContainsKey("Customer").Should().BeFalse();

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
        public async Task It_applies_document_filters()
        {
            // Arrange
            Action <SwaggerDocsConfig> config = c => c.DocumentFilter <ApplyNewHostName>();
            var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

            using (WebApp.Start(HttpClientUtils.BaseAddress, builder => Configuration(builder, unitTestConfigs: config)))
            {
                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                swaggerDocument.host.Should().Be("foo");

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
Esempio n. 11
0
        public async Task Schema_can_be_configured_to_display_nested_reference_types_for_odata_controllers()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(CustomersController), oc => oc.IncludeNavigationProperties())))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                swaggerDocument.definitions["Customer"].properties.ContainsKey("Orders").Should().BeTrue();
                swaggerDocument.definitions["Order"].properties.ContainsKey("Customer").Should().BeTrue();

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
        public async Task It_wraps_string_type_url_params_with_single_quotes()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(ProductsV1Controller))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue("/odata/v1/Products({Id})/Default.CalculateGeneralSalesTax(state='{state}')", out pathItem);
                pathItem.Should().NotBeNull();
                pathItem.get.Should().NotBeNull();
            }
        }
Esempio n. 13
0
        public async Task It_has_a_restier_get_with_all_optional_query_parameters()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, Configuration))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue("/restier/Users({Id})", out pathItem);
                pathItem.get.parameters.Where(parameter => parameter.name.StartsWith("$")).Should().OnlyContain(parameter => parameter.required == false);

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
Esempio n. 14
0
        public async Task It_serializes_web_api_model()
        {
            Action <SwaggerDocsConfig> config = c => c.DocumentFilter <ApplySharedModelsDocumentation>();

            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => SharedModelsSetup.ConfigurationWithFormatters(appBuilder, config, typeof(SharedModelsSetup.SharedModelsController), typeof(SharedModelsSetup.SharedModelsWebApiController))))
            {
                // Access swagger doc first
                await ValidationUtils.ValidateSwaggerJson();

                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);
                // Verify that the custom web api model can be serialized
                var webApiResults = await httpClient.GetJsonAsync <List <SharedModelsSetup.CustomApiModel> >("CustomApiModels");

                webApiResults.Should().NotBeNull();
                webApiResults.Count.Should().Be(2);
            }
        }
Esempio n. 15
0
        public async Task It_has_single_entity_odata_query_parameters()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(CustomersController))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue("/odata/Customers({Id})", out pathItem);
                pathItem.get.parameters.Where(parameter => parameter.name.StartsWith("$")).Should().HaveCount(2);

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
Esempio n. 16
0
        public async Task It_groups_paths_by_entity_set()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, Configuration))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue("/restier/Users({Id})", out pathItem);
                pathItem.get.tags.First().Should().Be("Users");

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
Esempio n. 17
0
        public async Task It_handles_an_odata_route_prefix_attribute(string path)
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(RoutePrefixedPinsController))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue(path, out pathItem);
                pathItem.Should().NotBeNull();

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
Esempio n. 18
0
        public async Task It_includes_a_put_operation()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(CustomersController))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue("/odata/Customers({Id})", out pathItem);
                pathItem.Should().NotBeNull();
                pathItem.put.Should().NotBeNull();

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
        public async Task It_supports_actions_with_only_body_paramters()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(SuppliersController))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);
                // Verify that the OData route in the test controller is valid
                var supplierDto = new SupplierDto
                {
                    Name        = "SupplierName",
                    Code        = "SDTO",
                    Description = "SupplierDescription"
                };
                var result = await httpClient.PostAsJsonAsync("/odata/Suppliers/Default.Create", supplierDto);

                result.IsSuccessStatusCode.Should().BeTrue();

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue("/odata/Suppliers/Default.Create", out pathItem);
                pathItem.Should().NotBeNull();
                pathItem.post.Should().NotBeNull();
                pathItem.post.parameters.Count.Should().Be(1);
                pathItem.post.parameters.Single()[email protected]().Be("body");
                pathItem.post.parameters.Single().schema.Should().NotBeNull();
                pathItem.post.parameters.Single().schema.properties.Should().NotBeNull();
                pathItem.post.parameters.Single().schema.properties.Count.Should().Be(3);
                pathItem.post.parameters.Single().schema.properties.Should().ContainKey("code");
                pathItem.post.parameters.Single().schema.properties.Should().ContainKey("name");
                pathItem.post.parameters.Single().schema.properties.Single(pair => pair.Key == "name").Value.type.Should().Be("string");
                pathItem.post.parameters.Single().schema.properties.Should().ContainKey("description");
                pathItem.post.parameters.Single().schema.properties.Single(pair => pair.Key == "description").Value.type.Should().Be("string");
                pathItem.post.parameters.Single().schema.required.Should().NotBeNull();
                pathItem.post.parameters.Single().schema.required.Count.Should().Be(2);
                pathItem.post.parameters.Single().schema.required.Should().Contain("code");
                pathItem.post.parameters.Single().schema.required.Should().Contain("name");

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
Esempio n. 20
0
        public async Task It_has_a_body_parameter_with_a_schema()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(OrdersController))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue("/odata/Orders({OrderId})", out pathItem);
                pathItem.patch.parameters.Single(parameter => parameter.@in == "body").schema.Should().NotBeNull();
                pathItem.patch.parameters.Single(parameter => parameter.@in == "body")[email protected]().Be("#/definitions/Order");

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
        public async Task It_explores_the_correct_versioned_controller()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, builder => Configuration(builder, typeof(CustomersV1Controller))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem versionedCustomerController;
                swaggerDocument.paths.TryGetValue("/odata/v1/Customers({Id})", out versionedCustomerController);
                versionedCustomerController.Should().NotBeNull();
                versionedCustomerController.put.Should().BeNull();

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
        public async Task It_supports_a_function_bound_to_an_entity()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(ProductsV1Controller))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue("/odata/v1/Products({Id})/Default.GetPriceRank()", out pathItem);
                pathItem.Should().NotBeNull();
                pathItem.get.Should().NotBeNull();

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
Esempio n. 23
0
        public async Task It_allows_definition_of_custom_delete_routes()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, builder => Configuration(builder, typeof(OrdersController))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue("/odata/Customers({Id})/Orders({orderID})", out pathItem);
                pathItem.Should().NotBeNull();
                pathItem.delete.Should().NotBeNull();

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
Esempio n. 24
0
        public async Task It_supports_types_with_a_guid_primary_key()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(OrdersController))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue("/odata/Orders({OrderId})", out pathItem);
                pathItem.Should().NotBeNull();
                pathItem.get.Should().NotBeNull();

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
        public async Task It_supports_unbound_functions()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(ProductsV1Controller))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue("/odata/v1/GetSalesTaxRate(state='{state}')", out pathItem);
                pathItem.Should().NotBeNull();
                pathItem.get.Should().NotBeNull();

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
Esempio n. 26
0
        public async Task It_supports_custom_swagger_routes_against_restier()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, NorthwindConfiguration))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue("/restier/Customers('{CustomerId}')/Orders({OrderId})", out pathItem);
                pathItem.Should().NotBeNull();
                var getResponse = pathItem.get.responses.SingleOrDefault(response => response.Key == "200");
                getResponse.Should().NotBeNull();

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
Esempio n. 27
0
        public async Task It_supports_restier()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, Configuration))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem restierPath;
                swaggerDocument.paths.TryGetValue("/restier/Users({Id})", out restierPath);
                restierPath.Should().NotBeNull();
                restierPath.get.Should().NotBeNull();
                restierPath.get.parameters.Single(parameter => parameter.name == "Id").type.Should().NotBeNullOrEmpty();

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
Esempio n. 28
0
        public async Task It_provides_unique_operation_ids_for_restier()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, Configuration))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                swaggerDocument.paths.Values
                .Select(pathItem => pathItem.get)
                .GroupBy(operation => operation.operationId)
                .All(grouping => grouping.Count() == 1)
                .Should().BeTrue();

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
Esempio n. 29
0
        public async Task It_has_a_restier_response_with_the_correct_edm_model_type()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, Configuration))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue("/restier/Users({Id})", out pathItem);
                var getByIdResponse = pathItem.get.responses.SingleOrDefault(response => response.Key == "200");
                getByIdResponse.Should().NotBeNull();
                [email protected]().Be("#/definitions/User");

                await ValidationUtils.ValidateSwaggerJson();
            }
        }
Esempio n. 30
0
        public async Task It_has_a_parameter_with_a_name_equal_to_the_path_name()
        {
            using (WebApp.Start(HttpClientUtils.BaseAddress, appBuilder => Configuration(appBuilder, typeof(CustomersController))))
            {
                // Arrange
                var httpClient = HttpClientUtils.GetHttpClient(HttpClientUtils.BaseAddress);

                // Act
                var swaggerDocument = await httpClient.GetJsonAsync <SwaggerDocument>("swagger/docs/v1");

                // Assert
                PathItem pathItem;
                swaggerDocument.paths.TryGetValue("/odata/Customers({Id})", out pathItem);
                pathItem.Should().NotBeNull();
                pathItem.get.Should().NotBeNull();
                pathItem.get.parameters.Should().Contain(parameter => parameter.name == "Id");

                await ValidationUtils.ValidateSwaggerJson();
            }
        }