Skip to content

Commit

Permalink
fix broken api schema (#115)
Browse files Browse the repository at this point in the history
  • Loading branch information
amyasnikov authored Sep 23, 2024
1 parent 7504af9 commit 116befe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion validity/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ class Meta:
)
brief_fields = ("id", "url", "display")

def get_results_url(self, obj):
def get_results_url(self, obj) -> str:
results_url = reverse("plugins-api:validity-api:compliancetestresult-list", request=self.context["request"])
return results_url + f"?report_id={obj.pk}"

Expand Down
3 changes: 2 additions & 1 deletion validity/netbox_changes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from functools import partial

from validity import config
from validity.api.helpers import nested_factory


if config.netbox_version >= "4.1.0":
Expand All @@ -25,4 +26,4 @@ def content_types(custom_field):
else:
from tenancy.api.serializers import TenantSerializer as __TenantSerializer

NestedTenantSerializer = partial(__TenantSerializer, nested=True)
NestedTenantSerializer = nested_factory(__TenantSerializer, nb_version=config.netbox_version)
5 changes: 5 additions & 0 deletions validity/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,3 +222,8 @@ def test_run_tests(admin_client, di, post_body, status_code):
assert resp.status_code == status_code
if resp.status_code == HTTPStatus.OK:
launcher.assert_called_once()


def test_api_schema_is_not_broken(admin_client):
resp = admin_client.get("/api/schema/")
assert resp.status_code == HTTPStatus.OK

0 comments on commit 116befe

Please sign in to comment.