Skip to content

Commit ec5d24f

Browse files
committed
Revert docfx bug workaround
1 parent f9b9f0a commit ec5d24f

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/JsonApiDotNetCore.OpenApi.Swashbuckle/SwaggerComponents/EndpointOrderingFilter.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,8 @@
66
namespace JsonApiDotNetCore.OpenApi.Swashbuckle.SwaggerComponents;
77

88
[UsedImplicitly(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)]
9-
internal sealed class EndpointOrderingFilter : IDocumentFilter
9+
internal sealed partial class EndpointOrderingFilter : IDocumentFilter
1010
{
11-
// Workaround for docfx bug.
12-
private const string PatternText = @".*{id}/(?>relationships\/)?(?<RelationshipName>\w+)";
13-
private const RegexOptions RegexOptionsNet60 = RegexOptions.Compiled | RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture;
14-
#pragma warning disable SYSLIB1045 // Convert to 'GeneratedRegexAttribute'.
15-
private static readonly Regex RelationshipNameInUrlPattern = new(PatternText, RegexOptionsNet60);
16-
#pragma warning restore SYSLIB1045 // Convert to 'GeneratedRegexAttribute'.
17-
1811
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
1912
{
2013
ArgumentNullException.ThrowIfNull(swaggerDoc);
@@ -58,8 +51,11 @@ private static bool IsSecondaryEndpoint(KeyValuePair<string, IOpenApiPathItem> e
5851

5952
private static string GetRelationshipName(KeyValuePair<string, IOpenApiPathItem> entry)
6053
{
61-
Match match = RelationshipNameInUrlPattern.Match(entry.Key);
54+
Match match = RelationshipNameInUrlRegex().Match(entry.Key);
6255

6356
return match.Success ? match.Groups["RelationshipName"].Value : string.Empty;
6457
}
58+
59+
[GeneratedRegex(@".*{id}/(?>relationships\/)?(?<RelationshipName>\w+)", RegexOptions.CultureInvariant | RegexOptions.ExplicitCapture)]
60+
private static partial Regex RelationshipNameInUrlRegex();
6561
}

0 commit comments

Comments
 (0)