Skip to main content

leangle

PyPI PyPI - Python Version GitHub https://travis-ci.org/jsfehler/leangle.svg?branch=master https://coveralls.io/repos/github/jsfehler/leangle/badge.svg?branch=master

An add-on for chalice to improve documentation of an API Gateway.

As of version 1.13.0, chalice does not support models for the request or response. This means any documentation generated for an API Gateway is going to be much less useful.

leangle improves this with a collection of decorators for chalice route functions, and built-in support for marshmallow schemas.

Installation

Via pip:

pip install leangle

Chalice itself is an optional dependency. This can be useful for testing and validation, but should not be used for the version of chalice deployed to AWS.

pip install leangle[chalice]

Describe API Parameters

API Responses can be described with the describe.parameter decorator. They will be added as documentation to the API Gateway. They should go after the route decorator, and can be stacked.

import leangle


@app.route('/', methods=['POST'])
@leangle.describe.parameter(name='body', _in='body', description='Create a new widget', schema='WidgetSchema')
def index():
    return Response(status_code=201)

Describing the ‘in’ field of a parameter

_in is used, as in is a reserved word in Python.

Describe API Responses

API Responses can be described with the describe.response decorator. They will be added as documentation to the API Gateway. They should go after the route decorator, and can be stacked.

import leangle


@app.route('/', methods=['POST'])
@leangle.describe.response(201, description='Created')
@leangle.describe.response(422, description='Missing Parameter')
def index():
    return Response(status_code=201)

Describe Method Tags

import leangle


@app.route('/', methods=['POST'])
@leangle.describe.tags(["x-large"])
def index():
    return Response(status_code=201)

Add schemas

Schema objects can be defined using marshmallow

When decorated with the add_schema decorator, they will be added as models to the API Gateway.

The name of these Schema classes can be used in the describe decorators.

import leangle
from marshmallow import Schema, fields


@leangle.add_schema()
class BaseSchema(Schema):
    name = fields.Str()


@app.route('/', methods=['POST'])
@leangle.describe.response(201, description='Created', schema='BaseSchema')
def index():
    return Response(status_code=201)

Metadata

Release files for leangle 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for leangle 0.2.2
File Size Uploaded
leangle-0.2.2.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for leangle 0.2.2
File Interpreter ABI Platform
leangle-0.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.2 kB

Release files / leangle-0.2.2.tar.gz

Download URL leangle-0.2.2.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
daad9b3c44aea464353f5bc96465dab58ea42bbe6e813cf3ba5aff457a0cf806
BLAKE2b-256 checksum
How to use checksums
3519bf5bbf619b1eae5d5001c67bf5253e7aca4141957667e4b752a8ff0ab8a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.1

Release files / leangle-0.2.2-py3-none-any.whl

Download URL leangle-0.2.2-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e0de883943937389051a3c905a729bd3c4b0f7350b4fd06a0901301ada704dcc
BLAKE2b-256 checksum
How to use checksums
6d67b604176a9b408b294d2a0ae784b92b52d7ee7f266ee0a68d272d21340f1e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.1

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page