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")); }
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))); }
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))); }