public JsonSchema GetConnectorsSchema() { var docSchema = JsonSchemaEx.CreateObject("Document"); var connectionSchema = CreateAddonAdapters(docSchema, "Connection", _providerProcessorAdapter) .AddAsDefinition(docSchema); docSchema .SetAsDictionary(connectionSchema); return(docSchema); }
private static JsonSchema CreateAddonAdapter(JsonSchema docSchema, IProviderProcessorAdapter inputOutputAdapter) { var connectionParameterSchema = JsonSchema .FromType(inputOutputAdapter.ConnectionParametersType) .AddAsDefinition(docSchema); var adapterSchema = JsonSchemaEx .CreateObject($"Adapter_{inputOutputAdapter.Name}") .AddProperty("Type", new JsonSchemaProperty { Pattern = $"^{inputOutputAdapter.Name}$" }, true) .AddProperty("Connection", connectionParameterSchema, false); if (inputOutputAdapter.ProviderParametersType != null) { var providerParameterSchema = JsonSchema .FromType(inputOutputAdapter.ProviderParametersType) .AddStringProperty("Name", false); var providersSchema = JsonSchemaEx .CreateDictionary($"Sources_{inputOutputAdapter.Name}", providerParameterSchema) .AddAsDefinition(docSchema); adapterSchema .AddProperty("Providers", providersSchema, false); } if (inputOutputAdapter.ProcessorParametersType != null) { var processorParameterSchema = JsonSchema .FromType(inputOutputAdapter.ProcessorParametersType) .AddStringProperty("Name", false); var processorsSchema = JsonSchemaEx .CreateDictionary($"Processes_{inputOutputAdapter.Name}", processorParameterSchema) .AddAsDefinition(docSchema); adapterSchema .AddProperty("Processors", processorsSchema, false); } return(adapterSchema.AddAsDefinition(docSchema)); }