Quickstart¶
Prerequisites¶
Python 2.7 or Python 3.4+
Running It¶
Put your API YAML inside a folder in the root path of your application (e.g swagger\
) and then do
import connexion
app = connexion.App(__name__, specification_dir='swagger/')
app.add_api('my_api.yaml')
app.run(port=8080)
Dynamic Rendering of Your Specification¶
Connexion uses Jinja2 to allow specification parameterization through arguments parameter. You can either define specification arguments globally for the application in the connexion.App constructor, or for each specific API in the connexion.App#add_api method:
app = connexion.App(__name__, specification_dir='swagger/',
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.
The 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:
app = connexion.App(__name__, specification_dir='swagger/',
swagger_ui=False)
app.add_api('my_api.yaml')
You can also disable it at the API level:
app = connexion.App(__name__, specification_dir='swagger/')
app.add_api('my_api.yaml', swagger_ui=False)