Skip to content

Commit ea46194

Browse files
committed
Disabled OpenAPI for nonjson and operations controller, as these are not yet supported and will cause the integration to crash
1 parent bad9aad commit ea46194

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/JsonApiDotNetCore.OpenApi/JsonApiMetadata/EndpointResolver.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Linq;
22
using System.Reflection;
3+
using JsonApiDotNetCore.Controllers;
34
using Microsoft.AspNetCore.Mvc;
45
using Microsoft.AspNetCore.Mvc.Routing;
56

@@ -11,6 +12,12 @@ internal sealed class EndpointResolver
1112
{
1213
ArgumentGuard.NotNull(controllerAction, nameof(controllerAction));
1314

15+
if (!typeof(CoreJsonApiController).IsAssignableFrom(controllerAction.ReflectedType) ||
16+
typeof(BaseJsonApiOperationsController).IsAssignableFrom(controllerAction.ReflectedType))
17+
{
18+
return null;
19+
}
20+
1421
HttpMethodAttribute method = controllerAction.GetCustomAttributes(true).OfType<HttpMethodAttribute>().FirstOrDefault();
1522

1623
return ResolveJsonApiEndpoint(method);

test/OpenApiTests/ExistingOpenApiIntegration/ExistingOpenApiIntegrationStartup.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using JetBrains.Annotations;
12
using JsonApiDotNetCore.Configuration;
23
using JsonApiDotNetCore.Resources.Annotations;
34
using Microsoft.EntityFrameworkCore;
@@ -6,6 +7,7 @@
67

78
namespace OpenApiTests.ExistingOpenApiIntegration
89
{
10+
[UsedImplicitly(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)]
911
public sealed class ExistingOpenApiIntegrationStartup<TDbContext> : OpenApiStartup<TDbContext>
1012
where TDbContext : DbContext
1113
{

0 commit comments

Comments
 (0)