summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCoprDistGit <infra@openeuler.org>2023-05-15 03:52:42 +0000
committerCoprDistGit <infra@openeuler.org>2023-05-15 03:52:42 +0000
commit65de14b038adb1f43bffef09276ae7658e443d8c (patch)
tree2a5ef3ec7f24d7157a44be8ce3e47c6035b203ad
parent7e777d798bdc6eeee8f2b011aff1f6089f8e575f (diff)
automatic import of python-schema-validator
-rw-r--r--.gitignore1
-rw-r--r--python-schema-validator.spec296
-rw-r--r--sources1
3 files changed, 298 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..bdb3b73 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/schema_validator-0.2.5.tar.gz
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`
+<details>
+<summary>How to use</summary>
+```
+ 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 {}
+```
+</details>
+<details>
+<summary>How to show the swagger </summary>
+```
+app.config["SWAGGER_ROUTE"] = True
+http://yourhost/swagger/docs -> show the all swagger
+http://yourhost/swagger/docs/{tag} -> show the swagger which include tag
+```
+</details>
+<details>
+<summary>How to export the swagger </summary>
+```
+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
+```
+</details>
+
+%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`
+<details>
+<summary>How to use</summary>
+```
+ 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 {}
+```
+</details>
+<details>
+<summary>How to show the swagger </summary>
+```
+app.config["SWAGGER_ROUTE"] = True
+http://yourhost/swagger/docs -> show the all swagger
+http://yourhost/swagger/docs/{tag} -> show the swagger which include tag
+```
+</details>
+<details>
+<summary>How to export the swagger </summary>
+```
+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
+```
+</details>
+
+%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`
+<details>
+<summary>How to use</summary>
+```
+ 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 {}
+```
+</details>
+<details>
+<summary>How to show the swagger </summary>
+```
+app.config["SWAGGER_ROUTE"] = True
+http://yourhost/swagger/docs -> show the all swagger
+http://yourhost/swagger/docs/{tag} -> show the swagger which include tag
+```
+</details>
+<details>
+<summary>How to export the swagger </summary>
+```
+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
+```
+</details>
+
+%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 <Python_Bot@openeuler.org> - 0.2.5-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..a36814e
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+5d28fa5edb1f8b122504f02e90c424c8 schema_validator-0.2.5.tar.gz