The premier source of truth powering network automation. Open source under Apache 2. Try NetBox Cloud free: https://netboxlabs.com/products/free-netbox-cloud/
Go to file
Tatsushi Demachi c3cdf8e97e Fix type mismatches in API view (#2429)
* Fix tags field to be shown as array in API view

`tags` field in serializers is defineded as `TagListSerializerField`.
It should be shown as an array value in API view but actually, it is a
simple string value.

This fixes it by introducing a new `FieldInspector` to handle
`TagListSerializerField` type field as an array. It doesn't affects any
other type fields.

* Fix SerializedPKRelatedField type API expression

A field definded as `SerializedPKRelatedField` should be shown as an
array of child serializer objects in a response value definition in API
view but it is shown as an array of primary key values (usually
`integer` type) of a child serializer.

This fixes it by introducing a new `FieldInspector` to handle the field.
It doesn't affect any other type fields.

* Fix request parameter representation in API view

In API view, representation of a parameter defined as a sub class of
`WritableNestedSerializer` should be vary between a request and a
response. For example, `tenant` field in `IPAddressSerializer` should be
shown like following as a request body:

```
tenant: integer ...
```

while it should be shown like following as a response body:

```
tenant: {
    id: integer ...,
    url: string ...,
    name: string ...,
    slug: string ...
}
```

But in both cases, it is shown as a response body type expression. This
causes an error at sending an API request with that type value.

It is only an API view issue, API can handle a request if a request
parameter is structured as an expected request body by ignoring the
wrong expression.

This fixes the issue by replacing an implicitly used default auto schema
generator class by its sub class and returning a pseudo serializer with
'Writable' prefix at generating a request body. The reason to introduce
a new generator class is that there is no other point which can
distinguish a request and a response. It is not enough to distinguish
POST, PUT, PATCH methods from GET because former cases may return a JSON
object as a response but it is also represented as same as a request
body, causes another mismatch.

This also fixes `SerializedPKRelatedField` type field representation. It
should be shown as an array of primary keys in a request body.

Fixed #2400
2018-11-27 16:14:45 -05:00
.github Use real emojis for issue template names 2018-07-26 15:09:19 -04:00
docs Add developer guidance for the introduction of new dependencies 2018-11-27 10:45:10 -05:00
netbox Fix type mismatches in API view (#2429) 2018-11-27 16:14:45 -05:00
scripts Closes #2559: Add a pre-commit git hook to enforce PEP8 validation 2018-11-08 13:52:34 -05:00
.gitattributes Force Unix line endings on shell scripts 2017-03-09 16:20:32 +00:00
.gitignore Initial work on reports 2017-09-19 17:47:42 -04:00
.travis.yml Update CI to use pycostyle instead of pep8 2018-07-02 19:27:53 +02:00
base_requirements.txt Adopt django-taggit-serializer for representation of assigned tags in the API 2018-08-03 09:43:03 -04:00
CHANGELOG.md Fix type mismatches in API view (#2429) 2018-11-27 16:14:45 -05:00
CONTRIBUTING.md Further reiterated the policy for pull requests 2018-07-18 16:14:57 -04:00
LICENSE.txt Initial push to public repo 2016-03-01 11:23:03 -05:00
mkdocs.yml Expanded the development style guide 2018-11-12 14:36:09 -05:00
old_requirements.txt Use drf_yasg to generate swagger 2018-03-15 17:07:58 -04:00
README.md Add a page related to community related projects 2018-09-13 17:54:13 +02:00
requirements.txt Fixes #2526: Bump paramiko and pycryptodome requirements due to vulnerability 2018-10-22 11:23:37 -04:00
upgrade.sh Fixes #1527: Replace deprecated pycrypto library with pycryptodome 2017-10-09 17:40:15 -04:00

NetBox

NetBox is an IP address management (IPAM) and data center infrastructure management (DCIM) tool. Initially conceived by the network engineering team at DigitalOcean, NetBox was developed specifically to address the needs of network and infrastructure engineers.

NetBox runs as a web application atop the Django Python framework with a PostgreSQL database. For a complete list of requirements, see requirements.txt. The code is available on GitHub.

The complete documentation for NetBox can be found at Read the Docs.

Questions? Comments? Please subscribe to the netbox-discuss mailing list, or join us in the #netbox Slack channel on NetworkToCode!

Build Status

NetBox is built against both Python 2.7 and 3.5. Python 3.5 or higher is strongly recommended.

status
master Build Status
develop Build Status

Screenshots

Screenshot of main page

Screenshot of rack elevation

Screenshot of prefix hierarchy

Installation

Please see the documentation for instructions on installing NetBox. To upgrade NetBox, please download the latest release and run upgrade.sh.

Alternative Installations

Related projects

Supported SDK

  • pynetbox Python API client library for Netbox.

Community SDK

Ansible Inventory