flaskdocs is a lightweight wrapper around a flask app which aims to centralize both validation and documentation of an API. Declare the schemas you're accept/return, and flaskdocs will let you generate an openapi.json file, as well as validating incoming requests and returning errors to the client if a request doesn't match the given schema.
Example usage:
Declare a flask app and pass it to a flaskdocs API as follows:
from flask import Flask, jsonify
from flaskdocs import API
from flaskdocs.schema import (
JsonSchema,
QueryParameterSchema,
Literal,
Use,
)
app = Flask(__name__)
api = API(
title="example",
version="0.0.1",
description="Here's an example API",
app=app,
)
@api.route(
name="Add Numbers",
path="/add",
methods=["GET"],
description="Add two numbers together and return the sum",
query_parameter_schema=QueryParameterSchema({
# use "Use" here to tell the parser try calling float, rather
# than doing a type check, because queryParameters always come
# in as strings
Literal("x", description="The first number to add"): Use(float),
Literal("y", description="The second number to add"): Use(float),
}),
response_schema={200: JsonSchema({
Literal("sum", description="The sum x + y"): float
})},
)
def add(x: float, y: float):
return jsonify({"sum": x + y})
api.output_openapi("example/openapi-spec.json")
To run a more complete example (found in the example folder) run FLASK_APP=example/server.py python -m flask run from this directory.
Metadata
Release files for flaskdocs 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flaskdocs-0.0.1.tar.gz | 5.3 kB | Without provenance | Details for flaskdocs-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flaskdocs-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for flaskdocs-0.0.1-py3-none-any.whl |
Total release size: 11.3 kB
Release files / flaskdocs-0.0.1.tar.gz
| Download URL | flaskdocs-0.0.1.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c23da7f1f7371dcc403461d00be52b520a2b6932a7ac55fee3d6bde8c86dbf97
|
|
BLAKE2b-256 checksum How to use checksums |
8044afb08bcb9df3e39032031fac8cd32f01ab6a0e3e74c9ffb9e3c27f52e0e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.5
|
Release files / flaskdocs-0.0.1-py3-none-any.whl
| Download URL | flaskdocs-0.0.1-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7b0c04580060df32f05645a265750ae4dea664f9e1f42210062010ccece6ab25
|
|
BLAKE2b-256 checksum How to use checksums |
91e81c44043c810f61bf84358a8367edbc81ac8f905cd7aaa143a672d35dd01b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.5
|
Security for flaskdocs 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.