Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve netkan relationship error message #4020

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Netkan/Validators/ObeysCKANSchemaValidator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ public void Validate(Metadata metadata)
var errors = CKANSchema.schema.Validate(metadata.Json());
if (errors.Any())
{
string msg = errors
.Select(err => $"{err.Path}: {err.Kind}")
.Aggregate((a, b) => $"{a}\r\n{b}");
var msg = string.Join(", ", errors.Select(err => $"{err.Path}: {err.Kind}"));
throw new Kraken($"Schema validation failed: {msg}");
}
}
Expand Down
7 changes: 4 additions & 3 deletions Netkan/Validators/RelationshipsValidator.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System.Linq;

using Newtonsoft.Json.Linq;

using CKAN.Versioning;
using CKAN.NetKAN.Model;
using System.Linq;

namespace CKAN.NetKAN.Validators
{
Expand All @@ -18,7 +20,7 @@ public void Validate(Metadata metadata)
{
throw new Kraken("spec_version v1.2+ required for 'supports'");
}
foreach (JObject rel in json[relName].Cast<JObject>())
foreach (var rel in json[relName].Children<JObject>())
{
if (rel.ContainsKey("any_of"))
{
Expand Down Expand Up @@ -65,7 +67,6 @@ public void Validate(Metadata metadata)
}
}
}

}

private static readonly string[] relProps = new string[]
Expand Down
Loading