OpenAPI Support

The flask_ligand.views.openapi module contains built-in endpoints for generating OpenAPI clients for TypeScript and Python.

For OpenAPI client generation to work properly your flask-ligand based microservice must have the OPENAPI_GEN_SERVER_URL setting configured to a valid OpenAPI Generator Server URL. The public OpenAPI generator server URL located at http://api.openapi-generator.tech is also available, but since it is not a secure endpoint, it is recommended for use only in testing.

Online Generation

Any microservice built with flask-ligand will have the following built-in endpoints for generating OpenAPI clients:

  • /openapi/typescript-axios/: Generate a TypeScript client download link.

  • /openapi/python/: Generate a Python client download link.

For more details about the endpoint, use the included SwaggerUI documentation with your flask-ligand based microservice running locally by opening a browser and navigating to http://localhost:5000/apidocs.

Online Example

Generate a Python client download link with your flask-ligand based microservice running locally:

curl -X 'GET' \
  'http://localhost:5000/openapi/python/' \
  -H 'accept: application/json'

Offline Generation

The genclient and openapi Flask sub-commands are provided for offline generation of OpenAPI clients for your flask-ligand based microservice CI/CD pipelines. Use flask genclient --help or flask openapi --help to get more details about the functionality that the sub-commands provide.

Important

In order to fully utilize offline generation the FLASK_ENV environment variable should be set to cli which will prevent flask-ligand from initializing Flask extensions. However, all settings required by the production environment still need to be set to successfully generate an OpenAPI client.

Offline Example

Generate a Python client download link with your flask-ligand based microservice in offline mode:

FLASK_ENV=cli flask genclient python