예제 #1
0
 /// <summary>
 /// Converts a <see cref="JsonSchema"/> to a matching <see cref="XmlSchema"/>
 /// </summary>
 /// <param name="schema">The schema to convert</param>
 /// <param name = "schemaUri" > Uri that represents the unique id of the Json Schema.</param>
 /// <returns>XmlSchema genrated based on the Json Schema.</returns>
 public XmlSchema Convert(JsonSchema schema, Uri schemaUri)
 {
     _jsonSchema = _normalizer.Normalize(schema);
     _schemaUri  = schemaUri;
     _strategy   = JsonSchemaConverterStrategyFactory.SelectStrategy(_jsonSchema);
     ConvertUsingStrategy();
     return(_xmlSchema);
 }
예제 #2
0
        private async Task <string> ProcessNewXsd(
            AltinnAppGitRepository altinnAppGitRepository,
            MemoryStream xsdMemoryStream,
            string filePath)
        {
            Json.Schema.JsonSchema jsonSchema = GenerateJsonSchemaFromXsd(xsdMemoryStream);
            var jsonContent = SerializeJson(jsonSchema);

            await altinnAppGitRepository.WriteTextByRelativePathAsync(
                Path.ChangeExtension(filePath, "schema.json"), jsonContent, true);

            var jsonSchemaConverterStrategy = JsonSchemaConverterStrategyFactory.SelectStrategy(jsonSchema);
            var metamodelConverter          =
                new JsonSchemaToMetamodelConverter(jsonSchemaConverterStrategy.GetAnalyzer());
            var schemaName    = GetSchemaName(filePath);
            var modelMetadata = metamodelConverter.Convert(schemaName, jsonContent);
            await altinnAppGitRepository.UpdateModelMetadata(modelMetadata, schemaName);

            await UpdateCSharpClasses(altinnAppGitRepository, modelMetadata, schemaName);

            await UpdateApplicationMetadata(altinnAppGitRepository, schemaName, schemaName);

            return(jsonContent);
        }