Пример #1
0
        static string DumpDeclarationsToJson(string inputFile, Declaration declaration)
        {
            string schema_errors = null;
            string output        = DeclarationSerializer.Serialize(declaration, ref schema_errors);

            if (!String.IsNullOrEmpty(schema_errors))
            {
                Logger.Error("Json schema errors:" + schema_errors);
            }
            else
            {
                Logger.Info("Json schema OK");
            }

            Logger.Info("Output size: " + output.Length);

            if (ValidateByApi)
            {
                string validationResult = ApiClient.ValidateParserOutput(output);
                if (validationResult != "[]")
                {
                    string inputFileName  = Path.GetFileName(inputFile);
                    string errorsFileName = "validation_errors_" +
                                            Path.GetFileNameWithoutExtension(inputFileName) + ".json";
                    var rep = MiscSerializer.DeserializeValidationReport(validationResult);
                    File.WriteAllText(errorsFileName, validationResult);
                    Logger.Error("Api validation failed. Errors:" + errorsFileName);
                }
            }
            return(output);
        }
Пример #2
0
        public static void ReportUnknownEntry(UnknownEntry ue)
        {
            string jsonContents = MiscSerializer.Serialize(ue);
            var    contents     = new StringContent(jsonContents, Encoding.UTF8, "application/json");
            var    httpResponse = HttpClient.PostAsync(ReportUnknownEntryUrl, contents).Result;

            if (!httpResponse.IsSuccessStatusCode)
            {
                throw new DeclaratorApiException(httpResponse, "Could not report unknown entry to Declarator API");
            }
        }