Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/crutchcorn/modern-python-enterprise-template. A modern Python enterprise template with a focus on p
Something went wrong. Try again.
676 B · 28 lines
Python
at main
1234567891011121314151617181920212223242526272829"""Export the FastAPI OpenAPI spec to a JSON file."""
import argparseimport jsonimport sys
from src.core import app
def export_openapi(output: str | None = None) -> None: spec = app.openapi() text = json.dumps(spec, indent=2)
if output: with open(output, "w") as f: f.write(text) else: sys.stdout.write(text) sys.stdout.write("\n")
if __name__ == "__main__": parser = argparse.ArgumentParser(description="Export FastAPI OpenAPI spec") parser.add_argument( "-o", "--output", help="Output file path (default: stdout)", default=None ) args = parser.parse_args() export_openapi(args.output)