Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def update_specs(cls, specs):
if cls.Schema:
specs.definition(cls.meta.name, schema=cls.Schema)
operations = utils.load_operations_from_docstring(cls.__doc__)
specs.add_path(RE_URL.sub(r'{\1}', cls.meta.url), operations=cls.update_operations_specs(
operations, ('GET', 'POST'),
))
if cls.meta.url_detail:
ops = cls.update_operations_specs(
operations, ('GET', 'PUT', 'PATCH', 'DELETE'), parameters=[{
'name': cls.meta.name,
'in': 'path',
'description': 'Resource Identifier',
'type': 'string',
'required': True,
}]
)
specs.add_path(RE_URL.sub(r'{\1}', cls.meta.url_detail), operations=ops)
schema = {}
if cls.Schema:
schema['$ref'] = '#/definitions/%s' % cls.meta.name
defaults['parameters'].append({
'name': 'body',
'in': 'body',
'description': 'Resource Body',
'required': True,
'schema': schema,
})
if method_name in operations:
defaults.update(operations[method_name])
docstring_yaml = utils.load_yaml_from_docstring(cls_method.__doc__)
if docstring_yaml:
defaults.update(docstring_yaml)
result[method_name] = defaults
return result