-
Notifications
You must be signed in to change notification settings - Fork 525
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
base: master
Are you sure you want to change the base?
Update utils.py #468
Conversation
There was a problem hiding this 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): |
There was a problem hiding this comment.
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/' |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
Multiple doc_dir can be set in the swagger configuration file
config.py