6
6
using Microsoft . OpenApi . Models ;
7
7
using Swashbuckle . AspNetCore . SwaggerGen ;
8
8
9
- namespace JsonApiDotNetCore . OpenApi . Swashbuckle . SchemaGenerators . Bodies ;
9
+ namespace JsonApiDotNetCore . OpenApi . Swashbuckle . SchemaGenerators . Documents ;
10
10
11
11
/// <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 .
13
13
/// </summary>
14
- internal sealed class ResourceOrRelationshipBodySchemaGenerator : BodySchemaGenerator
14
+ internal sealed class ResourceOrRelationshipDocumentSchemaGenerator : DocumentSchemaGenerator
15
15
{
16
- private static readonly Type [ ] RequestBodySchemaTypes =
16
+ private static readonly Type [ ] RequestDocumentSchemaTypes =
17
17
[
18
18
typeof ( CreateRequestDocument < > ) ,
19
19
typeof ( UpdateRequestDocument < > ) ,
@@ -22,7 +22,7 @@ internal sealed class ResourceOrRelationshipBodySchemaGenerator : BodySchemaGene
22
22
typeof ( ToManyInRequest < > )
23
23
] ;
24
24
25
- private static readonly Type [ ] ResponseBodySchemaTypes =
25
+ private static readonly Type [ ] ResponseDocumentSchemaTypes =
26
26
[
27
27
typeof ( CollectionResponseDocument < > ) ,
28
28
typeof ( PrimaryResponseDocument < > ) ,
@@ -37,7 +37,7 @@ internal sealed class ResourceOrRelationshipBodySchemaGenerator : BodySchemaGene
37
37
private readonly DataContainerSchemaGenerator _dataContainerSchemaGenerator ;
38
38
private readonly IResourceGraph _resourceGraph ;
39
39
40
- public ResourceOrRelationshipBodySchemaGenerator ( SchemaGenerator defaultSchemaGenerator , DataContainerSchemaGenerator dataContainerSchemaGenerator ,
40
+ public ResourceOrRelationshipDocumentSchemaGenerator ( SchemaGenerator defaultSchemaGenerator , DataContainerSchemaGenerator dataContainerSchemaGenerator ,
41
41
MetaSchemaGenerator metaSchemaGenerator , LinksVisibilitySchemaGenerator linksVisibilitySchemaGenerator , IJsonApiOptions options ,
42
42
IResourceGraph resourceGraph )
43
43
: base ( metaSchemaGenerator , linksVisibilitySchemaGenerator , options )
@@ -51,35 +51,35 @@ public ResourceOrRelationshipBodySchemaGenerator(SchemaGenerator defaultSchemaGe
51
51
_resourceGraph = resourceGraph ;
52
52
}
53
53
54
- public override bool CanGenerate ( Type modelType )
54
+ public override bool CanGenerate ( Type schemaType )
55
55
{
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 ) ;
58
58
}
59
59
60
- protected override OpenApiSchema GenerateBodySchema ( Type bodyType , SchemaRepository schemaRepository )
60
+ protected override OpenApiSchema GenerateDocumentSchema ( Type schemaType , SchemaRepository schemaRepository )
61
61
{
62
- ArgumentNullException . ThrowIfNull ( bodyType ) ;
62
+ ArgumentNullException . ThrowIfNull ( schemaType ) ;
63
63
ArgumentNullException . ThrowIfNull ( schemaRepository ) ;
64
64
65
- if ( schemaRepository . TryLookupByType ( bodyType , out OpenApiSchema ? referenceSchemaForBody ) )
65
+ if ( schemaRepository . TryLookupByType ( schemaType , out OpenApiSchema ? referenceSchemaForDocument ) )
66
66
{
67
- return referenceSchemaForBody ;
67
+ return referenceSchemaForDocument ;
68
68
}
69
69
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 ) ;
72
72
73
- _ = _dataContainerSchemaGenerator . GenerateSchema ( bodyType , resourceSchemaType . ResourceType , isRequestSchema , ! isRequestSchema , schemaRepository ) ;
73
+ _ = _dataContainerSchemaGenerator . GenerateSchema ( schemaType , resourceSchemaType . ResourceType , isRequestSchema , ! isRequestSchema , schemaRepository ) ;
74
74
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 ( ) ;
77
77
78
78
if ( JsonApiSchemaFacts . HasNullableDataProperty ( resourceSchemaType . SchemaOpenType ) )
79
79
{
80
- inlineSchemaForBody . Properties [ JsonApiPropertyName . Data ] . Nullable = true ;
80
+ inlineSchemaForDocument . Properties [ JsonApiPropertyName . Data ] . Nullable = true ;
81
81
}
82
82
83
- return referenceSchemaForBody ;
83
+ return referenceSchemaForDocument ;
84
84
}
85
85
}
0 commit comments