lafrech / test Goto Github PK
View Code? Open in Web Editor NEWtest
test
Issue by sloria
Monday Jul 30, 2018 at 00:44 GMT
Originally opened as marshmallow-code/apispec#257
From #246:
Also the web framework path helpers deal with operations quite a lot, and perhaps this logic should be split into path_helper and operation_helper. From a quick glance, the coupling between the two seems loose. Could be a bit trickier with flask due to the if method in rule.methods test, which covers what looks like a twisted but legit case (method declared in the view but not in the rule).
Issue by deckar01
Wednesday Apr 27, 2016 at 17:42 GMT
Originally opened as marshmallow-code/apispec#68
I have organized my views with Flask blueprints, but am unable to document them in the view file, because it is not executed in the application context.
# app/views/example.py
from flask import Blueprint
example_view = Blueprint('example_view', __name__)
from app.spec import spec
@bp.route('example', methods=['GET'])
def get_example():
"""An example.
---
get:
description: Get an example
responses:
200:
description: An example
schema: ExampleSchema
"""
return 'example', 200
spec.add_path(view=get_example)
...
File "/usr/local/lib/python2.7/site-packages/apispec/core.py", line 170, in add_path
self, path=path, operations=operations, **kwargs
File "/usr/local/lib/python2.7/site-packages/apispec/ext/flask.py", line 62, in path_from_view
rule = _rule_for_view(view)
File "/usr/local/lib/python2.7/site-packages/apispec/ext/flask.py", line 38, in _rule_for_view
view_funcs = current_app.view_functions
File "/usr/local/lib/python2.7/site-packages/werkzeug/local.py", line 343, in __getattr__
return getattr(self._get_current_object(), name)
File "/usr/local/lib/python2.7/site-packages/werkzeug/local.py", line 302, in _get_current_object
return self.__local()
File "/usr/local/lib/python2.7/site-packages/flask/globals.py", line 34, in _find_app
raise RuntimeError('working outside of application context')
RuntimeError: working outside of application context
Is there a way to keep the spec declarations with the blueprint? (It seems like there might not be.)
Do you think it would be useful to add the ability to add all the views from a blueprint at once?
I noticed that the flask extension seems to acknowledge that a view could contain multiple paths, but assumes it only contains one. apispec/ext/flask.py#L46
Maybe something like spec.add_paths()
could be added to handle compound view objects?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.