Exemplo n.º 1
0
        private static async Task <OpenApiDocument> GenerateSwaggerDocument()
        {
            var generator   = new WebApiOpenApiDocumentGenerator(new WebApiOpenApiDocumentGeneratorSettings());
            var assembly    = Assembly.GetAssembly(typeof(Web.Program));
            var controllers = WebApiOpenApiDocumentGenerator.GetControllerClasses(assembly);

            return(await generator.GenerateForControllersAsync(controllers));
        }
        public void When_controller_has_ApiExplorerSettingsAttribute_with_IgnoreApi_then_it_is_ignored()
        {
            //// Arrange

            //// Act
            var controllers = WebApiOpenApiDocumentGenerator.GetControllerClasses(typeof(ApiExplorerIgnoredController).Assembly);

            //// Assert
            Assert.IsFalse(controllers.Any(c => c.Name == "ApiExplorerIgnoredController"));
        }
Exemplo n.º 3
0
        public void When_class_is_abstract_then_it_is_ignored()
        {
            // Arrange


            // Act
            var controllerClasses = WebApiOpenApiDocumentGenerator.GetControllerClasses(typeof(ControllerClassesTests).Assembly);

            // Assert
            Assert.IsFalse(controllerClasses.Contains(typeof(MyAbstractController)));
        }
Exemplo n.º 4
0
        public void When_class_inherits_from_ApiController_then_it_is_found()
        {
            // Arrange


            // Act
            var controllerClasses = WebApiOpenApiDocumentGenerator.GetControllerClasses(typeof(ControllerClassesTests).Assembly);

            // Assert
            Assert.IsTrue(controllerClasses.Contains(typeof(MyWebApi)));
        }