using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; namespace Svrnty.CQRS.Events.Abstractions.Schema; /// /// Generates JSON Schema (Draft 7) definitions from CLR types. /// /// /// /// JSON Schemas enable: /// - External consumers (non-.NET clients) to understand event structure /// - Schema validation for incoming/outgoing events /// - Documentation generation /// - Code generation for other languages /// /// /// Implementation Notes: /// This is an optional service. If not registered, events will be stored /// without JSON Schema metadata. This is fine for .NET-to-.NET communication /// but limits interoperability with non-.NET systems. /// /// public interface IJsonSchemaGenerator { /// /// Generates a JSON Schema (Draft 7) for the specified CLR type. /// /// The CLR type to generate schema for. /// Cancellation token. /// JSON Schema as a string (JSON format). /// /// /// The generated schema should follow JSON Schema Draft 7 specification. /// Include property names, types, required fields, and descriptions from /// XML documentation comments if available. /// /// Task GenerateSchemaAsync( Type type, CancellationToken cancellationToken = default); /// /// Validates a JSON string against a JSON Schema. /// /// The JSON data to validate. /// The JSON Schema to validate against. /// Cancellation token. /// True if valid, false otherwise. /// /// /// This is an optional operation. Implementations may throw /// if validation is not supported. /// /// Task ValidateAsync( string jsonData, string jsonSchema, CancellationToken cancellationToken = default); /// /// Gets detailed validation errors if validation fails. /// /// The JSON data to validate. /// The JSON Schema to validate against. /// Cancellation token. /// List of validation error messages, empty if valid. Task> GetValidationErrorsAsync( string jsonData, string jsonSchema, CancellationToken cancellationToken = default); }