{ "info": { "author": "Tomas Sandven", "author_email": "tomas191191@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "\n# bottle-jsonschema\n\nBottle plugin for automatically validating JSON schemas for all relevant\nrequests.\n\n## Installation\n\n pip install bottle_jsonschema\n\n## Usage example\n\n```python\nimport bottle\nfrom bottle.ext.jsonschema import JSONSchemaPlugin, SchemaValidationError\n\nbottle.install(JSONSchemaPlugin())\n\n@bottle.error(400)\ndef handle_error_400(error):\n # This forwards the error directly to the user, which will display a nicely\n # formatted JSON object containing the validation errors.\n if isinstance(error, SchemaValidationError):\n return response\n\n # Handle other error situations...\n\n return json.dumps({\"error\": \"invalid request\"})\n```\n\nThe error object contains a list of strings describing the validation errors.\nYou can easily customize how the errors are displayed, here's how you can\ndisplay them as a HTML list:\n\n```python\n@bottle.error(400)\ndef handle_error_400(error):\n if isinstance(error, SchemaValidationError):\n response.content_type = \"text/html\"\n\n error_list = \"\\n\".join(\n \"
Errors:
\n