66using Microsoft . OpenApi . Models ;
77using Swashbuckle . AspNetCore . SwaggerGen ;
88
9- namespace JsonApiDotNetCore . OpenApi . Swashbuckle . SchemaGenerators . Bodies ;
9+ namespace JsonApiDotNetCore . OpenApi . Swashbuckle . SchemaGenerators . Documents ;
1010
1111/// <summary>
12- /// Generates the OpenAPI component schema for a resource/relationship request/response body .
12+ /// Generates the OpenAPI component schema for a resource/relationship request/response document .
1313/// </summary>
14- internal sealed class ResourceOrRelationshipBodySchemaGenerator : BodySchemaGenerator
14+ internal sealed class ResourceOrRelationshipDocumentSchemaGenerator : DocumentSchemaGenerator
1515{
16- private static readonly Type [ ] RequestBodySchemaTypes =
16+ private static readonly Type [ ] RequestDocumentSchemaTypes =
1717 [
1818 typeof ( CreateRequestDocument < > ) ,
1919 typeof ( UpdateRequestDocument < > ) ,
@@ -22,7 +22,7 @@ internal sealed class ResourceOrRelationshipBodySchemaGenerator : BodySchemaGene
2222 typeof ( ToManyInRequest < > )
2323 ] ;
2424
25- private static readonly Type [ ] ResponseBodySchemaTypes =
25+ private static readonly Type [ ] ResponseDocumentSchemaTypes =
2626 [
2727 typeof ( CollectionResponseDocument < > ) ,
2828 typeof ( PrimaryResponseDocument < > ) ,
@@ -37,7 +37,7 @@ internal sealed class ResourceOrRelationshipBodySchemaGenerator : BodySchemaGene
3737 private readonly DataContainerSchemaGenerator _dataContainerSchemaGenerator ;
3838 private readonly IResourceGraph _resourceGraph ;
3939
40- public ResourceOrRelationshipBodySchemaGenerator ( SchemaGenerator defaultSchemaGenerator , DataContainerSchemaGenerator dataContainerSchemaGenerator ,
40+ public ResourceOrRelationshipDocumentSchemaGenerator ( SchemaGenerator defaultSchemaGenerator , DataContainerSchemaGenerator dataContainerSchemaGenerator ,
4141 MetaSchemaGenerator metaSchemaGenerator , LinksVisibilitySchemaGenerator linksVisibilitySchemaGenerator , IJsonApiOptions options ,
4242 IResourceGraph resourceGraph )
4343 : base ( metaSchemaGenerator , linksVisibilitySchemaGenerator , options )
@@ -51,35 +51,35 @@ public ResourceOrRelationshipBodySchemaGenerator(SchemaGenerator defaultSchemaGe
5151 _resourceGraph = resourceGraph ;
5252 }
5353
54- public override bool CanGenerate ( Type modelType )
54+ public override bool CanGenerate ( Type schemaType )
5555 {
56- Type modelOpenType = modelType . ConstructedToOpenType ( ) ;
57- return RequestBodySchemaTypes . Contains ( modelOpenType ) || ResponseBodySchemaTypes . Contains ( modelOpenType ) ;
56+ Type schemaOpenType = schemaType . ConstructedToOpenType ( ) ;
57+ return RequestDocumentSchemaTypes . Contains ( schemaOpenType ) || ResponseDocumentSchemaTypes . Contains ( schemaOpenType ) ;
5858 }
5959
60- protected override OpenApiSchema GenerateBodySchema ( Type bodyType , SchemaRepository schemaRepository )
60+ protected override OpenApiSchema GenerateDocumentSchema ( Type schemaType , SchemaRepository schemaRepository )
6161 {
62- ArgumentNullException . ThrowIfNull ( bodyType ) ;
62+ ArgumentNullException . ThrowIfNull ( schemaType ) ;
6363 ArgumentNullException . ThrowIfNull ( schemaRepository ) ;
6464
65- if ( schemaRepository . TryLookupByType ( bodyType , out OpenApiSchema ? referenceSchemaForBody ) )
65+ if ( schemaRepository . TryLookupByType ( schemaType , out OpenApiSchema ? referenceSchemaForDocument ) )
6666 {
67- return referenceSchemaForBody ;
67+ return referenceSchemaForDocument ;
6868 }
6969
70- var resourceSchemaType = ResourceSchemaType . Create ( bodyType , _resourceGraph ) ;
71- bool isRequestSchema = RequestBodySchemaTypes . Contains ( resourceSchemaType . SchemaOpenType ) ;
70+ var resourceSchemaType = ResourceSchemaType . Create ( schemaType , _resourceGraph ) ;
71+ bool isRequestSchema = RequestDocumentSchemaTypes . Contains ( resourceSchemaType . SchemaOpenType ) ;
7272
73- _ = _dataContainerSchemaGenerator . GenerateSchema ( bodyType , resourceSchemaType . ResourceType , isRequestSchema , ! isRequestSchema , schemaRepository ) ;
73+ _ = _dataContainerSchemaGenerator . GenerateSchema ( schemaType , resourceSchemaType . ResourceType , isRequestSchema , ! isRequestSchema , schemaRepository ) ;
7474
75- referenceSchemaForBody = _defaultSchemaGenerator . GenerateSchema ( bodyType , schemaRepository ) ;
76- OpenApiSchema inlineSchemaForBody = schemaRepository . Schemas [ referenceSchemaForBody . Reference . Id ] . UnwrapLastExtendedSchema ( ) ;
75+ referenceSchemaForDocument = _defaultSchemaGenerator . GenerateSchema ( schemaType , schemaRepository ) ;
76+ OpenApiSchema inlineSchemaForDocument = schemaRepository . Schemas [ referenceSchemaForDocument . Reference . Id ] . UnwrapLastExtendedSchema ( ) ;
7777
7878 if ( JsonApiSchemaFacts . HasNullableDataProperty ( resourceSchemaType . SchemaOpenType ) )
7979 {
80- inlineSchemaForBody . Properties [ JsonApiPropertyName . Data ] . Nullable = true ;
80+ inlineSchemaForDocument . Properties [ JsonApiPropertyName . Data ] . Nullable = true ;
8181 }
8282
83- return referenceSchemaForBody ;
83+ return referenceSchemaForDocument ;
8484 }
8585}
0 commit comments