{"id":29805571,"url":"https://github.com/rachekalmir/flask-jsonschema-ext","last_synced_at":"2026-04-16T14:04:17.671Z","repository":{"id":57430412,"uuid":"81048615","full_name":"rachekalmir/flask-jsonschema-ext","owner":"rachekalmir","description":"Flask JSONSchema Extended Library","archived":false,"fork":false,"pushed_at":"2017-06-24T19:02:18.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-27T07:03:49.128Z","etag":null,"topics":["flask","flask-jsonschema","json-schema"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rachekalmir.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-02-06T04:44:46.000Z","updated_at":"2017-02-21T16:15:11.000Z","dependencies_parsed_at":"2022-08-26T05:01:53.798Z","dependency_job_id":null,"html_url":"https://github.com/rachekalmir/flask-jsonschema-ext","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rachekalmir/flask-jsonschema-ext","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rachekalmir%2Fflask-jsonschema-ext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rachekalmir%2Fflask-jsonschema-ext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rachekalmir%2Fflask-jsonschema-ext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rachekalmir%2Fflask-jsonschema-ext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rachekalmir","download_url":"https://codeload.github.com/rachekalmir/flask-jsonschema-ext/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rachekalmir%2Fflask-jsonschema-ext/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264221619,"owners_count":23575057,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["flask","flask-jsonschema","json-schema"],"created_at":"2025-07-28T14:01:31.596Z","updated_at":"2026-04-16T14:04:17.624Z","avatar_url":"https://github.com/rachekalmir.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Flask-JSONSchema-Ext\nFlask JSONSchema Extended Library\n\n[![Build Status](https://travis-ci.org/rachekalmir/flask-jsonschema-ext.svg?branch=master)](https://travis-ci.org/rachekalmir/flask-jsonschema-ext) [![Coverage Status](https://coveralls.io/repos/github/rachekalmir/flask-jsonschema-ext/badge.svg?branch=master)](https://coveralls.io/github/rachekalmir/flask-jsonschema-ext?branch=master) [![PyPI version](https://badge.fury.io/py/Flask-JSONSchema-Ext.svg)](https://badge.fury.io/py/Flask-JSONSchema-Ext)\n\nThis library can be used to apply a JSONSchema (http://json-schema.org/) to a Flask API end-point that is generated on the fly from your database entities.\n\nCurrently supported drivers are:\n\n* SQLAlchemy\n\n## Installation\n\nUse pip or easy_install:\n\n`pip install flask-jsonschema-ext`\n\nFlask-JSONSchema-Ext follows [semantic versioning](http://semver.org/).\n\n## Testing\n\nThe tests are in the tests/ and examples/ folders.\nTo run the tests use the `py.test` testing tool:\n\n`pytest`\n\n## Basic Usage\n\nFirst create some SQLAlchemy models:\n\n```python\n# models.py\n\nfrom sqlalchemy import Column, Integer, String\nfrom sqlalchemy.ext.declarative import declarative_base\n\nBase = declarative_base()\n\nclass Post(Base):\n    __tablename__ = 'post'\n    post_id = Column(Integer, primary_key=True)\n    post_value = Column(String)\n    author_name = Column(String)\n```\n\nNext create a basic Flask app and annotate the flask endpoint with the `@jsonschema_generate` decorator:\n\n```python\n# app.py\n\nfrom flask import Flask\n\nfrom flask_jsonschema_ext import FlaskJsonSchemaExt, jsonschema_generate\nfrom flask_jsonschema_ext.drivers import SqlAlchemyDriver\n\nfrom .models import Post\n\napp = Flask(__name__)\njsonschema = FlaskJsonSchemaExt(app, SqlAlchemyDriver)\n\n@app.route('/post', methods=['POST', 'PUT'])\n@jsonschema_generate(Post)\ndef post_root():\n    return \"\"\n\nif __name__ == '__main__':\n    app.run()\n```\n\nNow, all posts and puts to `/post` will only accept json that matches the schema defined by the `Post` class. \n\n## Including and Excluding fields (and relationships)\n\nIncluding and excluding fields can be done at a global level by specifying `__jsonschema_include__` or `__jsonschema_exclude__` on the SQLAlchemy class:\n\n```python\nclass Post(Base):\n    __tablename__ = 'post'\n    __jsonschema_exclude__ = ['author_name']\n    post_id = Column(Integer, primary_key=True)\n    post_value = Column(String)\n    author_name = Column(String)\n```\n\nThis exclude definition will remove `author_name` from the resulting schema and thus any incoming requests containing it will be rejected by the flask endpoint.\n\nInclude can be specified in a similar fashion; just remember that include will run before exclude as it is more explicit and it is therefore incorrect to specify both of them on the same class.  I.e. specifying include will already have limited the class to only those included fields thereby making any exclude definition meaningless.\n\n## Customising the schema per endpoint\n\nYou can also customise the schema at a local level by specifying a custom parse tree on an endpoint:\n\n```python\n@app.route('/post', methods=['POST', 'PUT'])\n@jsonschema_generate(Post, parse_tree={__jsonschema_include__: ['post_value', 'author_name']})\ndef post_root():\n    return \"\"\n```\n\nThis will override the definition as specified on the class itself as the schema generator will now first check the specified definition and then check the class definition. \n\n## Development\n\nWe would love to hear what you think about flask-jsonschema-ext on our [issues](https://github.com/rachekalmir/flask-jsonschema-ext/issues) page.\n\n## Changelog\n\n#### Version 0.2.0\n\nReleased on \n\n- Added Local File Driver\n\n#### Version 0.1.2\n\nReleased on 2017-04-12\n\n- Migrated jsonschema decorator to support non-generated schemas\n- Added colanderalchemy example\n\n#### Version 0.1.1\n\nReleased on 2017-03-04\n\n- Created CHANGELOG\n- Added caching options to decorator\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frachekalmir%2Fflask-jsonschema-ext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frachekalmir%2Fflask-jsonschema-ext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frachekalmir%2Fflask-jsonschema-ext/lists"}