Closed nikitph closed 7 years ago
I haven't used Eve-Mongoengine, but I think this is a Eve-Mongoengine error.
The problem is that Eve-Mongoengine doesn't include the '_id'
field (which is the default item_lookup_field
) in the schema. Eve-Swagger expects something like '_id': {'type': 'objectid'}
in the schema of each resource.
i am unable to get eve- swagger to work with my eve-mongoengine/eve app.
my code looks like this
`from eve import Eve from eve_mongoengine import EveMongoengine from eve_swagger import swagger, add_documentation
init application
from models import *
all = ( 'create_connection', 'disconnect', 'get_connection', 'DEFAULT_CONNECTION_NAME', 'fetch_connection_settings', 'InvalidSettingsError', 'get_db' )
DEFAULT_CONNECTION_NAME = 'default-mongodb-connection'
MONGODB_SETTINGS = {
}
app = Eve(settings=MONGODB_SETTINGS)
init extension
ext = EveMongoengine(app) app.register_blueprint(swagger) app.config['SWAGGER_INFO'] = { 'title': 'My Supercool API', 'version': '1.0', 'description': 'an API description', 'termsOfService': 'my terms of service', 'contact': { 'name': 'nicola' }, 'license': { 'name': 'BSD' } }
register model to eve
ext.add_model([Item,MessageThreads,Messages])
let's roll
app.run(host='127.0.0.1', port=8001,debug=True)`
full stack trace
File "/Users/Omkareshwar/PycharmProjects/apid/apid/lib/python2.7/site-packages/flask/app.py", line 1475, in full_dispatch_request rv = self.dispatch_request() File "/Users/Omkareshwar/PycharmProjects/apid/apid/lib/python2.7/site-packages/flask/app.py", line 1461, in dispatch_request return self.view_functionsrule.endpoint File "/Users/Omkareshwar/PycharmProjects/apid/apid/lib/python2.7/site-packages/eve_swagger/swagger.py", line 38, in decorated resp = make_response(f(*args, **kwargs)) File "/Users/Omkareshwar/PycharmProjects/apid/apid/lib/python2.7/site-packages/eve_swagger/swagger.py", line 101, in index node(root, 'parameters', parameters()) File "/Users/Omkareshwar/PycharmProjects/apid/apid/lib/python2.7/site-packages/eve_swagger/objects.py", line 76, in parameters eve_type = rd['schema'][lookup_field]['type'] KeyError: '_id'
my requirements.txt looks like this
blinker==1.4 Cerberus==0.9.2 Eve==0.4 Eve-Mongoengine==0.0.9 Eve-Swagger==0.0.5 Events==0.2.1 Flask==0.10.1 flask-mongoengine==0.8 Flask-PyMongo==0.4.1 Flask-WTF==0.13.1 itsdangerous==0.24 Jinja2==2.7.3 MarkupSafe==0.23 mongoengine==0.10.6 pymongo==3.2.1 simplejson==3.8.2 Werkzeug==0.11.4 WTForms==2.1