Skip to main content

Documentation generator for Swagger API

Project description

Swagger API Docs Generator for Foliant

This preprocessor generates Markdown documentation from JSON generated by Swagger. It uses Jinja2 templating engine or widdershins for generating Markdown from JSON.

Installation

$ pip install foliantcontrib.swaggerdoc

Config

To enable the preprocessor, add pgsqldoc to preprocessors section in the project config:

preprocessors:
    - swaggerdoc

The preprocessor has a number of options:

preprocessors:
    - swaggerdoc:
        json_url: http://localhost/swagger.json
        json_path: swagger.json
        mode: 'jinja'
        template: swagger.j2
        environment: env.yaml

json_url : URL to JSON generated by Swagger. Has priority over loading json by path.

json_path : local path to JSON generated by Swagger (relative to project dir).

If both url and path are specified — preprocessor first tries to fetch JSON from url, and then (if that fails) looks for the file on local path.

mode : Determines how the Swagger JSON would be converted to markdown. Should be one of: jinja, widdershins. Default: jinja

template : Only for jinja mode. Path to jinja-template for rendering the generated documentation. Path is relative to the project directory. If no template is specified preprocessor will use default template (and put it into project dir if it was missing). Default: swagger.j2

environment : Only for widdershins mode. Parameters for widdershins converter. You can either pass a string containing relative path to YAML or JSON file with all parameters (like in example above) or specify all parameters in YAML format under this key. More info on widdershins parameters.

Usage

Add a <<swaggerdoc></swaggerdoc> tag at the position in the document where the generated documentation should be inserted:

# Introduction

This document contains the automatically generated documentation of our API.

<<swaggerdoc></swaggerdoc>

Each time the preprocessor encounters the tag <<swaggerdoc></swaggerdoc> it inserts the whole generated documentation text instead of it. The path or url to swagger.json are taken from foliant.yml.

You can also specify some parameters (or all of them) in the tag options:

# Introduction

Introduction text for API documentation.

<swaggerdoc json_url="http://localhost/swagger.json"
            mode="jinja"
            template="swagger.j2">
</swaggerdoc>

<swaggerdoc json_url="http://localhost/swagger.json"
            mode="widdershins"
            environment="env.yml">
</swaggerdoc>

Tag parameters have the highest priority.

This way you can have documentation from several different JSON files in one foliant project (even in one md-file if you like it so).

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

foliantcontrib.swaggerdoc-1.1.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file foliantcontrib.swaggerdoc-1.1.0.tar.gz.

File metadata

  • Download URL: foliantcontrib.swaggerdoc-1.1.0.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.14.2 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.1

File hashes

Hashes for foliantcontrib.swaggerdoc-1.1.0.tar.gz
Algorithm Hash digest
SHA256 3a9014ae6864bee826c2451ab2411388a9e88664f37eb4c9304c6df767671e32
MD5 c7dbf06f85f538b7824444e19cf97091
BLAKE2b-256 2008e66ed9a837d7606ea38406cfdef424707eb03f7d0f063d0fbb69546abefa

See more details on using hashes here.

File details

Details for the file foliantcontrib.swaggerdoc-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: foliantcontrib.swaggerdoc-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.14.2 setuptools/40.2.0 requests-toolbelt/0.8.0 tqdm/4.25.0 CPython/3.6.1

File hashes

Hashes for foliantcontrib.swaggerdoc-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0de5b34893960c55e68cae299a6f4e03371d4b0e7aeb3f22139ce477937c5abb
MD5 68e4f6771b5aaaf0a2aeba9708576e6d
BLAKE2b-256 ee9d70193a09546b57992abc95d2213f1d4c1a287063b7c8f943fab47290deec

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page