0
votes

I get errors when I try to print a schema with two string[] or two List . A string[] and a List are ok .

having this in target class.

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

Causes an error on lines where schema is converted to string not where it is generated.

        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());

I tried with both Newtonsoft.JSON 6.0.8 and latest 7.x and with Newtonsoft.JSON.Schema 1.0.11 I grabbed them with nuget and am running on Xamarin Studio Version 5.9.5 (build 10) Mono 4.0.3 ((detached/d6946b4) on OS X

Errors trace is

System.Uri.EnsureAbsoluteUri () 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:2062 System.Uri.GetComponents (components=System.UriComponents.Host|System.UriComponents.Port|System.UriComponents.Scheme|System.UriComponents.UserInfo, format=System.UriFormat.Unescaped) 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: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}) 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/UriParser.cs:208

System.Uri.IsBaseOf (uri={#/properties/ovoList}) 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:1740

1

1 Answers

0
votes

The problem is that there is not Id. The scheme.ToString function wants procList properties to reference the ovoList properties but it is unable to create a ref because there is no base URI for the schema.

adding

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

Solved this.