nikhil_no_persistent / lilac /make_openapi.py
nsthorat-lilac's picture
Duplicate from lilacai/nikhil_staging
bfc0ec6
raw
history blame
766 Bytes
"""Writes the openapi.json file to the specified output.
This is meant to run as a standalone script. It lives in lilac/ so we can import the FastAPI app.
"""
import json
import click
from fastapi.openapi.utils import get_openapi
from .server import app
@click.command()
@click.option(
'--output', required=True, type=str, help='The output filepath for the opepnapi.json file.')
def main(output: str) -> None:
"""Create the openapi.json file for the API to generate TypeScript stubs."""
with open(output, 'w') as f:
json.dump(
get_openapi(
title=app.title,
version=app.version,
openapi_version=app.openapi_version,
description=app.description,
routes=app.routes), f)
if __name__ == '__main__':
main()