Skip to content

Commit 112e208

Browse files
committed
Revert "Fixed: removed unused entries that are not top-level documents"
Turns out these were not redundant, after all. They are needed as entry points for request body parameters. A default schema is being generated without them, so not running our own generator. The effect is that 'data' in nullable relationships is not marked as `nullable: true`. This reverts commit b0fa688.
1 parent 823336d commit 112e208

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Reflection;
22
using JsonApiDotNetCore.Controllers;
33
using JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents;
4+
using JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships;
45
using Microsoft.AspNetCore.Mvc.ApiExplorer;
56
using Microsoft.OpenApi.Models;
67
using Swashbuckle.AspNetCore.SwaggerGen;
@@ -10,6 +11,7 @@ namespace JsonApiDotNetCore.OpenApi.SwaggerComponents;
1011

1112
internal sealed class JsonApiSchemaGenerator : ISchemaGenerator
1213
{
14+
// List of all the root types we're being called for, that need to be handled by our custom schema generators.
1315
private static readonly Type[] JsonApiDocumentTypes =
1416
[
1517
typeof(ResourceCollectionResponseDocument<>),
@@ -21,7 +23,10 @@ internal sealed class JsonApiSchemaGenerator : ISchemaGenerator
2123
typeof(ResourceIdentifierCollectionResponseDocument<>),
2224
typeof(ResourceIdentifierResponseDocument<>),
2325
typeof(NullableResourceIdentifierResponseDocument<>),
24-
typeof(ErrorResponseDocument)
26+
typeof(ErrorResponseDocument),
27+
typeof(ToManyRelationshipInRequest<>),
28+
typeof(ToOneRelationshipInRequest<>),
29+
typeof(NullableToOneRelationshipInRequest<>)
2530
];
2631

2732
private static readonly OpenApiSchema IdTypeSchema = new()

0 commit comments

Comments
 (0)