diff --git a/test/MicroElements.Swashbuckle.FluentValidation.Tests/MicroElements.Swashbuckle.FluentValidation.Tests.csproj b/test/MicroElements.Swashbuckle.FluentValidation.Tests/MicroElements.Swashbuckle.FluentValidation.Tests.csproj index 4021561..2d1eec4 100644 --- a/test/MicroElements.Swashbuckle.FluentValidation.Tests/MicroElements.Swashbuckle.FluentValidation.Tests.csproj +++ b/test/MicroElements.Swashbuckle.FluentValidation.Tests/MicroElements.Swashbuckle.FluentValidation.Tests.csproj @@ -9,7 +9,9 @@ + + diff --git a/test/MicroElements.Swashbuckle.FluentValidation.Tests/SwaggerTestHost.cs b/test/MicroElements.Swashbuckle.FluentValidation.Tests/SwaggerTestHost.cs index 2c3c4fb..1e03d53 100644 --- a/test/MicroElements.Swashbuckle.FluentValidation.Tests/SwaggerTestHost.cs +++ b/test/MicroElements.Swashbuckle.FluentValidation.Tests/SwaggerTestHost.cs @@ -1,12 +1,13 @@ using System; using FluentValidation; + using Microsoft.AspNetCore.Mvc; -#endif using MicroElements.OpenApi.FluentValidation; using MicroElements.Swashbuckle.FluentValidation.AspNetCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen; +using Swashbuckle.AspNetCore.Annotations; namespace MicroElements.Swashbuckle.FluentValidation.Tests; @@ -60,6 +61,9 @@ public SwaggerTestHost RegisterValidator() public SwaggerTestHost GenerateSchema(out OpenApiSchema schema) { var schemaGenerator = ServiceProvider.GetService(); + if (schemaGenerator == null) + throw new InvalidOperationException("ISchemaGenerator service not found. Make sure to call Configure() first."); + var openApiSchema = schemaGenerator.GenerateSchema(typeof(TModel), SchemaRepository); schema = SchemaRepository.Schemas[openApiSchema.Reference.Id]; return this;