Skip to content

Commit

Permalink
Null check
Browse files Browse the repository at this point in the history
  • Loading branch information
simpat-adam committed Jul 17, 2024
1 parent 2a72c87 commit 3cf5c75
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/core/EdFi.DataManagementService.Core/ApiService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, List<string>> dependencies =
resourceSchemasObj!.ToDictionary(rs => rs.ResourceName.Value, rs => new List<string>());
resourceSchemas.ToDictionary(rs => rs.ResourceName.Value, rs => new List<string>());

foreach (var resourceSchema in resourceSchemasObj)
foreach (var resourceSchema in resourceSchemas)
{
foreach (var documentPath in resourceSchema.DocumentPaths.Where(d => d.IsReference))
{
Expand All @@ -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")
Expand Down

0 comments on commit 3cf5c75

Please sign in to comment.