Quickstart

Created:
March 7, 2023
Updated:
May 31, 2023

Prerequisites

Python 3.6+

Installation

In your command line, type:


$ pip install firetail[swagger-ui] 

Running it

Put your API YAML inside a folder in the root path of your application (for example, openapi/) then do:


import firetail

app = firetail.FlaskApp(__name__, specification_dir='openapi/')
app.add_api('my_api.yaml')
app.run(port=8080)

Dynamic rendering of your specification

FireTail uses Jinja2 to allow specification parameterization through an arguments parameter. You can either define specification arguments globally for the application in the firetail.App constructor, or for each specific API in the firetail.App#add_api method:


app = firetail.FlaskApp(__name__, specification_dir='openapi/',
                    arguments={'global': 'global_value'})
app.add_api('my_api.yaml', arguments={'api_local': 'local_value'})
app.run(port=8080)

When a value is provided both globally and on the API, the API value will take precedence.

Swagger UI console

The Swagger UI for an API is available by default, in {base_path}/ui/ where base_path is the base path of the API.

You can disable the Swagger UI at the application level:


options = {"swagger_ui": False}
app = firetail.FlaskApp(__name__, specification_dir='openapi/',
                    options=options)
app.add_api('my_api.yaml')

You can also disable it at the API level:


options = {"swagger_ui": False}
app = firetail.FlaskApp(__name__, specification_dir='openapi/')
app.add_api('my_api.yaml', options=options)

You can pass custom Swagger UI Configuration Parameters such as displayOperationId through the swagger_ui_config option:


options = {"swagger_ui_config": {"displayOperationId": True}}
app = firetail.FlaskApp(__name__, specification_dir='openapi/',
                    options=options)

Server backend

By default, FireTail uses the default flask server but you can also use Tornado or gevent as the HTTP server, to do so set the server to tornado or gevent:


import firetail

app = firetail.FlaskApp(__name__, port = 8080, specification_dir='openapi/', server='tornado')

Related topics