Skip to main content

Add response descriptions to chalice

Project description

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.

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('body', description='Create a new widget', schema='WidgetSchema')
def index():
    return Response(status_code=201)

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)

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.

import leangle
from marshmallow import Schema, fields


@leangle.add_schema('BaseSchema')
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)

Project details


Download files

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

Source Distribution

leangle-0.0.11.tar.gz (3.0 kB view hashes)

Uploaded Source

Built Distribution

leangle-0.0.11-py3-none-any.whl (5.4 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