Skip to content

Commit

Permalink
Replaced default list server variables with object (#220)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Hopkins <[email protected]>
  • Loading branch information
cansarigol and ahopkins authored Dec 12, 2023
1 parent 4b7af45 commit 2e4ed3a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sanic_ext/extensions/openapi/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ def __init__(
variables: Optional[Dict[str, Any]] = None,
):
super().__init__(
url=url, description=description, variables=variables or []
url=url, description=description, variables=variables or {}
)


Expand Down
9 changes: 9 additions & 0 deletions tests/extensions/openapi/test_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import pytest

from sanic_ext.extensions.openapi.definitions import Server
from sanic_ext.extensions.openapi.types import Definition


Expand Down Expand Up @@ -45,3 +46,11 @@ def test_serialize_no_nullable(Thing):
assert serialized["name"] == "ok"
assert "foo" not in serialized
assert "bar" not in serialized


def test_server_definitions_defaults():
assert Server(url="url").fields == {
"url": "url",
"description": None,
"variables": {},
}

0 comments on commit 2e4ed3a

Please sign in to comment.