python - Move Flask-Restplus Swagger API Docs -


i'm trying use flask-restplus build restful api in python. i'd have swagger docs located in different place normal "/".

i'm following documentation here , have followed instructions. i'm using python2.7.3 , have following code ~/dev/test/app.py:

from flask import flask flask.ext.restplus import api, apidoc  app = flask(__name__) api = api(app, ui=false)  @api.route('/doc/', endpoint='doc') def swagger_ui():     return apidoc.ui_for(api)  app.register_blueprint(apidoc.apidoc) 

when try run python app.py get:

traceback (most recent call last):   file "app.py", line 7 in <module>     @api.route('/doc/', endpoint='doc')   file "/home/logan/.virtualenvs/test/lib/python2.7/site-packages/flask_restplus/api.py", line 191, in wrapper     self.add_resources(cls, *urls, **kwargs)   file "/home/logan/.virtualenvs/test/lib/python2.7/site-packages/flask_restplus/api.py", line 175, in add_resource     super(api, self).add_resource(resource, *urls, **kwargs)   file "/home/logan/.virtualenvs/test/lib/python2.7/site-packages/flask_restful/__init__.py", line 396, in add_resource     self._register_view(self.app, resource, *urls, **kwargs)   file "/home/logan/.virtualenvs/test/lib/python2.7/site-packages/flask_restful/__init__.py", line 435, in _register_view     resource_func = self.output(resource.as_view(endpoint, *resource_class_args, attributeerror: 'function' object has no attribute 'as_view' 

i'm not sure going wrong, guess understand haven't inherited resource as_view come from, documentation seems indicate should work.

any apprecaited.

with flask-restplus <= 0.8.0 should write:

from flask import flask flask.ext.restplus import api, apidoc  app = flask(__name__) api = api(app, ui=false)  @app.route('/doc/', endpoint='doc') def swagger_ui():     return apidoc.ui_for(api) 

note use of @app instead of @api

starting v0.8.1 (soon released), have write:

from flask import flask flask.ext.restplus import api, apidoc  app = flask(__name__) api = api(app, doc='/doc/') 

see: http://flask-restplus.readthedocs.org/en/latest/swagger.html#swagger-ui


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -