Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
    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("");
        }
    }
Exemple #4
0
 private static string SerializeJson(Manatee.Json.Schema.JsonSchema jsonSchema)
 {
     return(new Manatee.Json.Serialization.JsonSerializer().Serialize(jsonSchema).GetIndentedString(0));
 }
Exemple #5
0
        private static string GetRootName(Manatee.Json.Schema.JsonSchema jsonSchema)
        {
            Guard.AssertArgumentNotNull(jsonSchema.Properties(), nameof(jsonSchema));

            return(jsonSchema.Properties().FirstOrDefault().Key);
        }
Exemple #6
0
 /// <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);
 }
Exemple #7
0
#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;
        }
Exemple #8
0
 /// <summary>
 /// Creates an instance of the <see cref="AdditionalItemsKeyword"/>.
 /// </summary>
 public AdditionalItemsKeyword(JsonSchema value)
 {
     Value = value;
 }
Exemple #9
0
#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;
        }
Exemple #10
0
#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;
        }
Exemple #11
0
 /// <summary>
 /// Creates an instance of the <see cref="ThenKeyword"/>.
 /// </summary>
 public ThenKeyword(JsonSchema value)
 {
     Value = value;
 }
Exemple #12
0
#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;
        }