From 65de14b038adb1f43bffef09276ae7658e443d8c Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Mon, 15 May 2023 03:52:42 +0000 Subject: automatic import of python-schema-validator --- python-schema-validator.spec | 296 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 296 insertions(+) create mode 100644 python-schema-validator.spec (limited to 'python-schema-validator.spec') diff --git a/python-schema-validator.spec b/python-schema-validator.spec new file mode 100644 index 0000000..b341bfa --- /dev/null +++ b/python-schema-validator.spec @@ -0,0 +1,296 @@ +%global _empty_manifest_terminate_build 0 +Name: python-schema-validator +Version: 0.2.5 +Release: 1 +Summary: A flask/quart extension to provide schema validation with pydantic. +License: MIT +URL: https://github.com/huangxiaohen2738/schema-validator +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/57/ab/fdaca277af898bb228e9e228a639bc8df2649814b67a0bdff9f223bd1bf0/schema_validator-0.2.5.tar.gz +BuildArch: noarch + +Requires: python3-pyhumps +Requires: python3-pydantic + +%description +#### Generate from quart-schema +### Install + - `pip install schema-validator` +
+How to use +``` + from dataclasses import dataclass + from datetime import datetime + from typing import Optional + from pydantic import BaseModel + from flask import Flask + from quart import Quart + from schema_validator import SchemaValidator + from schema_validator.flask import validate + # from schema_validator.quart import validate + app = Flask(__name__) + # or + app = Quart(__name__) + OR + schema = SchemaValidator(app) + schema.init_app(app) + @dataclass + class Todo: + task: str + due: Optional[datetime] + class TodoResponse(BaseModel): + id: int + name: str + @app.post("/") + @validate(body=Todo, responses=TodoResponse) + def create_todo(): + # balabala + return dict(id=1, name="2") + @app.get("/") + @validate( + query=Todo, + responses={200: TodoResponse, 400: TodoResponse} + ) + def update_todo(): + # balabala + return TodoResponse(id=1, name="123") + @app.delete("/") + @validate( + body=Todo, + responses={200: TodoResponse} + ) + def delete(): + # balabala + return jsonify(id=1) + @tags("SOME-TAG", "OTHER-TAG") # only for swagger + class View(MethodView): + @validate(...) + def get(self): + return {} +``` +
+
+How to show the swagger +``` +app.config["SWAGGER_ROUTE"] = True +http://yourhost/swagger/docs -> show the all swagger +http://yourhost/swagger/docs/{tag} -> show the swagger which include tag +``` +
+
+How to export the swagger +``` +add command in flask/quart: + app.cli.add_command(generate_schema_command) +Export all swagger to json file: + - flask/quart schema -o swagger.json +Export the swagger which include the ACCOUNT tag: + - flask/quart schema -o swagger.json -t ACCOUNT +``` +
+ +%package -n python3-schema-validator +Summary: A flask/quart extension to provide schema validation with pydantic. +Provides: python-schema-validator +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-schema-validator +#### Generate from quart-schema +### Install + - `pip install schema-validator` +
+How to use +``` + from dataclasses import dataclass + from datetime import datetime + from typing import Optional + from pydantic import BaseModel + from flask import Flask + from quart import Quart + from schema_validator import SchemaValidator + from schema_validator.flask import validate + # from schema_validator.quart import validate + app = Flask(__name__) + # or + app = Quart(__name__) + OR + schema = SchemaValidator(app) + schema.init_app(app) + @dataclass + class Todo: + task: str + due: Optional[datetime] + class TodoResponse(BaseModel): + id: int + name: str + @app.post("/") + @validate(body=Todo, responses=TodoResponse) + def create_todo(): + # balabala + return dict(id=1, name="2") + @app.get("/") + @validate( + query=Todo, + responses={200: TodoResponse, 400: TodoResponse} + ) + def update_todo(): + # balabala + return TodoResponse(id=1, name="123") + @app.delete("/") + @validate( + body=Todo, + responses={200: TodoResponse} + ) + def delete(): + # balabala + return jsonify(id=1) + @tags("SOME-TAG", "OTHER-TAG") # only for swagger + class View(MethodView): + @validate(...) + def get(self): + return {} +``` +
+
+How to show the swagger +``` +app.config["SWAGGER_ROUTE"] = True +http://yourhost/swagger/docs -> show the all swagger +http://yourhost/swagger/docs/{tag} -> show the swagger which include tag +``` +
+
+How to export the swagger +``` +add command in flask/quart: + app.cli.add_command(generate_schema_command) +Export all swagger to json file: + - flask/quart schema -o swagger.json +Export the swagger which include the ACCOUNT tag: + - flask/quart schema -o swagger.json -t ACCOUNT +``` +
+ +%package help +Summary: Development documents and examples for schema-validator +Provides: python3-schema-validator-doc +%description help +#### Generate from quart-schema +### Install + - `pip install schema-validator` +
+How to use +``` + from dataclasses import dataclass + from datetime import datetime + from typing import Optional + from pydantic import BaseModel + from flask import Flask + from quart import Quart + from schema_validator import SchemaValidator + from schema_validator.flask import validate + # from schema_validator.quart import validate + app = Flask(__name__) + # or + app = Quart(__name__) + OR + schema = SchemaValidator(app) + schema.init_app(app) + @dataclass + class Todo: + task: str + due: Optional[datetime] + class TodoResponse(BaseModel): + id: int + name: str + @app.post("/") + @validate(body=Todo, responses=TodoResponse) + def create_todo(): + # balabala + return dict(id=1, name="2") + @app.get("/") + @validate( + query=Todo, + responses={200: TodoResponse, 400: TodoResponse} + ) + def update_todo(): + # balabala + return TodoResponse(id=1, name="123") + @app.delete("/") + @validate( + body=Todo, + responses={200: TodoResponse} + ) + def delete(): + # balabala + return jsonify(id=1) + @tags("SOME-TAG", "OTHER-TAG") # only for swagger + class View(MethodView): + @validate(...) + def get(self): + return {} +``` +
+
+How to show the swagger +``` +app.config["SWAGGER_ROUTE"] = True +http://yourhost/swagger/docs -> show the all swagger +http://yourhost/swagger/docs/{tag} -> show the swagger which include tag +``` +
+
+How to export the swagger +``` +add command in flask/quart: + app.cli.add_command(generate_schema_command) +Export all swagger to json file: + - flask/quart schema -o swagger.json +Export the swagger which include the ACCOUNT tag: + - flask/quart schema -o swagger.json -t ACCOUNT +``` +
+ +%prep +%autosetup -n schema-validator-0.2.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-schema-validator -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Mon May 15 2023 Python_Bot - 0.2.5-1 +- Package Spec generated -- cgit v1.2.3