gwaramadze / falguard Goto Github PK
View Code? Open in Web Editor NEWFalcon requests validation against OpenAPI (Swagger) schema
License: Other
Falcon requests validation against OpenAPI (Swagger) schema
License: Other
Thank you for Falguard, it is very useful.
I have a question: Say I have a resource published on /hello
that only implement on_get
.
If I try to access it with a POST request, Falguard returns a 404 error, whereas it should be a 405, shouldn't it ?
Drogi Remy,
I would like to add .yaml support to falguard, may I?
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
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.