예제 #1
0
        private SchemaResult CheckSchema(JObject exampleJson, SchemaDefinition definition)
        {
            var jSchema = JSchema.Parse(definition.Schema.ToString(), settings);

            var isValid = exampleJson.IsValid(jSchema, out IList <string> errors);

            if (isValid)
            {
                return(SchemaResult.CreateSuccess(definition.SchemaName, definition.ConsumerName));
            }

            return(SchemaResult.CreateFailure(definition.SchemaName, definition.ConsumerName, errors.ToArray()));
        }
예제 #2
0
        private SchemaResult CheckSchemaAgainstExamples(SchemaDefinition schemaDefinition, IEnumerable <SchemaExample> examples)
        {
            var example = examples.FirstOrDefault(e => schemaDefinition.SchemaName == e.SchemaName);

            if (example == null)
            {
                return(SchemaResult.CreateFailure(schemaDefinition.SchemaName, $"Cannot find example for {schemaDefinition.SchemaName}"));
            }

            var schemaResult = CheckSchema(example.Example, schemaDefinition);

            return(schemaResult);
        }
 internal void AddResult(SchemaResult result)
 {
     this.SchemaResultsList.Add(result);
 }