Giter Site home page Giter Site logo

falguard's Issues

Error thrown in JsonApiErrorResponseFormatter

Hey,

I receive the following exception when the code is executing in JsonApiErrorResponseFormatter._get_source()

self = <falguard._JsonApiErrorResponseFormatter object at 0x7f25d6e204e0>
validation_error = <ValidationError: "'name' is a required property">

    def _get_source(self, validation_error):
        # pylint: disable=no-self-use
>       path = '/'.join(validation_error.path)
E       TypeError: sequence item 0: expected str instance, int found

devenv/lib/python3.6/site-packages/falguard.py:51: TypeError

I had a quick look and should the _get_source function be using validation_error.schema_path instead? See my output from Pdb below for the schema and error details including schema_path and path values:

-> path = '/'.join(validation_error.path)
(Pdb) pp vars(validation_error)
{'cause': None,
 'context': [],
 'instance': {'cost_gbp': 10,
              'depth_mm': 100,
              'height_mm': 100,
              'sku': 'prod-1',
              'weight_g': 100,
              'width_mm': 100},
 'message': "'name' is a required property",
 'parent': None,
 'path': deque([0]),
 'relative_path': deque([0]),
 'relative_schema_path': deque(['items', 'required']),
 'schema': {'properties': {'cost_gbp': {'example': 100, 'type': 'number'},
                           'depth_mm': {'example': 100, 'type': 'number'},
                           'height_mm': {'example': 100, 'type': 'number'},
                           'name': {'example': 'American Crew Fiber 85g',
                                    'type': 'string'},
                           'sku': {'example': 'ABC001', 'type': 'string'},
                           'weight_g': {'example': 10, 'type': 'number'},
                           'width_mm': {'example': 100, 'type': 'number'}},
            'required': ['sku',
                         'name',
                         'weight_g',
                         'height_mm',
                         'width_mm',
                         'depth_mm',
                         'cost_gbp']},
 'schema_path': deque(['items', 'required']),
 'validator': 'required',
 'validator_value': ['sku',
                     'name',
                     'weight_g',
                     'height_mm',
                     'width_mm',
                     'depth_mm',
                     'cost_gbp']}

Is it likely to be a mis-configured schema on my part or is this a bug?

For info here is the output from pip freeze:

alembic==1.0.8
astroid==2.2.5
attrs==19.1.0
autopep8==1.2.4
bravado-core==5.11.0
certifi==2019.3.9
chardet==3.0.4
falcon==1.4.1
falcon-cors==1.1.7
falguard==0.3
flake8==3.0.4
gunicorn==19.7.1
idna==2.8
importmagic==0.1.7
isort==4.3.16
jedi==0.9.0
jsonpointer==2.0
jsonref==0.2
jsonschema==3.0.1
lazy-object-proxy==1.3.1
Mako==1.0.8
MarkupSafe==1.1.1
mccabe==0.6.1
msgpack-python==0.5.6
passlib==1.7.1
pep8==1.7.1
pg8000==1.13.1
psycopg2==2.7.3
py==1.8.0
pycodestyle==2.0.0
pyflakes==1.2.3
pylint==1.7.1
pyrsistent==0.14.11
pytest==3.0.2
python-dateutil==2.8.0
python-editor==1.0.4
python-mimeparse==1.6.0
pytz==2018.9
PyYAML==5.1
requests==2.21.0
rfc3987==1.3.8
simplejson==3.16.0
six==1.12.0
SQLAlchemy==1.3.1
sqlalchemy-filters==0.10.0
SQLAlchemy-Utils==0.33.9
strict-rfc3339==0.7
swagger-spec-validator==2.4.3
testing.common.database==2.0.3
testing.postgresql==1.3.0
typed-ast==1.3.1
urllib3==1.24.1
webcolors==1.8.1
wrapt==1.11.1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.