private async Task UpdateAppTexts( string org, string repository, string developer, Manatee.Json.Schema.JsonSchema jsonSchema) { JsonSchemaToInstanceModelGenerator converter = new JsonSchemaToInstanceModelGenerator(org, repository, jsonSchema); var newTexts = converter.GetTexts(); var altinnAppGitRepository = _altinnGitRepositoryFactory.GetAltinnAppGitRepository(org, repository, developer); var existingTexts = await altinnAppGitRepository.GetTextResourcesForAllLanguages(); MergeTexts(newTexts, existingTexts); await altinnAppGitRepository.SaveServiceTexts(existingTexts); }
private static Stream ConvertJsonSchemaToXsd(Manatee.Json.Schema.JsonSchema jsonSchema) { JsonSchemaToXsd jsonSchemaToXsd = new JsonSchemaToXsd(); XmlSchema xmlschema = jsonSchemaToXsd.CreateXsd(jsonSchema); MemoryStream xsdMemoryStream = new MemoryStream(); XmlTextWriter xmlTextWriter = new XmlTextWriter(xsdMemoryStream, new UpperCaseUtf8Encoding()); xmlTextWriter.Formatting = Formatting.Indented; xmlTextWriter.WriteStartDocument(false); xmlschema.Write(xsdMemoryStream); xsdMemoryStream.Seek(0, SeekOrigin.Begin); return(xsdMemoryStream); }
public static string ValidateSchema(string jsonText, string schemaText) { var serializer = new Manatee.Json.Serialization.JsonSerializer(); var json = Manatee.Json.JsonValue.Parse(jsonText); var schemaJson = Manatee.Json.JsonValue.Parse(schemaText); var schema = new Manatee.Json.Schema.JsonSchema(); schema.FromJson(schemaJson, serializer); Manatee.Json.Schema.JsonSchemaOptions.OutputFormat = Manatee.Json.Schema.SchemaValidationOutputFormat.Basic; var validationResults = schema.ValidateSchema(); if (!validationResults.IsValid) { json = serializer.Serialize(validationResults); return(JsonHelper.FormatJson(json.ToString())); } else { return(""); } }
private static string SerializeJson(Manatee.Json.Schema.JsonSchema jsonSchema) { return(new Manatee.Json.Serialization.JsonSerializer().Serialize(jsonSchema).GetIndentedString(0)); }
private static string GetRootName(Manatee.Json.Schema.JsonSchema jsonSchema) { Guard.AssertArgumentNotNull(jsonSchema.Properties(), nameof(jsonSchema)); return(jsonSchema.Properties().FirstOrDefault().Key); }
/// <summary> /// Builds an object from a <see cref="JsonValue"/>. /// </summary> /// <param name="json">The <see cref="JsonValue"/> representation of the object.</param> /// <param name="serializer">The <see cref="JsonSerializer"/> instance to use for additional /// serialization of values.</param> public void FromJson(JsonValue json, JsonSerializer serializer) { Value = serializer.Deserialize <JsonSchema>(json); }
#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable. /// <summary> /// Creates an instance of the <see cref="AdditionalItemsKeyword"/>. /// </summary> public ContainsKeyword(JsonSchema value) { Value = value; }
/// <summary> /// Creates an instance of the <see cref="AdditionalItemsKeyword"/>. /// </summary> public AdditionalItemsKeyword(JsonSchema value) { Value = value; }
#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable. /// <summary> /// Creates an instance of the <see cref="ElseKeyword"/>. /// </summary> public ElseKeyword(JsonSchema value) { Value = value; }
#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable. /// <summary> /// Creates an instance of the <see cref="ContentSchemaKeyword"/>. /// </summary> public ContentSchemaKeyword(JsonSchema value) { Value = value; }
/// <summary> /// Creates an instance of the <see cref="ThenKeyword"/>. /// </summary> public ThenKeyword(JsonSchema value) { Value = value; }
#pragma warning restore CS8618 // Non-nullable field is uninitialized. Consider declaring as nullable. /// <summary> /// Creates an instance of the <see cref="UnevaluatedPropertiesKeyword"/>. /// </summary> public UnevaluatedPropertiesKeyword(JsonSchema value) { Value = value; }