@@ -109,17 +109,16 @@ def _traverse(self, schema, tree, path=tuple(), table='root', parent=None, comme
109109 definition = None
110110 new_json_path = json_path
111111 while '$ref' in tree :
112- p = tree ['$ref' ].lstrip ('#' ).lstrip ('/' ).split ('/' )
113- # TODO: I actually don't think it's required JSON schema that all definitions have to go under #/definitions
114- if len (p ) != 2 and p [0 ] != 'definitions' :
115- warnings .warn ('%s.%s: Broken reference: %s' % (table , self ._column_name (path ), tree ['$ref' ]))
116- return
117- _ , definition = p
118- if definition not in schema ['definitions' ]:
119- warnings .warn ('%s.%s: Broken definition: %s' % (table , self ._column_name (path ), definition ))
120- return
121- tree = schema ['definitions' ][definition ]
122- new_json_path = ('#' , 'definitions' , definition )
112+ ref = tree ['$ref' ]
113+ p = ref .lstrip ('#' ).lstrip ('/' ).split ('/' )
114+ tree = schema
115+ for elem in p :
116+ if elem not in tree :
117+ warnings .warn ('%s.%s: Broken definition: %s' % (table , self ._column_name (path ), ref ))
118+ return
119+ tree = tree [elem ]
120+ new_json_path = ('#' ,) + tuple (p )
121+ definition = p [- 1 ] # TODO(erikbern): we should just make this a boolean variable
123122
124123 special_keys = set (tree .keys ()).intersection (['oneOf' , 'allOf' , 'anyOf' ])
125124 if special_keys :
@@ -137,6 +136,7 @@ def _traverse(self, schema, tree, path=tuple(), table='root', parent=None, comme
137136 res = {}
138137 warnings .warn ('%s.%s: Type info missing' % (table , self ._column_name (path )))
139138 elif tree ['type' ] == 'object' :
139+ print ('object:' , tree )
140140 res = {}
141141 if 'patternProperties' in tree :
142142 # Always create a new table for the pattern properties
0 commit comments