How to use the apispec.utils function in apispec

To help you get started, we’ve selected a few apispec examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github klen / flask-restler / flask_restler / resource.py View on Github external
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)
github klen / flask-restler / flask_restler / resource.py View on Github external
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