Skip to content

Custom Documentation

Thomas Pollet edited this page Jan 11, 2020 · 13 revisions

Overview

The swagger documentation is described in the swagger.json file. This documentation is generated from the docstrings in the code and can be customized in several ways. Several examples are implemented in the custom_swagger.py example

Import Swagger

You can modify the swagger.json by specifying the custom_swagger argument to the API constructor, for example

custom_swagger = {
    "info": {"title": "New Title", 
             "description" : "new description"},
    "securityDefinitions": {"ApiKeyAuth": {"type": "apiKey", "in": "header", "name": "My-ApiKey"}}
}

api = SAFRSAPI(... , custom_swagger=custom_swagger)

This will update the generated swagger with your customizations

Docstrings

The SAFRSBase instances can contain python docstrings that will be used to generate the swagger.json. For example

class User(SAFRSBase, db.Model):
    """
        description: User description
    """