Generate stubs for external library? #3065
Unanswered
AlexCK-STFC
asked this question in
Q&A
Replies: 1 comment
-
|
It's likely manual stub creation is needed as many object types are tracable to others, i.e. Ip-Address -> either Device or VM depending on assigned object type. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to work out if this tool is what I'm looking for.
The pynetbox library has models but incomplete stubs. It maps API endpoints to models (or a default generic type); then adds additional keys as properties on the fly.
https://github.com/netbox-community/pynetbox/tree/master/pynetbox/models
Someone made a now-archived stubs project, and pointed to this tool as a replacement:
https://github.com/interdotlink/pynetbox-stubs/
The schema for netbox can be found at https://demo.netbox.dev/api/schema/?format=json
Can datamodel-code-generator generate stubs, mapping to these PyNetbox models? I.e. via --type-overrides, something like
--type-overrides {"PaginatedDeviceWithConfigContextList": "pynetbox.models.dcim.Devices"}? Is there documentation for this use-case?If this is the correct method, via type-overrides, is there an easy way to ingest the endpoint mapping-> model names (I could make a custom script to fetch them)?
And how should I handle "None" mappings which go to a generic "Record" class?
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions