Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

A data validation and REST auto-documenter for APIs.

Project description

Restifier is a python library for creating and documenting RESTful APIs.
It includes a middleware component, a set of decorators, and a “forms” library for validating/documenting requests. The middle generates a Swagger compatible JSON specification for the APIs automatically.

Author

Jesse Lovelace jesse@hawatian.com

License

The MIT License

Usage

See tests.py for information on usage. In general, so create a payload validator construct a class like this:

class HelloMessage(Message):
    greeting = StringProperty(description="The greating.",
        validators=[regex(re.compile('^[A-Za-z]+$')), required()])

class HelloResponseMessage(Message):
    salutation = StringProperty(description="The response.")
    tags = StringProperty(repeated=True)
    request = StructuredProperty(HelloMessage)

Then decorate your handlers like this:

class HelloHandler(RequestHandler):

    @api(input=HelloMessage, output=HelloResponseMessage)
    def post(self, obj):
        return {'salutation':'You are the best.'}

Also, to auto-document, use the middleware:

routes = [
    ('/api/v1/hello', HelloHandler)
]

app = DocumentedMiddleware(
    WSGIApplication(routes),
    api_base="/api/v1",
    api_overview="This is a super important API that does a lot of stuff."
)

Project details


Release history Release notifications

This version
History Node

1.0.4

History Node

1.0.3

History Node

1.0.2

History Node

1.0.1

History Node

1.0.0

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
restifier-1.0.4.tar.gz (15.0 kB) Copy SHA256 hash SHA256 Source None Feb 3, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page