%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 - 0.0.5-1 - Package Spec generated