From 5656515830416214a7e842430cbcf4ff6ed12bb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=93teris=20Caune?= Date: Sat, 2 Oct 2021 13:38:45 +0300 Subject: [PATCH] Add 'schemaVersion' field in the shields.io endpoint Fixes: #566 --- CHANGELOG.md | 1 + hc/api/tests/test_badge.py | 5 ++++- hc/api/views.py | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dd3c488..1ee52681 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes to this project will be documented in this file. - Drop API support for GET, DELETE requests with a request body - Add missing @csrf_exempt annotations in API views - Fix the ping handler to reject status codes > 255 +- Add 'schemaVersion' field in the shields.io endpoint (#566) ## v1.22.0 - 2020-08-06 diff --git a/hc/api/tests/test_badge.py b/hc/api/tests/test_badge.py index cd2488e2..25e188fb 100644 --- a/hc/api/tests/test_badge.py +++ b/hc/api/tests/test_badge.py @@ -90,4 +90,7 @@ class BadgeTestCase(BaseTestCase): def test_it_returns_shields_json(self): doc = self.client.get(self.shields_url).json() - self.assertEqual(doc, {"label": "foo", "message": "up", "color": "success"}) + self.assertEqual( + doc, + {"schemaVersion": 1, "label": "foo", "message": "up", "color": "success"}, + ) diff --git a/hc/api/views.py b/hc/api/views.py index 660f3f5a..aec09cc6 100644 --- a/hc/api/views.py +++ b/hc/api/views.py @@ -461,7 +461,9 @@ def badge(request, badge_key, signature, tag, fmt): elif status == "late": color = "important" - return JsonResponse({"label": label, "message": status, "color": color}) + return JsonResponse( + {"schemaVersion": 1, "label": label, "message": status, "color": color} + ) if fmt == "json": return JsonResponse(