Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove XML comments fix for BR tag hence remove all markdown filters #257

Merged
merged 1 commit into from
May 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.