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

Update utils.py #468

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Update utils.py #468

wants to merge 3 commits into from

Conversation

wxhou
Copy link

@wxhou wxhou commented Mar 18, 2021

Multiple doc_dir can be set in the swagger configuration file

config.py

SWAGGER = {
    "doc_dir": ("./apps/docs/", "./apps_demo/docs/")
}

Copy link
Member

@billyrrr billyrrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea on allowing multiple yaml files. Some changes and new test cases would be best.

if hasattr(method, '__func__') else method
setattr(func, 'swag_type', 'yml')
setattr(func, 'swag_path', file_path)
if doc_dir and isinstance(doc_dir, Iterable):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isinstance('./examples/docs/', Iterable) would evaluate to True. Don't worry about this fix tho. I plan to copy a function from marshmallow source code ```def is_iterable_but_not_string(obj) -> bool:

@@ -13,7 +13,7 @@
app = Flask(__name__)
app.config['SWAGGER'] = {
'title': 'Flasgger Parsed Method/Function View Example',
'doc_dir': './examples/docs/'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, we want to maintain backward compatibility, even in our examples, but I would agree with your change to promote this new feature.

func = method.__func__ \
if hasattr(method, '__func__') else method
setattr(func, 'swag_type', 'yml')
setattr(func, 'swag_path', file_path)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen if there are multiple doc_dir? Will setattr(func, 'swag_type', 'yml') override previous definition of func? It would be better if there is a unittest or test case to demonstrate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants