From 50bca76174854d8c548415ceb7b740cdd20dd2a9 Mon Sep 17 00:00:00 2001 From: Scott Xu Date: Sat, 17 Jun 2023 21:44:06 +0800 Subject: [PATCH] unit test for https://github.com/heldersepu/Swagger-Net/pull/126 --- .../Swagger.Net.Dummy.Core.csproj | 1 + .../SwaggerExtensions/AddDescription.cs | 10 ++++++++++ Tests/Swagger.Net.Tests/Swagger/AnnotationsTests.cs | 12 ++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 Tests/Swagger.Net.Dummy.Core/SwaggerExtensions/AddDescription.cs diff --git a/Tests/Swagger.Net.Dummy.Core/Swagger.Net.Dummy.Core.csproj b/Tests/Swagger.Net.Dummy.Core/Swagger.Net.Dummy.Core.csproj index 1572ac6e..a03fea23 100644 --- a/Tests/Swagger.Net.Dummy.Core/Swagger.Net.Dummy.Core.csproj +++ b/Tests/Swagger.Net.Dummy.Core/Swagger.Net.Dummy.Core.csproj @@ -111,6 +111,7 @@ + diff --git a/Tests/Swagger.Net.Dummy.Core/SwaggerExtensions/AddDescription.cs b/Tests/Swagger.Net.Dummy.Core/SwaggerExtensions/AddDescription.cs new file mode 100644 index 00000000..3ff6dc9c --- /dev/null +++ b/Tests/Swagger.Net.Dummy.Core/SwaggerExtensions/AddDescription.cs @@ -0,0 +1,10 @@ +namespace Swagger.Net.Dummy.SwaggerExtensions +{ + public class AddDescription : ISchemaFilter + { + public void Apply(Schema schema, SchemaRegistry schemaRegistry, System.Type type) + { + schema.description = "Some description"; + } + } +} diff --git a/Tests/Swagger.Net.Tests/Swagger/AnnotationsTests.cs b/Tests/Swagger.Net.Tests/Swagger/AnnotationsTests.cs index 1bb70f6b..a3b311de 100644 --- a/Tests/Swagger.Net.Tests/Swagger/AnnotationsTests.cs +++ b/Tests/Swagger.Net.Tests/Swagger/AnnotationsTests.cs @@ -49,6 +49,18 @@ public void It_exposes_config_to_post_modify_responses() Assert.AreEqual("bar", xProp.ToString()); } + [Test] + public void It_exposes_config_to_modify_schema_description() + { + SetUpHandler(c => c.SchemaFilter()); + + var swagger = GetContent(TEMP_URI.DOCS); + + var messageExamples = swagger["definitions"]["Message"]["properties"]["Content"]["description"]; + + Assert.AreEqual("Some description", messageExamples.ToString()); + } + [Test] public void It_documents_responses_from_swagger_response_attributes_post() {