Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def schema2jsonschema(self, schema):
if self.openapi_version.major < 3 or not is_value_typed_dict(schema):
return super(ValueTypedDictOpenAPIConverter, self).schema2jsonschema(schema)
schema_type = schema.value_type
schema_instance = common.resolve_schema_instance(schema_type)
schema_key = common.make_schema_key(schema_instance)
if schema_key not in self.refs:
component_name = self.schema_name_resolver(schema_type)
self.spec.components.schema(component_name, schema=schema_instance)
ref_dict = self.get_ref_dict(schema_instance)
return {
u'type': u'object',
u'additionalProperties': ref_dict,
}
def resolver(schema):
schema_instance = common.resolve_schema_instance(schema)
prefix = "Partial-" if schema_instance.partial else ""
schema_cls = common.resolve_schema_cls(schema)
name = prefix + schema_cls.__name__
if name.endswith("Schema"):
return name[:-6] or name
return name
def dump(self, obj, many=None, update_fields=True, **kwargs):
schema = common.resolve_schema_instance(self.value_type)
result = {}
for entry in obj:
part = schema.dump(entry).data
result[part[self.key_name]] = part
if not self.keep_key:
del part[self.key_name]
return MarshalResult(result, [])
def schema2jsonschema(self, schema):
if self.openapi_version.major < 3 or not is_value_typed_dict(schema):
return super(ValueTypedDictOpenAPIConverter, self).schema2jsonschema(schema)
schema_type = schema.value_type
schema_instance = common.resolve_schema_instance(schema_type)
schema_key = common.make_schema_key(schema_instance)
if schema_key not in self.refs:
component_name = self.schema_name_resolver(schema_type)
self.spec.components.schema(component_name, schema=schema_instance)
ref_dict = self.get_ref_dict(schema_instance)
return {
u'type': u'object',
u'additionalProperties': ref_dict,
}