public async Task GenerateSchemaAsync(DirectoryInfo directoryInfo, JsonHelper jsonHelper) { await jsonHelper.WriteJsonSchemaAsync <SchemeModel>(directoryInfo, "schema.json"); var sample = new SchemeModel { Name = "my-schema", Schema = new SynchronizeSchemaDto { Properties = new SchemaPropertiesDto { Label = "My Schema" }, Fields = new List <UpsertSchemaFieldDto> { new UpsertSchemaFieldDto { Name = "my-string", Properties = new StringFieldPropertiesDto { IsRequired = true }, Partitioning = "invariant" } }, IsPublished = true } }; await jsonHelper.WriteWithSchema(directoryInfo, "schemas/__schema.json", sample, "../__json/schema"); }
public async Task ExportAsync(ISyncService sync, SyncOptions options, ISession session) { var current = await session.Schemas.GetSchemasAsync(session.App); var schemaMap = current.Items.ToDictionary(x => x.Id, x => x.Name); foreach (var schema in current.Items.OrderBy(x => x.Name)) { await log.DoSafeAsync($"Exporting '{schema.Name}'", async() => { var details = await session.Schemas.GetSchemaAsync(session.App, schema.Name); var model = new SchemeModel { Name = schema.Name, Schema = sync.Convert <SynchronizeSchemaDto>(details), SchemaType = details.Type, IsSingleton = details.IsSingleton }; MapReferences(model.Schema, schemaMap); await sync.WriteWithSchema(new FilePath($"schemas", $"{schema.Name}.json"), model, Ref); }); } }
public async Task ExportAsync(DirectoryInfo directoryInfo, JsonHelper jsonHelper, SyncOptions options, ISession session) { var current = await session.Schemas.GetSchemasAsync(session.App); var schemaMap = current.Items.ToDictionary(x => x.Id, x => x.Name); foreach (var schema in current.Items.OrderBy(x => x.Name)) { await log.DoSafeAsync($"Exporting '{schema.Name}'", async() => { var details = await session.Schemas.GetSchemaAsync(session.App, schema.Name); var model = new SchemeModel { Name = schema.Name }; model.Schema = jsonHelper.Convert <SynchronizeSchemaDto>(details); MapReferences(model.Schema, schemaMap); await jsonHelper.WriteWithSchema(directoryInfo, $"schemas/{schema.Name}.json", model, "../__json/schema"); }); } }
public async Task GenerateSchemaAsync(ISyncService sync) { await sync.WriteJsonSchemaAsync <SchemeModel>(new FilePath("schema.json")); var sample = new SchemeModel { Name = "my-schema", Schema = new SynchronizeSchemaDto { Properties = new SchemaPropertiesDto { Label = "My Schema" }, Fields = new List <UpsertSchemaFieldDto> { new UpsertSchemaFieldDto { Name = "my-string", Properties = new StringFieldPropertiesDto { IsRequired = true }, Partitioning = "invariant" } }, IsPublished = true } }; await sync.WriteWithSchema(new FilePath("schemas", "__schema.json"), sample, Ref); }