Skip to main content

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
        additional_json_path: tags.json
        mode: 'jinja'
        template: swagger.j2
        environment: env.yaml

json_url : URL to JSON generated by Swagger. Has priority over loading json by path. If it is a list — preprocessor takes the first url which works.

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.

additional_json_path : Only for jinja mode. Local path to JSON with additional info (relative to project dir). It will be merged into swagger.json, not overriding existing fields.

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).

Release files for foliantcontrib.swaggerdoc 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for foliantcontrib.swaggerdoc 1.1.1
File Size Uploaded
foliantcontrib.swaggerdoc-1.1.1.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for foliantcontrib.swaggerdoc 1.1.1
File Interpreter ABI Platform
foliantcontrib.swaggerdoc-1.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 14.4 kB

Release files / foliantcontrib.swaggerdoc-1.1.1.tar.gz

Download URL foliantcontrib.swaggerdoc-1.1.1.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
eceb0112ca19fdbf5b6f9ff245f2ca36c9d7fea327ec86777b7b8a8e652b5cc5
BLAKE2b-256 checksum
How to use checksums
ed2395e0905a5e6a2831df11a20549e7cdded06b157b8fdab2f0e35c86697b73
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / foliantcontrib.swaggerdoc-1.1.1-py3-none-any.whl

Download URL foliantcontrib.swaggerdoc-1.1.1-py3-none-any.whl
Size 7.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f8cdc15252bd73dd7b5a245476e57762d1817815ba802af0ee8b0f75eab6a82b
BLAKE2b-256 checksum
How to use checksums
c73661b75862ba4a8dd74ce5a7e1bf9e5dac0fb4d802d17d1c93a79d48b731ef
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.3

2 release files

1.1.2

2 release files

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.0

2 release files

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