Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset swagger attributes in case inheritance is used. #561

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions flasgger/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,21 @@
from functools import wraps, partial
from collections import defaultdict
from flask import Blueprint
from flask import Markup
try:
from flask import Markup
except ImportError:
from markupsafe import Markup
from flask import current_app
from flask import jsonify, Response
from flask import redirect
from flask import render_template
from flask import request, url_for
from flask import abort
from flask.views import MethodView
from flask.json import JSONEncoder
try:
from flask.json import JSONEncoder
except ImportError:
from json import JSONEncoder
try:
from flask_restful.reqparse import RequestParser
except ImportError:
Expand Down
17 changes: 13 additions & 4 deletions flasgger/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,26 @@ def get_specs(rules, ignore_verbs, optional_fields, sanitizer,
swagged = True

if doc_dir:
endpoint_name = rule.endpoint
if "." in endpoint_name:
endpoint_name = endpoint_name.split(".")[-1]

if view_class:
file_path = os.path.join(
doc_dir, endpoint.__name__, method.__name__ + '.yml')
doc_dir, endpoint_name, method.__name__ + '.yml')
else:
file_path = os.path.join(
doc_dir, endpoint.__name__ + '.yml')
doc_dir, endpoint_name + '.yml')
func = method.__func__ \
if hasattr(method, '__func__') else method
if os.path.isfile(file_path):
func = method.__func__ \
if hasattr(method, '__func__') else method
setattr(func, 'swag_type', 'yml')
setattr(func, 'swag_path', file_path)
else:
# Reset in case of inheritance.
setattr(func, 'swag_type', None)
setattr(func, 'swag_path', None)


doc_summary, doc_description, doc_swag = parse_docstring(
method, sanitizer, endpoint=rule.endpoint, verb=verb)
Expand Down