diff options
| author | CoprDistGit <infra@openeuler.org> | 2023-05-05 07:49:22 +0000 |
|---|---|---|
| committer | CoprDistGit <infra@openeuler.org> | 2023-05-05 07:49:22 +0000 |
| commit | 531481723c2428db77ad486954b88e46466f262c (patch) | |
| tree | f5ad075b7afd68c31ebbed9bd10d13d8899c440b | |
| parent | ecb80d0847026c86150277d7ec45403ba9b23047 (diff) | |
automatic import of python-flask-json-schemaopeneuler20.03
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | python-flask-json-schema.spec | 296 | ||||
| -rw-r--r-- | sources | 1 |
3 files changed, 298 insertions, 0 deletions
@@ -0,0 +1 @@ +/Flask-json-schema-0.0.5.tar.gz diff --git a/python-flask-json-schema.spec b/python-flask-json-schema.spec new file mode 100644 index 0000000..995066e --- /dev/null +++ b/python-flask-json-schema.spec @@ -0,0 +1,296 @@ +%global _empty_manifest_terminate_build 0 +Name: python-flask-json-schema +Version: 0.0.5 +Release: 1 +Summary: Flask extension to validate JSON requests +License: MIT +URL: https://github.com/sanjeevan/flask-json-schema +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/5f/bf/93a452f97f9369e0f5288f3566aef0f66f7420cccf509ba5c1ea401d283a/Flask-json-schema-0.0.5.tar.gz +BuildArch: noarch + +Requires: python3-Flask +Requires: python3-jsonschema + +%description +# Flask-json-schema + +This extension makes it easy to validate JSON data that is sent to your Flask app using the jsonschema spec + +## Setup + +Flask-json-schema is available on PyPI and can be installed with + + pip install flask-json-schema + +The extension can either be initialized directly: + +```python +from flask import Flask +from flask_json_schema import JsonSchema + +app = Flask(__name__) +schema = JsonSchema(app) +``` + +Or through the factory method: + +```python +schema = JsonSchema() + +app = Flask(__name__) +schema.init_app(app) +``` + +## Quick example + +```python +from flask_json_schema import JsonSchema, JsonValidationError +from flask import Flask, jsonify, request + +app = Flask(__name__) +schema = JsonSchema(app) + +todo_schema = { + 'required': ['todo'], + 'properties': { + 'todo': { 'type': 'string' }, + 'priority': { 'type': 'integer' }, + } +} + +todos = [] + +@app.errorhandler(JsonValidationError) +def validation_error(e): + return jsonify({ 'error': e.message, 'errors': [validation_error.message for validation_error in e.errors]}) + +@app.route('/todo', methods=['GET', 'POST']) +@schema.validate(todo_schema) +def create_message(): + if request.method == 'POST': + todos.append( request.get_json() ) + return jsonify({ 'success': True, 'message': 'Created todo' }) + + return jsonify(todos) + +app.run('0.0.0.0', 5000, debug=True) +``` + +See `example.py` for the source code + + +## Links + +* [Source Code](https://github.com/sanjeevan/flask-json-schema) +* [Issues](https://github.com/sanjeevan/flask-json-schema/issues) + + + + + +%package -n python3-flask-json-schema +Summary: Flask extension to validate JSON requests +Provides: python-flask-json-schema +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-flask-json-schema +# Flask-json-schema + +This extension makes it easy to validate JSON data that is sent to your Flask app using the jsonschema spec + +## Setup + +Flask-json-schema is available on PyPI and can be installed with + + pip install flask-json-schema + +The extension can either be initialized directly: + +```python +from flask import Flask +from flask_json_schema import JsonSchema + +app = Flask(__name__) +schema = JsonSchema(app) +``` + +Or through the factory method: + +```python +schema = JsonSchema() + +app = Flask(__name__) +schema.init_app(app) +``` + +## Quick example + +```python +from flask_json_schema import JsonSchema, JsonValidationError +from flask import Flask, jsonify, request + +app = Flask(__name__) +schema = JsonSchema(app) + +todo_schema = { + 'required': ['todo'], + 'properties': { + 'todo': { 'type': 'string' }, + 'priority': { 'type': 'integer' }, + } +} + +todos = [] + +@app.errorhandler(JsonValidationError) +def validation_error(e): + return jsonify({ 'error': e.message, 'errors': [validation_error.message for validation_error in e.errors]}) + +@app.route('/todo', methods=['GET', 'POST']) +@schema.validate(todo_schema) +def create_message(): + if request.method == 'POST': + todos.append( request.get_json() ) + return jsonify({ 'success': True, 'message': 'Created todo' }) + + return jsonify(todos) + +app.run('0.0.0.0', 5000, debug=True) +``` + +See `example.py` for the source code + + +## Links + +* [Source Code](https://github.com/sanjeevan/flask-json-schema) +* [Issues](https://github.com/sanjeevan/flask-json-schema/issues) + + + + + +%package help +Summary: Development documents and examples for flask-json-schema +Provides: python3-flask-json-schema-doc +%description help +# Flask-json-schema + +This extension makes it easy to validate JSON data that is sent to your Flask app using the jsonschema spec + +## Setup + +Flask-json-schema is available on PyPI and can be installed with + + pip install flask-json-schema + +The extension can either be initialized directly: + +```python +from flask import Flask +from flask_json_schema import JsonSchema + +app = Flask(__name__) +schema = JsonSchema(app) +``` + +Or through the factory method: + +```python +schema = JsonSchema() + +app = Flask(__name__) +schema.init_app(app) +``` + +## Quick example + +```python +from flask_json_schema import JsonSchema, JsonValidationError +from flask import Flask, jsonify, request + +app = Flask(__name__) +schema = JsonSchema(app) + +todo_schema = { + 'required': ['todo'], + 'properties': { + 'todo': { 'type': 'string' }, + 'priority': { 'type': 'integer' }, + } +} + +todos = [] + +@app.errorhandler(JsonValidationError) +def validation_error(e): + return jsonify({ 'error': e.message, 'errors': [validation_error.message for validation_error in e.errors]}) + +@app.route('/todo', methods=['GET', 'POST']) +@schema.validate(todo_schema) +def create_message(): + if request.method == 'POST': + todos.append( request.get_json() ) + return jsonify({ 'success': True, 'message': 'Created todo' }) + + return jsonify(todos) + +app.run('0.0.0.0', 5000, debug=True) +``` + +See `example.py` for the source code + + +## Links + +* [Source Code](https://github.com/sanjeevan/flask-json-schema) +* [Issues](https://github.com/sanjeevan/flask-json-schema/issues) + + + + + +%prep +%autosetup -n flask-json-schema-0.0.5 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-flask-json-schema -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 0.0.5-1 +- Package Spec generated @@ -0,0 +1 @@ +81ee4499aeefa1d15488460e5fdd1ebe Flask-json-schema-0.0.5.tar.gz |
