|
@@ -50,6 +50,18 @@ class ParseJsonSchema(ParseDbSchema):
|
|
|
try:
|
|
|
with open(schema_path, "r") as f:
|
|
|
schema = json.load(f)
|
|
|
+
|
|
|
+ definitions_flag = self._analyze_schema(schema)
|
|
|
+
|
|
|
+ if definitions_flag:
|
|
|
+ schema = self._clean_desciptions_tags_from_single_quotes(schema)
|
|
|
+ schema = self._dereference_schema(schema)
|
|
|
+ # Need to do it again since sub schema could also contain
|
|
|
+ # single quotes
|
|
|
+ schema = self._clean_desciptions_tags_from_single_quotes(schema)
|
|
|
+ self.schemas.append(schema)
|
|
|
+
|
|
|
+ else:
|
|
|
self.schemas.append(schema)
|
|
|
|
|
|
except Exception as e:
|
|
@@ -343,10 +355,13 @@ 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._clean_desciptions_tags_from_single_quotes(schema)
|
|
|
schema = self._dereference_schema(schema)
|
|
|
+ # Need to do it again since sub schema could also contain
|
|
|
+ # single quotes
|
|
|
+ schema = self._clean_desciptions_tags_from_single_quotes(schema)
|
|
|
schema = self._format_schema_for_mongo(schema)
|
|
|
|
|
|
return schema
|
|
@@ -363,12 +378,11 @@ class ParseJsonSchema(ParseDbSchema):
|
|
|
definitions_flag = self._analyze_schema(schema[key], definitions_flag)
|
|
|
|
|
|
return definitions_flag
|
|
|
-
|
|
|
- def _format_schema_for_mongo(self, schema: dict) -> dict:
|
|
|
+
|
|
|
+
|
|
|
+ def _clean_desciptions_tags_from_single_quotes(self, schema: dict) -> dict:
|
|
|
'''
|
|
|
- We use in the schema tags whih are not supported by mongo an threfore
|
|
|
- must be taken care of before setting the schema for mongo.
|
|
|
- :param str schema_path: path to the schema file.
|
|
|
+ :param dict schema: dictonary containing schema
|
|
|
'''
|
|
|
|
|
|
for key in list(schema):
|
|
@@ -378,14 +392,27 @@ class ParseJsonSchema(ParseDbSchema):
|
|
|
schema[key] = cleaned_description
|
|
|
|
|
|
if type(schema[key]) == dict:
|
|
|
- self._format_schema_for_mongo(schema[key])
|
|
|
+ self._clean_desciptions_tags_from_single_quotes(schema[key])
|
|
|
+
|
|
|
+ return schema
|
|
|
|
|
|
- if key == 'examples':
|
|
|
- self._remove_examples(schema)
|
|
|
+ def _format_schema_for_mongo(self, schema: dict) -> dict:
|
|
|
+ '''
|
|
|
+ We use in the schema tags whih are not supported by mongo an threfore
|
|
|
+ must be taken care of before setting the schema for mongo.
|
|
|
+ :param str schema_path: path to the schema file.
|
|
|
+ '''
|
|
|
|
|
|
+ for key in list(schema):
|
|
|
+
|
|
|
+ if type(schema[key]) == dict:
|
|
|
+ self._format_schema_for_mongo(schema[key])
|
|
|
|
|
|
if key == 'default' or key == 'default_values':
|
|
|
self._remove_defaults(schema)
|
|
|
+
|
|
|
+ if key == 'examples':
|
|
|
+ self._remove_examples(schema)
|
|
|
|
|
|
return schema
|
|
|
|