Skip to content

Commit 8850294

Browse files
author
Konrad Jamrozik
authored
Fix NRE in CompareRequired (#345)
1 parent 1bc9117 commit 8850294

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

openapi-diff/src/modeler/AutoRest.Swagger/Model/Schema.cs

+6-4
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,16 @@ private void CompareRequired(ComparisonContext<ServiceDefinition> context, Schem
213213
var newRequiredNonReadOnlyPropNames = new List<string>();
214214
foreach (string requiredPropName in Required)
215215
{
216-
Properties.TryGetValue(requiredPropName, out Schema propSchema);
217-
priorSchema.Properties.TryGetValue(requiredPropName, out Schema priorPropSchema);
218-
bool propWasRequired = priorSchema.Required?.Contains(requiredPropName) == true;
216+
Schema propSchema = null;
217+
Schema priorPropSchema = null;
218+
Properties?.TryGetValue(requiredPropName, out propSchema);
219+
priorSchema?.Properties?.TryGetValue(requiredPropName, out priorPropSchema);
220+
bool propWasRequired = priorSchema?.Required?.Contains(requiredPropName) == true;
219221
// Note that property is considered read-only only if it is consistently read-only both in the old and new models.
220222
bool propIsReadOnly = propSchema?.ReadOnly == true && priorPropSchema?.ReadOnly == true;
221223
if (!propWasRequired && !propIsReadOnly)
222224
{
223-
// Property is newly required and it is not read-only, hence it is a breaking change.
225+
// Property is newly required, and it is not read-only, hence it is a breaking change.
224226
newRequiredNonReadOnlyPropNames.Add(requiredPropName);
225227
}
226228
else

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@azure/oad",
3-
"version": "0.10.12",
3+
"version": "0.10.13",
44
"author": {
55
"name": "Microsoft Corporation",
66
"email": "azsdkteam@microsoft.com",

0 commit comments

Comments
 (0)