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 hashes)

Uploaded Source

Built Distribution

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

Uploaded Python 3

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