diff --git a/src/core/EdFi.DataManagementService.Core/ApiService.cs b/src/core/EdFi.DataManagementService.Core/ApiService.cs index 2047338dc..f110b30b3 100644 --- a/src/core/EdFi.DataManagementService.Core/ApiService.cs +++ b/src/core/EdFi.DataManagementService.Core/ApiService.cs @@ -290,12 +290,18 @@ public JsonArray GetDependencies() foreach (JsonNode projectSchemaNode in projectSchemaNodes) { - var resourceSchemasObj = projectSchemaNode["resourceSchemas"]!.AsObject().Select(x => new ResourceSchema(x.Value!)); + var resourceSchemas = projectSchemaNode["resourceSchemas"]?.AsObject().Select(x => new ResourceSchema(x.Value!)).ToList(); + if (resourceSchemas == null) + { + string errorMessage = "No resourceSchemas found, ApiSchema.json is invalid"; + _logger.LogCritical(errorMessage); + throw new InvalidOperationException(errorMessage); + } Dictionary> dependencies = - resourceSchemasObj!.ToDictionary(rs => rs.ResourceName.Value, rs => new List()); + resourceSchemas.ToDictionary(rs => rs.ResourceName.Value, rs => new List()); - foreach (var resourceSchema in resourceSchemasObj) + foreach (var resourceSchema in resourceSchemas) { foreach (var documentPath in resourceSchema.DocumentPaths.Where(d => d.IsReference)) { @@ -317,7 +323,7 @@ public JsonArray GetDependencies() int RecursivelyDetermineDependencies(string resourceName, int depth) { - + // Code Smell here: // These resources are similar to abstract base classes, so they are not represented in the resourceSchemas // portion of the schema document. This is a rudimentary replacement with the most specific version of the resource if (resourceName == "EducationOrganization")