Skip to main content

generate OpenAPI document and validate request&response with Python annotations.

Project description

Spectree

GitHub Actions pypi downloads versions Language grade: Python

Yet another library to generate OpenAPI document and validate request & response with Python annotations.

Features

  • Less boilerplate code, annotations are really easy-to-use :sparkles:
  • Generate API document with Redoc UI or Swagger UI :yum:
  • Validate query, JSON data, response data with pydantic :wink:
  • Current support:
    • Flask
    • Falcon
    • Starlette

Quick Start

install with pip: pip install spectree

Demo

Step by Step

  1. Define your data structure with pydantic.BaseModel
  2. create spectree.SpecTree instance with the web framework name you are using api = SpecTree('flask')
  3. validate the route
    • query
    • json
    • headers
    • cookies
    • resp
    • tags
  4. access these data with context(query, json, headers, cookies)
    • flask: request.context
    • falcon: req.context
    • starlette: request.context
  5. register to the web application api.register(app)
  6. check the document at URL location /apidoc/redoc or /apidoc/swagger

Examples

Check the examples folder.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spectree-0.1.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

spectree-0.1.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file spectree-0.1.0.tar.gz.

File metadata

  • Download URL: spectree-0.1.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4

File hashes

Hashes for spectree-0.1.0.tar.gz
Algorithm Hash digest
SHA256 22ff5b0931e64f688f27da4e2cbec9091cf84fda076a61bd7015705d501b8c93
MD5 c18879fb0cb94b89e73bdf076c6a1996
BLAKE2b-256 7cc575da0a1201405e0ab761a3fcac5289db7134fe63920635ccc34424f94dfa

See more details on using hashes here.

File details

Details for the file spectree-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: spectree-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4

File hashes

Hashes for spectree-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e05dabebd3b18ec490c759882900c834ea468d5a0d9bb2ba5998ab229e36748
MD5 ec4cde9570676f4d450a13d1a01666b7
BLAKE2b-256 baf472e88c43eff9179c3b593cba58b1dc8d18301746a2e6f3a4ad53a7df6c24

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page