From d07c491f40cb5b2c141da20e0fb8a9d431506d09 Mon Sep 17 00:00:00 2001 From: jerry Date: Mon, 9 Sep 2024 00:55:01 +0000 Subject: [PATCH] script to generate latest api specs file (#1374) --- scripts/api-specs-update.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 scripts/api-specs-update.py diff --git a/scripts/api-specs-update.py b/scripts/api-specs-update.py new file mode 100755 index 00000000..5c0ec822 --- /dev/null +++ b/scripts/api-specs-update.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +"""Update the latest api specs file from a running django server""" + +import sys + +import urllib.request +import urllib.error + + +try: + urllib.request.urlretrieve( + "http://127.0.0.1:8000/api/schema", "docs/assets/schemas/api-latest.yaml" + ) +except urllib.error.URLError as e: + print(f"Could not fetch latests API specs: {e}", file=sys.stderr) + print("Make sure that the django server is running", file=sys.stderr) + sys.exit(1) + +print("Api specs successfully updated")