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

Schema error when using "description" or "example", unknown rule #1264

Closed
rmlopes opened this issue Apr 29, 2019 · 1 comment

Comments

Projects
None yet
2 participants
@rmlopes
Copy link

commented Apr 29, 2019

Expected Behavior

The description and example properties are used in the documentation. Description is a string, and example an instance of the entity.

# eve-demo
# Add "description" to one of the entities

Actual Behavior

Error in POST:

Traceback (most recent call last):
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/eve/endpoints.py", line 58, in collections_endpoint
    response = post(resource)
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/eve/methods/common.py", line 318, in rate_limited
    return f(*args, **kwargs)
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/eve/auth.py", line 80, in decorated
    return f(*args, **kwargs)
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/eve/methods/common.py", line 1351, in decorated
    r = f(resource, **combined_args)
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/eve/methods/post.py", line 49, in post
    return post_internal(resource, payl, skip_validation=False)
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/eve/methods/post.py", line 167, in post_internal
    schema, resource=resource, allow_unknown=resource_def["allow_unknown"]
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/eve/validation.py", line 28, in __init__
    super(Validator, self).__init__(*args, **kwargs)
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/cerberus/validator.py", line 169, in __init__
    self.schema = kwargs.get('schema', None)
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/cerberus/validator.py", line 509, in schema
    self._schema = DefinitionSchema(self, schema)
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/cerberus/schema.py", line 69, in __init__
    self.validate(schema)
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/cerberus/schema.py", line 197, in validate
    self._validate(schema)
  File "/home/rmlopes/dev/knowLOGIS/knowlogisAPI/__py_venv__/lib/python3.5/site-packages/cerberus/schema.py", line 219, in _validate
    raise SchemaError(self.schema_validator.errors)
cerberus.schema.SchemaError: {'firstname': [{'description': ['unknown rule']}]}

Environment

  • Python version: 3.5
  • Eve version: 0.9
  • Cerberus:1.2

This is reported at the swagger extension but I believe is a core problem. The examples are simpler at eve-demo hence it is uncaught.

@nicolaiarocci

This comment has been minimized.

Copy link
Member

commented May 2, 2019

Actually, this is due to Cerberus 1.0+ dropping support for transparent_schema_rules. When we did that, we did not upgrade Eve and Eve-Swagger docs accordingly. Right now, in order to add support for description and example eve-swagger options, you have to supply a custom validator, as suggested in eve-swagger README (which needs to be amended to get rid of the now non-existent transparent_schema_rules option)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.