@@ -10,16 +10,11 @@ namespace Microsoft.OpenApi.Models.References;
10
10
/// <typeparam name="V">The interface type for the model.</typeparam>
11
11
public abstract class BaseOpenApiReferenceHolder < T , V > : IOpenApiReferenceHolder < T , V > where T : class , IOpenApiReferenceable , V where V : IOpenApiSerializable
12
12
{
13
- /// <summary>
14
- /// The resolved target object. This should remain readonly, otherwise mutating the reference will have side effects.
15
- /// </summary>
16
- protected readonly T _target ;
17
13
/// <inheritdoc/>
18
14
public virtual T Target
19
15
{
20
16
get
21
17
{
22
- if ( _target is not null ) return _target ;
23
18
return Reference . HostDocument ? . ResolveReferenceTo < T > ( Reference ) ;
24
19
}
25
20
}
@@ -34,17 +29,6 @@ protected BaseOpenApiReferenceHolder(BaseOpenApiReferenceHolder<T, V> source)
34
29
//no need to copy summary and description as if they are not overridden, they will be fetched from the target
35
30
//if they are, the reference copy will handle it
36
31
}
37
- private protected BaseOpenApiReferenceHolder ( T target , string referenceId , ReferenceType referenceType )
38
- {
39
- Utils . CheckArgumentNull ( target ) ;
40
- _target = target ;
41
-
42
- Reference = new OpenApiReference ( )
43
- {
44
- Id = referenceId ,
45
- Type = referenceType ,
46
- } ;
47
- }
48
32
/// <summary>
49
33
/// Constructor initializing the reference object.
50
34
/// </summary>
@@ -56,9 +40,11 @@ private protected BaseOpenApiReferenceHolder(T target, string referenceId, Refer
56
40
/// 1. a absolute/relative file path, for example: ../commons/pet.json
57
41
/// 2. a Url, for example: http://localhost/pet.json
58
42
/// </param>
59
- protected BaseOpenApiReferenceHolder ( string referenceId , OpenApiDocument hostDocument , ReferenceType referenceType , string externalResource = null )
43
+ protected BaseOpenApiReferenceHolder ( string referenceId , OpenApiDocument hostDocument , ReferenceType referenceType , string externalResource )
60
44
{
61
45
Utils . CheckArgumentNullOrEmpty ( referenceId ) ;
46
+ // we're not checking for null hostDocument as it's optional and can be set via additional methods by a walker
47
+ // this way object initialization of a whole document is supported
62
48
63
49
Reference = new OpenApiReference ( )
64
50
{
0 commit comments