From ee8288b3d5ed19782d1a3efc86c8332aef2151d2 Mon Sep 17 00:00:00 2001 From: Eric Fahlgren Date: Wed, 11 Feb 2026 08:30:59 -0800 Subject: [PATCH] api: add versions to 'latest' API result In order to present a valid list of versions, downstream clients are currently parsing the upstream '.versions.json' and synthesizing (or not) a '-SNAPSHOT' version. Since we're doing this already inside ASU, we might as well make it available to clients. This will allow us to rewrite Firmware Selector, which has a hard-coded regex to filter unsupported versions (which is currently wrong). With this change OFS will rely completely on the ASU server to tell it what is available. Likewise, this allows a cleanup of owut to remove its similar parsing of the branches and .versions files. It has no impact on LuCI ASU app, as it only uses the 'latest' list from this API call. Signed-off-by: Eric Fahlgren --- asu/main.py | 11 ++++++++++- tests/test_api.py | 7 +++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/asu/main.py b/asu/main.py index 8602bac4..d8b021bd 100644 --- a/asu/main.py +++ b/asu/main.py @@ -127,8 +127,17 @@ def generate_latest(): @app.get("/json/v1/latest.json") def json_v1_latest(): + """Returns two lists: + + 1) A list of the latest releases on each branch that is still + under support, including any upcoming RC versions. Sorted by + release branch, with newest first. + + 2) A list of all available versions (both releases and snapshot), + sorted newest first. + """ latest = generate_latest() - return {"latest": latest} + return {"latest": latest, "versions": app.versions} def generate_branches(): diff --git a/tests/test_api.py b/tests/test_api.py index 5e35736b..10249595 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -264,6 +264,13 @@ def test_api_latest_default(client): response = client.get("/api/v1/latest", follow_redirects=False) assert response.status_code == 301 + response = client.get("/api/v1/latest", follow_redirects=True) + assert response.status_code == 200 + data = response.json() + assert data["latest"] == ["24.10.0-rc6", "23.05.5", "22.03.7"] + assert data["versions"][0] == "SNAPSHOT" + assert data["versions"][-1] == "1.2-SNAPSHOT" + def test_api_overview(client): response = client.get("/api/v1/overview", follow_redirects=False)