Skip to content

Comments

Integrate JsonSchemaValidator into JsonConfigurationLoader with optional strict mode#252

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/implement-schema-validation
Draft

Integrate JsonSchemaValidator into JsonConfigurationLoader with optional strict mode#252
Copilot wants to merge 2 commits intomasterfrom
copilot/implement-schema-validation

Conversation

Copy link
Contributor

Copilot AI commented Feb 21, 2026

JsonSchemaValidator existed in isolation with no connection to JsonConfigurationLoader, leaving JSON content unvalidated before deserialization and no mechanism for strict schema enforcement.

Changes

JsonConfigurationLoader.cs

  • Added schemaValidator, schemaName, and strictMode constructor parameters (all opt-in, backward compatible)
  • Schema validation now runs against raw JSON before deserialization in Load()
  • Strict mode (strictMode: true): schema failures abort loading, returning default or null
  • Non-strict mode (default): schema failures emit warnings and deserialization proceeds
  • Logs a warning when schemaValidator is set but schemaName is omitted (misconfiguration guard)
  • Null-guards schemaErrors list from ValidateContent()

JsonConfigurationLoaderTests.cs

Three new tests covering the integration:

  • Valid JSON passes schema and loads successfully
  • Strict mode returns default on schema violation
  • Non-strict mode deserializes with a warning despite schema violation

Configuration/README.md

Updated Quick Start and integration examples to show schemaValidator/schemaName/strictMode usage.

Usage

var schemaValidator = new JsonSchemaValidator(logger);
schemaValidator.LoadSchema("actuator", "schemas/json/actuator-settings.schema.json");

var loader = new JsonConfigurationLoader<ActuatorSettingsJson>(
    logger: logger,
    schemaValidator: schemaValidator,
    schemaName: "actuator",
    strictMode: true   // fail on schema violations; omit for warn-and-continue
);
var config = loader.Load("config/actuator-settings.json");
Original prompt

This section details on the original issue you should resolve

<issue_title>Schema Validation Implementation</issue_title>
<issue_description>Implement JSON schema validator and integrate with configuration loading.

Acceptance Criteria:

  • Schema validation library integrated
  • Validation occurs before config deserialization
  • Clear error messages for validation failures
  • Optional strict mode (fail vs warn)
  • Validation performance acceptable (<100ms)
  • Tests for validation logic

Technical Approach:

  • Use Json.NET Schema or System.Text.Json validation
  • Validate in JsonConfigurationLoader
  • Provide detailed validation errors
  • Consider caching compiled schemas

Files to Modify:

  • Libraries/ACATCore/Utility/JsonConfigurationLoader.cs
  • Create Libraries/ACATCore/Utility/JsonSchemaValidator.cs
  • Update preference loading code

Epic: Configuration System Enhancement

Estimated Effort: 4 days

</issue_description>

<agent_instructions>Review work done in Task #210 and consult Epic 225 and all relevant documentation for current progress. Make sure to update documentation to reflect any changes done.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

…t mode support

Co-authored-by: michaelbeale-IL <63321611+michaelbeale-IL@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement JSON schema validation and integration Integrate JsonSchemaValidator into JsonConfigurationLoader with optional strict mode Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Schema Validation Implementation

2 participants