Json configuration fails validation

Hi,
working with configurations, I wanted to validate the following saml.json

{
  "SAML": {
    "$schema": "https://www.componentspace.com/schemas/saml-config-schema-v1.0.json",
    "Configurations": [
      {
        "LocalIdentityProviderConfiguration": {
          "Name": "https://ExampleIdentityProvider",
          "Description": "Example Identity Provider",
          "SingleSignOnServiceUrl": "https://localhost:44313/SAML/SingleSignOnService",
          "LocalCertificates": [
            {
              "FileName": "certificates/idp.pfx",
              "Password": "password"
            }
          ]
        },
        "PartnerServiceProviderConfigurations": [
          {
            "Name": "https://ExampleServiceProvider",
            "Description": "Example Service Provider",
            "AssertionConsumerServiceUrl": "https://localhost:44360/SAML/AssertionConsumerService",
            "SingleLogoutServiceUrl": "https://localhost:44360/SAML/SingleLogoutService",
            "PartnerCertificates": [
              {
                "FileName": "certificates/sp.cer"
              }
            ]
          }
        ]
      }
    ]
  }
}

using the json schema componentspace.com/schemas/saml-config-schema-v1.0.json.

But it fails.
I also used JSON Schema Validator - Newtonsoft to investigate and I found out that the problem is in the last lines of the schema

"required": [ "Configurations" ]

If i remove them, validation works.
But my saml.json contains the property Configuration.

What am I doing wrong?

Thank you
Fabio

I wasn’t able to reproduce the issue. I used the same schema validator and copy/pasted the exact same SAML configuration you posted. It reported “No errors found. JSON validates against the schema”.

Here’s what I get if I copy&paste the schema

And It’s exactly the error I get when I try to validate the JSON in my application with the method below:

static bool ValidateJsonString(string jsonFilePath, string jsonSchemaData)
      {
          string jsonData = File.ReadAllText(jsonFilePath);

          JSchema schema = JSchema.Parse(jsonSchemaData);
          JObject json = JObject.Parse(jsonData);

          bool isValid = json.IsValid(schema, out IList<string> errors);

          if (!isValid)
          {
              Console.WriteLine("- JSON validation errors:");
              foreach (string error in errors)
              {
                  Console.WriteLine($"   - {error}");
              }
          }

          return isValid;
      }

Thank you
Fabio

The { "SAML": {}} object isn’t specified in the schema.

The schema should be applied to the { "Configurations": []} object.

By convention we use the “SAML” object to clearly identify the SAML configuration when it’s part of appsettings.json.

Ok thank you now It works!

Since we are moving from ASP.NET to netcore, I’m in the need to convert ALL the saml.config from xml to JSON: do you have any tool, snippet or example to do that?

I’m afraid not although it shouldn’t be too hard to write some code to do this.