Json.Net.Schema 两个字符串数组时出错

Json.Net.Schema error when two string arrays

当我尝试打印包含两个 string[] 或两个 List 的架构时出现错误。 string[] 和 List 都可以。

在目标中有这个 class。

public string[] ovoList;
public string[] procList;

在将架构转换为字符串而不是在生成架构的行上导致错误。

        static void Main(){
        JSchemaGenerator generator = new JSchemaGenerator();

        JSchema schema = generator.Generate(typeof(UNIKK.UIEngine.UIFrame));
        //Error is thrown on two lines below 
        Console.WriteLine(schema);
        File.WriteAllText(@"OVOSchema.json", schema.ToString());

我尝试使用 Newtonsoft.JSON 6.0.8 和最新的 7.x 以及 Newtonsoft.JSON.Schema 1.0.11 我用 nuget 抓住了它们并且 运行 Xamarin工作室 版本 5.9.5(构建 10) 单声道 4.0.3 ((detached/d6946b4) 在 OS X

错误跟踪是

System.Uri.EnsureAbsoluteUri() 在/private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System/System/Uri.cs:2062 System.Uri.GetComponents(组件=System.UriComponents.Host|System.UriComponents.Port|System.UriComponents.Scheme|System.UriComponents.UserInfo,格式=System.UriFormat.Unescaped)在/private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System/System/Uri.cs:1731 System.Uri.Compare (uri1={#}, uri2={#/properties/ovoList}, partsToCompare=System.UriComponents.Host|System.UriComponents.Port|System.UriComponents.Scheme|System.UriComponents.UserInfo, compareFormat =System.UriFormat.Unescaped, comparisonType=System.StringComparison.InvariantCultureIgnoreCase) in /private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System/System/Uri.cs:1768 System.UriParser.IsBaseOf (baseUri={#}, relativeUri={#/properties/ovoList}) 在/private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System/System/UriParser.cs:208

System.Uri.IsBaseOf (uri={#/properties/ovoList}) 在 /private/tmp/source-mono-mac-4.0.0-branch-c5sr3/bockbuild-mono-4.0.0-branch/profiles/mono-mac-xamarin/build-root/mono-4.0.3/mcs/class/System/System/Uri.cs:1740

问题是没有Id。 scheme.ToString 函数希望 procList 属性引用 ovoList 属性,但它无法创建引用,因为没有架构的基本 URI。

添加

schema.Id = new Uri ("http://www.example.com/"); 

解决了这个问题。