How to use the flasgger.marshmallow_apispec.convert_schemas function in flasgger

To help you get started, we’ve selected a few flasgger 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 flasgger / flasgger / flasgger / utils.py View on Github external
view_class = getattr(endpoint, 'view_class', None)
            if view_class and issubclass(view_class, SwaggerView):
                apispec_swag = {}
                apispec_attrs = optional_fields + [
                    'parameters', 'definitions', 'responses',
                    'summary', 'description'
                ]
                for attr in apispec_attrs:
                    value = getattr(view_class, attr)
                    if value:
                        apispec_swag[attr] = value

                apispec_definitions = apispec_swag.get('definitions', {})
                swag.update(
                    convert_schemas(apispec_swag, apispec_definitions)
                )
                swag['definitions'] = apispec_definitions

                swagged = True

            if doc_dir:
                if view_class:
                    file_path = os.path.join(
                        doc_dir, endpoint.__name__, method.__name__ + '.yml')
                else:
                    file_path = os.path.join(
                        doc_dir, endpoint.__name__ + '.yml')
                if os.path.isfile(file_path):
                    func = method.__func__ \
                        if hasattr(method, '__func__') else method
                    setattr(func, 'swag_type', 'yml')
github flasgger / flasgger / flasgger / utils.py View on Github external
if method is None:
                if is_mv:  # #76 Empty MethodViews
                    continue
                raise RuntimeError(
                    'Cannot detect view_func for rule {0}'.format(rule)
                )

            swag = {}
            swagged = False

            if getattr(method, 'specs_dict', None):
                definition = {}
                merge_specs(
                    swag,
                    convert_schemas(deepcopy(method.specs_dict), definition)
                )
                swag['definitions'] = definition
                swagged = True

            view_class = getattr(endpoint, 'view_class', None)
            if view_class and issubclass(view_class, SwaggerView):
                apispec_swag = {}
                apispec_attrs = optional_fields + [
                    'parameters', 'definitions', 'responses',
                    'summary', 'description'
                ]
                for attr in apispec_attrs:
                    value = getattr(view_class, attr)
                    if value:
                        apispec_swag[attr] = value