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