RicoSuter/NJsonSchema

Unable to parse schema with references to other schemas

开放

#328 创建于 2017年2月28日

 (4 条评论) (0 个反应) (0 位负责人)C# (550 个派生)github user discovery
help wantedtype: bug

仓库指标

星标
 (1,581 个星标)
PR 合并指标
 (平均合并 39天 6小时) (30 天内合并 1 个 PR)

描述

I'm trying to generate POCO's from the following JSON 4 schema, which has references to a number of other files.

http://docs.oasis-open.org/ubl/UBL-2.1-JSON/v1.0/cnprd01/json-schema/maindoc/UBL-Invoice-2.1.json

Here is my very basic code.

class Program
    {
        static void Main(string[] args)
        {
            using (var schema = JsonSchema4.FromUrlAsync("http://docs.oasis-open.org/ubl/UBL-2.1-JSON/v1.0/cnprd01/json-schema/maindoc/UBL-Invoice-2.1.json"))
            {
                Console.WriteLine("Reading schema");
                var generator = new CSharpGenerator(schema.Result);

                Console.WriteLine("Writing classes");
                var file = generator.GenerateFile(@"C:\TEMP\Classes\Invoice.cs");
            }
        }
    }

I'm getting the following error

{"Could not resolve the JSON path '../common/UBL-CommonExtensionComponents-2.1.json#/definitions/UBLExtensions' with the full JSON path 'http://docs.oasis-open.org/ubl/UBL-2.1-JSON/v1.0/cnprd01/json-schema/common/UBL-CommonExtensionComponents-2.1.json#/definitions/UBLExtensions'."}

The generator seems to have issue with the following $ref code, of which there are many ocurrences

"properties": {

        "UBLExtensions": {
          "title": "UBLExtensions",
          "description": "An optional set of extensions to the committee model",
          "items": { 
            "$ref": "../common/UBL-CommonExtensionComponents-2.1.json#/definitions/UBLExtensions" },
          "maxItems": 1,
          "minItems": 1,
          "additionalProperties": false,
          "type": "array"
          },

Any ideas how I resolve it?

贡献者指南