public static JSONSchema <T> Of(ISchemaDefinition <T> schemaDefinition) { ISchemaReader <T> Reader = schemaDefinition.SchemaReaderOpt.GetOrElse(new JsonReader <T>(_jsonMapper)); ISchemaWriter <T> Writer = schemaDefinition.SchemaWriterOpt.GetOrElse(new JsonWriter <T>(_jsonMapper)); return(new JSONSchema <T>(SchemaUtils.ParseSchemaInfo(schemaDefinition, SchemaType.JSON), schemaDefinition.Pojo, Reader, Writer)); }
public static AvroSchema <T> Of(ISchemaDefinition <T> schemaDefinition) { if (schemaDefinition.SchemaReaderOpt.HasValue && schemaDefinition.SchemaWriterOpt.HasValue) { return(new AvroSchema <T>(schemaDefinition.SchemaReaderOpt.Value, schemaDefinition.SchemaWriterOpt.Value, SchemaUtils.ParseSchemaInfo(schemaDefinition, SchemaType.AVRO))); } return(new AvroSchema <T>(SchemaUtils.ParseSchemaInfo(schemaDefinition, SchemaType.AVRO))); }
private static ISchemaInfo DecodeSubSchemaInfo(ISchemaInfo parentSchemaInfo, string schemaNameProperty, string schemaTypeProperty, string schemaPropsProperty, byte[] schemaData) { var parentSchemaProps = parentSchemaInfo.Properties; var schemaName = parentSchemaProps.GetOrDefault(schemaNameProperty, ""); var schemaType = SchemaType.ValueOf(parentSchemaProps.GetOrDefault(schemaTypeProperty, SchemaType.BYTES.Name)); IDictionary <string, string> schemaProps; if (!parentSchemaProps.TryGetValue(schemaPropsProperty, out var schemaPropsStr)) { schemaProps = new Dictionary <string, string>(); } else { schemaProps = SchemaUtils.DeserializeSchemaProperties(schemaPropsStr); } return(new SchemaInfo { Name = schemaName, Type = schemaType, Schema = schemaData, Properties = schemaProps }); }
private static void EncodeSubSchemaInfoToParentSchemaProperties(ISchemaInfo schemaInfo, string schemaNameProperty, string schemaTypeProperty, string schemaPropsProperty, IDictionary <string, string> parentSchemaProperties) { parentSchemaProperties[schemaNameProperty] = schemaInfo.Name; parentSchemaProperties[schemaTypeProperty] = schemaInfo.Type.ToString(); parentSchemaProperties[schemaPropsProperty] = SchemaUtils.SerializeSchemaProperties(schemaInfo.Properties); }
public AvroBaseStructSchema(ISchemaInfo schemaInfo) : base(schemaInfo) { schema = SchemaUtils.ParseAvroSchema(Encoding.UTF8.GetString(schemaInfo.Schema)); }