@@ -10,16 +10,11 @@ namespace Microsoft.OpenApi.Models.References;
1010/// <typeparam name="V">The interface type for the model.</typeparam>
1111public abstract class BaseOpenApiReferenceHolder < T , V > : IOpenApiReferenceHolder < T , V > where T : class , IOpenApiReferenceable , V where V : IOpenApiSerializable
1212{
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 ;
1713 /// <inheritdoc/>
1814 public virtual T Target
1915 {
2016 get
2117 {
22- if ( _target is not null ) return _target ;
2318 return Reference . HostDocument ? . ResolveReferenceTo < T > ( Reference ) ;
2419 }
2520 }
@@ -34,17 +29,6 @@ protected BaseOpenApiReferenceHolder(BaseOpenApiReferenceHolder<T, V> source)
3429 //no need to copy summary and description as if they are not overridden, they will be fetched from the target
3530 //if they are, the reference copy will handle it
3631 }
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- }
4832 /// <summary>
4933 /// Constructor initializing the reference object.
5034 /// </summary>
@@ -56,9 +40,11 @@ private protected BaseOpenApiReferenceHolder(T target, string referenceId, Refer
5640 /// 1. a absolute/relative file path, for example: ../commons/pet.json
5741 /// 2. a Url, for example: http://localhost/pet.json
5842 /// </param>
59- protected BaseOpenApiReferenceHolder ( string referenceId , OpenApiDocument hostDocument , ReferenceType referenceType , string externalResource = null )
43+ protected BaseOpenApiReferenceHolder ( string referenceId , OpenApiDocument hostDocument , ReferenceType referenceType , string externalResource )
6044 {
6145 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
6248
6349 Reference = new OpenApiReference ( )
6450 {
0 commit comments