carreraGroup / json-to-avro-schema

Converts JSON schema to AVRO schema
Apache License 2.0
2 stars 1 forks source link

Resolve local $id as a subnamespace #27

Open rubberduck203 opened 3 years ago

rubberduck203 commented 3 years ago

Related to #3

Consider the following schema.

   {
       "$id": "http://example.com/root.json",
       "definitions": {
           "A": { "$id": "#foo" },
           "B": {
               "$id": "other.json",
               "definitions": {
                   "X": { "$id": "#bar" },
                   "Y": { "$id": "t/inner.json" }
               }
           },
       }
   }

The type of X resolves to a canonical URI of http://example.com/other.json/#bar. Currently, we ignore the different namespace and just return bar as the name of the record in avro. i.e. com.example.root.bar when it should be com.example.other.bar.

To accomplish this, we'll likely need to pass the parent schema along as context in the transpiler, so we can walk back up the tree looking for the closest $id definition.