Spaces:
Runtime error
Runtime error
File size: 766 Bytes
bfc0ec6 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
"""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()
|