|
@@ -50,16 +50,6 @@ class ParseJsonSchema(ParseDbSchema):
|
|
|
try:
|
|
|
with open(schema_path, "r") as f:
|
|
|
schema = json.load(f)
|
|
|
-
|
|
|
- ref_flag = self._analyze_schema(schema)
|
|
|
-
|
|
|
- if ref_flag:
|
|
|
- schema = self._format_schema_for_mongo(schema)
|
|
|
- schema = self._dereference_schema(schema)
|
|
|
- schema = self._format_schema_for_mongo(schema)
|
|
|
- self.schemas.append(schema)
|
|
|
- else:
|
|
|
- schema = self._format_schema_for_mongo(schema)
|
|
|
self.schemas.append(schema)
|
|
|
|
|
|
except Exception as e:
|
|
@@ -199,7 +189,7 @@ class ParseJsonSchema(ParseDbSchema):
|
|
|
required_only=required_only)
|
|
|
|
|
|
for schema in schemas[1:]:
|
|
|
-
|
|
|
+
|
|
|
next_result = self._parse_one(schema=schema,
|
|
|
field_info=field_info,
|
|
|
required_only=required_only)
|
|
@@ -340,7 +330,7 @@ class ParseJsonSchema(ParseDbSchema):
|
|
|
|
|
|
return already_parsed
|
|
|
|
|
|
- def read_schema_and_parse_for_mongodb(self, schema_path: str) -> dict:
|
|
|
+ def load_and_parse_schema_for_mongodb(self, schema_path: str) -> dict:
|
|
|
'''
|
|
|
We need to deference json before import to Mongo DB pymongo can't deal with references
|
|
|
:param str schema_path: path to the schema file.
|
|
@@ -353,9 +343,9 @@ class ParseJsonSchema(ParseDbSchema):
|
|
|
schema = json.load(json_file)
|
|
|
|
|
|
definitions_flag = self._analyze_schema(schema)
|
|
|
-
|
|
|
+ schema = self._format_schema_for_mongo(schema)
|
|
|
+
|
|
|
if definitions_flag:
|
|
|
- schema = self._format_schema_for_mongo(schema)
|
|
|
schema = self._dereference_schema(schema)
|
|
|
schema = self._format_schema_for_mongo(schema)
|
|
|
|
|
@@ -413,7 +403,7 @@ class ParseJsonSchema(ParseDbSchema):
|
|
|
schema = str(schema).replace("'", "\"")
|
|
|
schema = jsonref.loads(schema, base_uri=base_dir_url)
|
|
|
schema = deepcopy(schema)
|
|
|
- #schema.pop('definitions', None)
|
|
|
+
|
|
|
return schema
|
|
|
|
|
|
def _remove_defaults(self, schema: dict) -> dict:
|