Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
openapi.yaml Add a slightly more built-out TODO app example Apr 22, 2019

An example RESTful API app showcasing the power of pyramid_openapi3

This folder showcases how to use the pyramid_openapi3 Pyramid add-on for building robust RESTful APIs. With only a few lines of code you get automatic validation of requests and responses against an OpenAPI v3 schema, along with Swagger "try-it-out" documentation for your API.

How to run

$ git clone
$ cd pyramid_openapi3/examples/todoapp
$ virtualenv -p python3.7 .
$ source bin/activate
$ pip install pyramid_openapi3
$ python

Then use the Swagger interface at http://localhost:6543/docs/ to discover the API. Use the Try it out button to run through a few request/response scenarios.

For example:

  • Get all TODO items using the GET request.
  • Adding a new TODO item using the POST request.
  • Getting a 400 BadRequest response for an empty POST request
  • Getting a 400 BadRequest response for a POST request when title is too long (over 40 characters).

All of these examples are covered with tests that you can run with $ python -m unittest

Further read

  • A simpler, single-file example is available in the examples/singlefile folder.

  • A fully built-out app, with 100% test coverage, providing a API is available at niteoweb/pyramid-realworld-example-app. It is a Heroku-deployable Pyramid app that provides an API for a social app. You are encouraged to use it as a scaffold for your next project.

  • More information about the library providing the integration between OpenAPI specs and Pyramid, more advanced features and design defence, is available in the main README file.

  • More validators for fields are listed in the OpenAPI Specification document. You can use Regex as well.

  • For an idea of a fully-fledged production OpenApi specification, check out WooCart's OpenAPI docs.

You can’t perform that action at this time.