Skip to content

Commit

Permalink
Remove XML comments fix for BR tag hence remove all markdown filters
Browse files Browse the repository at this point in the history
  • Loading branch information
mburumaxwell committed May 16, 2024
1 parent d1806f6 commit 62dab5a
Show file tree
Hide file tree
Showing 11 changed files with 3 additions and 248 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ namespace Microsoft.Extensions.DependencyInjection;
/// </summary>
public static class IServiceCollectionExtensions
{
/// <summary>
/// Adds conversion of XML comments extracted for Swagger to markdown.
/// </summary>
/// <param name="services">the service collection to use</param>
/// <returns></returns>
public static IServiceCollection AddSwaggerXmlToMarkdown(this IServiceCollection services)
{
return services.AddTransient<IPostConfigureOptions<SwaggerGenOptions>, ConfigureSwaggerGenXmlToMarkdown>();
}

/// <summary>
/// Adds enum descriptions.
/// This should be called after all XML documents have been added.
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ public void Apply(OpenApiSchema schema, SchemaFilterContext context)
var summaryNode = enumNode.SelectSingleNode("summary");
if (summaryNode != null)
{
var xml = XmlCommentsTextHelper.Humanize(summaryNode.InnerXml);
return XmlCommentsHelper.ToMarkdown(xml);
return XmlCommentsTextHelper.Humanize(summaryNode.InnerXml);
}

return null;
Expand Down

This file was deleted.

31 changes: 0 additions & 31 deletions src/Tingle.AspNetCore.Swagger/XmlCommentsHelper.cs

This file was deleted.

46 changes: 2 additions & 44 deletions tests/Tingle.AspNetCore.Swagger.Tests/FilterCreationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Options;
using Swashbuckle.AspNetCore.SwaggerGen;
using Tingle.AspNetCore.Swagger.Filters.Documents;
using Tingle.AspNetCore.Swagger.Filters.Operations;
using Tingle.AspNetCore.Swagger.Filters.Parameters;
using Tingle.AspNetCore.Swagger.Filters.RequestBodies;
using Tingle.AspNetCore.Swagger.Filters.Schemas;

namespace Tingle.AspNetCore.Swagger.Tests;
Expand Down Expand Up @@ -39,50 +35,12 @@ public void InheritDocSchemaFilter_CanBe_Created()
Assert.Single(options.SchemaFilters.OfType<InheritDocSchemaFilter>());
}

[Fact]
public void MarkdownFilters_AreAdded()
{
var env = new FakeWebHostEnvironment { ApplicationName = "Test", ContentRootPath = Environment.CurrentDirectory, };
var services = new ServiceCollection().AddLogging()
.AddSwaggerGen(o => o.IncludeXmlComments<MarkdownDocumentFilter>(env, includeControllerXmlComments: true))
.AddSwaggerXmlToMarkdown()
.BuildServiceProvider();

var options = services.GetRequiredService<IOptions<SwaggerGenOptions>>().Value;

Assert.Single(options.DocumentFilterDescriptors.Where(d => d.Type == typeof(MarkdownDocumentFilter)));
Assert.Single(options.OperationFilterDescriptors.Where(d => d.Type == typeof(MarkdownOperationFilter)));
Assert.Single(options.ParameterFilterDescriptors.Where(d => d.Type == typeof(MarkdownParameterFilter)));
Assert.Single(options.RequestBodyFilterDescriptors.Where(d => d.Type == typeof(MarkdownRequestBodyFilter)));
Assert.Single(options.SchemaFilterDescriptors.Where(d => d.Type == typeof(MarkdownSchemaFilter)));
}

[Fact]
public void MarkdownFilters_CanBe_Created()
{
var env = new FakeWebHostEnvironment { ApplicationName = "Test", ContentRootPath = Environment.CurrentDirectory, };
var services = new ServiceCollection().AddLogging()
.AddSwaggerGen(o => o.IncludeXmlComments<MarkdownDocumentFilter>(env, includeControllerXmlComments: true))
.AddSwaggerXmlToMarkdown()
.AddSingleton<IWebHostEnvironment>(env)
.BuildServiceProvider();

var optionsSchema = services.GetRequiredService<IOptions<SchemaGeneratorOptions>>().Value;
Assert.Single(optionsSchema.SchemaFilters.OfType<MarkdownSchemaFilter>());

var options = services.GetRequiredService<IOptions<SwaggerGeneratorOptions>>().Value;
Assert.Single(options.DocumentFilters.OfType<MarkdownDocumentFilter>());
Assert.Single(options.OperationFilters.OfType<MarkdownOperationFilter>());
Assert.Single(options.ParameterFilters.OfType<MarkdownParameterFilter>());
Assert.Single(options.RequestBodyFilters.OfType<MarkdownRequestBodyFilter>());
}

[Fact]
public void EnumDescriptionsFilters_AreAdded()
{
var env = new FakeWebHostEnvironment { ApplicationName = "Test", ContentRootPath = Environment.CurrentDirectory, };
var services = new ServiceCollection().AddLogging()
.AddSwaggerGen(o => o.IncludeXmlComments<MarkdownDocumentFilter>(env, includeControllerXmlComments: true))
.AddSwaggerGen(o => o.IncludeXmlComments<EnumDescriptionsSchemaFilter>(env, includeControllerXmlComments: true))
.AddSwaggerEnumDescriptions()
.BuildServiceProvider();

Expand All @@ -96,7 +54,7 @@ public void EnumDescriptionsFilter_CanBe_Created()
{
var env = new FakeWebHostEnvironment { ApplicationName = "Test", ContentRootPath = Environment.CurrentDirectory, };
var services = new ServiceCollection().AddLogging()
.AddSwaggerGen(o => o.IncludeXmlComments<MarkdownDocumentFilter>(env, includeControllerXmlComments: true))
.AddSwaggerGen(o => o.IncludeXmlComments<EnumDescriptionsSchemaFilter>(env, includeControllerXmlComments: true))
.AddSwaggerEnumDescriptions()
.BuildServiceProvider();

Expand Down
14 changes: 0 additions & 14 deletions tests/Tingle.AspNetCore.Swagger.Tests/XmlCommentsHelperTests.cs

This file was deleted.

0 comments on commit 62dab5a

Please sign in to comment.