Skip to main content

some helpers to create swagger output from a pecan app

example usage

given a file named myapp.py

import pecan
from pecan_swagger import decorators as swagger


@swagger.path('profile', 'Profile', 'Root')
class ProfileController(object):

    @pecan.expose(generic=True, template='index.html')
    def index(self):
        return dict()

    @index.when(method='POST')
    def index_post(self, **kw):
        print(kw)
        pecan.redirect('/profile')


@swagger.path('/', 'Root')
class RootController(object):

    profile = ProfileController()

and another file named myapp-doc.py

import pprint

from pecan_swagger import utils
import myapp

pp = pprint.PrettyPrinter(indent=2)
pp.pprint(utils.swagger_build('myapp', '1.0'))

the following will be produced when run

$ python myapp-doc.py
{
  "swagger": "2.0",
  "info": {
    "version": "1.0",
    "title": "myapp"
  },
  "paths": {
    "/profile": {
      "POST": {},
      "GET": {}
    }
  }
}

Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pecan_swagger-0.1.2-py2.py3-none-any.whl (6.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pecan_swagger-0.1.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pecan_swagger-0.1.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 dc838731b06c862a217334f7acf7f185f92c7a4d65ef633115d70832374ca212
MD5 0ec7716faf52f1e9cf654cf87896bf0e
BLAKE2b-256 940694b7dd4a96e98e02a49481209f73b5aac6b3ea6d1c205ad739ce91ec18d6

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.2 This release

1 file

0.1.1

1 file

0.1.0

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