Skip to content

Commit 7994691

Browse files
committed
fix: null propagation for most failed reference lookup
Signed-off-by: Vincent Biret <[email protected]>
1 parent efd2bfb commit 7994691

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs

+11-11
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,21 @@ internal OpenApiSchemaReference(OpenApiSchema target, string referenceId)
116116
}
117117

118118
/// <inheritdoc/>
119-
public override string Title { get => string.IsNullOrEmpty(_title) ? Target.Title : _title; set => _title = value; }
119+
public override string Title { get => string.IsNullOrEmpty(_title) ? Target?.Title : _title; set => _title = value; }
120120
/// <inheritdoc/>
121121
public override string Schema { get => string.IsNullOrEmpty(_schema) ? Target.Schema : _schema; set => _schema = value; }
122122
/// <inheritdoc/>
123123
public override string Id { get => string.IsNullOrEmpty(_id) ? Target.Id : _id; set => _id = value; }
124124
/// <inheritdoc/>
125125
public override string Comment { get => string.IsNullOrEmpty(_comment) ? Target.Comment : _comment; set => _comment = value; }
126126
/// <inheritdoc/>
127-
public override IDictionary<string, bool> Vocabulary { get => _vocabulary is not null ? _vocabulary : Target.Vocabulary; set => _vocabulary = value; }
127+
public override IDictionary<string, bool> Vocabulary { get => _vocabulary is not null ? _vocabulary : Target?.Vocabulary; set => _vocabulary = value; }
128128
/// <inheritdoc/>
129129
public override string DynamicRef { get => string.IsNullOrEmpty(_dynamicRef) ? Target.DynamicRef : _dynamicRef; set => _dynamicRef = value; }
130130
/// <inheritdoc/>
131131
public override string DynamicAnchor { get => string.IsNullOrEmpty(_dynamicAnchor) ? Target.DynamicAnchor : _dynamicAnchor; set => _dynamicAnchor = value; }
132132
/// <inheritdoc/>
133-
public override IDictionary<string, OpenApiSchema> Definitions { get => _definitions is not null ? _definitions : Target.Definitions; set => _definitions = value; }
133+
public override IDictionary<string, OpenApiSchema> Definitions { get => _definitions is not null ? _definitions : Target?.Definitions; set => _definitions = value; }
134134
/// <inheritdoc/>
135135
public override decimal? V31ExclusiveMaximum { get => _v31ExclusiveMaximum is not null ? _v31ExclusiveMaximum.Value : Target.V31ExclusiveMaximum; set => _v31ExclusiveMaximum = value; }
136136
/// <inheritdoc/>
@@ -176,15 +176,15 @@ public override JsonNode Default
176176
/// <inheritdoc/>
177177
public override bool WriteOnly { get => _writeOnly is not null ? _writeOnly.Value : Target.WriteOnly; set => _writeOnly = value; }
178178
/// <inheritdoc/>
179-
public override IList<OpenApiSchema> AllOf { get => _allOf is not null ? _allOf : Target.AllOf; set => _allOf = value; }
179+
public override IList<OpenApiSchema> AllOf { get => _allOf is not null ? _allOf : Target?.AllOf; set => _allOf = value; }
180180
/// <inheritdoc/>
181-
public override IList<OpenApiSchema> OneOf { get => _oneOf is not null ? _oneOf : Target.OneOf; set => _oneOf = value; }
181+
public override IList<OpenApiSchema> OneOf { get => _oneOf is not null ? _oneOf : Target?.OneOf; set => _oneOf = value; }
182182
/// <inheritdoc/>
183-
public override IList<OpenApiSchema> AnyOf { get => _anyOf is not null ? _anyOf : Target.AnyOf; set => _anyOf = value; }
183+
public override IList<OpenApiSchema> AnyOf { get => _anyOf is not null ? _anyOf : Target?.AnyOf; set => _anyOf = value; }
184184
/// <inheritdoc/>
185185
public override OpenApiSchema Not { get => _not is not null ? _not : Target.Not; set => _not = value; }
186186
/// <inheritdoc/>
187-
public override ISet<string> Required { get => _required is not null ? _required : Target.Required; set => _required = value; }
187+
public override ISet<string> Required { get => _required is not null ? _required : Target?.Required; set => _required = value; }
188188
/// <inheritdoc/>
189189
public override OpenApiSchema Items { get => _items is not null ? _items : Target.Items; set => _items = value; }
190190
/// <inheritdoc/>
@@ -194,9 +194,9 @@ public override JsonNode Default
194194
/// <inheritdoc/>
195195
public override bool? UniqueItems { get => _uniqueItems is not null ? _uniqueItems : Target.UniqueItems; set => _uniqueItems = value; }
196196
/// <inheritdoc/>
197-
public override IDictionary<string, OpenApiSchema> Properties { get => _properties is not null ? _properties : Target.Properties ; set => _properties = value; }
197+
public override IDictionary<string, OpenApiSchema> Properties { get => _properties is not null ? _properties : Target?.Properties ; set => _properties = value; }
198198
/// <inheritdoc/>
199-
public override IDictionary<string, OpenApiSchema> PatternProperties { get => _patternProperties is not null ? _patternProperties : Target.PatternProperties; set => _patternProperties = value; }
199+
public override IDictionary<string, OpenApiSchema> PatternProperties { get => _patternProperties is not null ? _patternProperties : Target?.PatternProperties; set => _patternProperties = value; }
200200
/// <inheritdoc/>
201201
public override int? MaxProperties { get => _maxProperties is not null ? _maxProperties : Target.MaxProperties; set => _maxProperties = value; }
202202
/// <inheritdoc/>
@@ -220,7 +220,7 @@ public override IList<JsonNode> Examples
220220
set => Target.Examples = value;
221221
}
222222
/// <inheritdoc/>
223-
public override IList<JsonNode> Enum { get => _enum is not null ? _enum : Target.Enum; set => _enum = value; }
223+
public override IList<JsonNode> Enum { get => _enum is not null ? _enum : Target?.Enum; set => _enum = value; }
224224
/// <inheritdoc/>
225225
public override bool Nullable { get => _nullable is null ? Target.Nullable : _nullable.Value; set => _nullable = value; }
226226
/// <inheritdoc/>
@@ -232,7 +232,7 @@ public override IList<JsonNode> Examples
232232
/// <inheritdoc/>
233233
public override OpenApiXml Xml { get => _xml is not null ? _xml : Target.Xml; set => _xml = value; }
234234
/// <inheritdoc/>
235-
public override IDictionary<string, IOpenApiExtension> Extensions { get => _extensions is not null ? _extensions : Target.Extensions; set => _extensions = value; }
235+
public override IDictionary<string, IOpenApiExtension> Extensions { get => _extensions is not null ? _extensions : Target?.Extensions; set => _extensions = value; }
236236

237237
/// <inheritdoc/>
238238
public override void SerializeAsV31(IOpenApiWriter writer)

0 commit comments

Comments
 (0)