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 for customizing the layout.

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:
        swagger_json_urls: http://localhost/swagger.json
        swagger_json_paths: swagger.json
        template: swagger.j2

swagger_json_urls : URL to JSON generated by Swagger or several such urls (in this case use yaml list format).

swagger_json_paths : path to JSON generated by Swagger relative to project dir or several such paths (in this case use yaml list format).

Important notice about those json files. Preprocessor would start parsing JSONS from the first url, subsequently merging data from following JSONS in the same order they are declared in config. First URLs, then paths.

template : Path to jinja-template for rendering the generated documentation. Path is relative to the project directory. Default: swagger.j2

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 paths or urls to swagger.json are taken from the config-file.

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

# Introduction

Introduction text for API documentation.

<swaggerdoc swagger_json_urls="http://localhost/swagger.json"
            template="swagger.j2">
</swaggerdoc>

Tag parameters have the highest priority.

Use comma to have several urls\paths in tag options.

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.0.0.tar.gz (6.0 kB view hashes)

Uploaded Source

Built Distribution

foliantcontrib.swaggerdoc-1.0.0-py3-none-any.whl (6.7 kB view hashes)

Uploaded Python 3

Supported by

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