Skip to content

Commit

Permalink
fix api schema error (#99)
Browse files Browse the repository at this point in the history
* fix 98

* update netbox version in ci
  • Loading branch information
amyasnikov authored Jul 12, 2024
1 parent 95b55b5 commit 43eb077
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
netbox_version: [v3.6.9, v3.7.8, v4.0.2]
netbox_version: [v3.6.9, v3.7.8, v4.0.7]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
9 changes: 6 additions & 3 deletions validity/api/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from functools import partial
from functools import partialmethod
from itertools import chain
from typing import Sequence

Expand All @@ -23,8 +23,11 @@ def nested_factory(
Creates nested Serializer from regular one
"""
if nb_version >= "4.0.0":
Serializer = type(serializer.__name__, (serializer,), {"Meta": meta_factory(parent=serializer.Meta)})
return partial(Serializer, nested=True)
class_attributes = {
"Meta": meta_factory(parent=serializer.Meta),
"__init__": partialmethod(serializer.__init__, nested=True),
}
return type(serializer.__name__, (serializer,), class_attributes)

name = "Nested" + serializer.__name__
mixins = (cls for cls in serializer.__bases__ if not issubclass(cls, ModelSerializer))
Expand Down

0 comments on commit 43eb077

Please sign in to comment.