From fcee749d477a529f6d0330c02bb6ed91166cf060 Mon Sep 17 00:00:00 2001 From: huangsong Date: Wed, 29 Sep 2021 14:21:16 +0800 Subject: [PATCH] add example --- example/example_1.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 example/example_1.py diff --git a/example/example_1.py b/example/example_1.py new file mode 100644 index 0000000..09a9f39 --- /dev/null +++ b/example/example_1.py @@ -0,0 +1,31 @@ +from flask import Flask, g +from schema_validator import validate +from dataclasses import dataclass + + +app = Flask() + + +@dataclass +class Req: + name: str + age: int + + +@dataclass +class Response: + name: str + + +@app.post("/test") +@validate(query=Req, body=Req, responses=Response, tags=["test"]) +def new_model(): + """ tags only for swagger """ + body = g.body_params + query_params = g.query_params + print(body, query_params) + return Response(name=123) + + +if __name__ == "__main__": + app.run()