1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

23 Commits

Author SHA1 Message Date
Daniel Sheppard
fc8f02c180 Corrects error with ListSerializer as request_body 2021-01-26 14:03:46 -06:00
Jeremy Stretch
64d1f57276 Add custom get_operation_id() method to avoid monkey-patching coreapi 2020-11-11 14:25:43 -05:00
Jeremy Stretch
c0c5f52ed9 Reorganize REST API components under netbox app 2020-10-13 15:57:21 -04:00
Jeremy Stretch
b846f631a4 Rename connection_status to connected_endpoint_reachable 2020-10-05 11:32:39 -04:00
Jeremy Stretch
53e09a924c Restore and rename CustomChoiceFieldInspector 2020-08-26 15:04:22 -04:00
Jeremy Stretch
bde25e69f8 Add CustomFieldsDataFieldInspector for OpenAPI spec 2020-08-26 14:36:45 -04:00
Jeremy Stretch
0b7d019c02 Remove unused CustomChoiceFieldInspector 2020-08-25 15:16:20 -04:00
Jeremy Stretch
548127cc88 Rename VMInterface serializers 2020-06-23 15:46:20 -04:00
Jeremy Stretch
448dc1442c Replace TaggitSerializer and TagListSerializerField with TaggedObjectSerializer 2020-06-17 09:57:17 -04:00
kobayashi
1ce0191a74 Fixes #4361: Set correct type of connection_state 2020-04-15 01:02:11 -04:00
Jeremy Stretch
803287a514 Closes #4313: Remove id__in filters 2020-03-06 12:05:53 -05:00
Tomas Slusny
4136a5fd5e List choices for choice fields as enums
Fixes #4062

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
2020-03-05 23:44:37 -05:00
Dan Starner
e6ee9803d4 use FieldInspector for JSONField type 2020-03-03 12:04:46 -05:00
kobayashi
0be5488104 Fix #4274: Set correct value schema for int typed ChoiceField 2020-03-02 11:26:56 -05:00
John Anderson
6fe1b9b37c update openapi field type for choice field value fields to string 2019-12-09 00:41:43 -05:00
Jeremy Stretch
a3b9bdaff1 Miscellaneous cleanup 2019-10-04 12:59:10 -04:00
Jeremy Stretch
1995091169 Changelog & renaming for #2065 2019-03-07 13:58:34 -05:00
Cristi Vîjdea
3a62e9a322 Resolve drf-yasg ref_name conflicts
This solves the problem of distinct serializers being confused because they have the same class name (e.g. `InterfaceSerializer`)

Fixes #2065.
2019-03-04 03:49:26 +02:00
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
Jeremy Stretch
c2416411c1 Renamed ChoiceFieldSerializer and ContentTypeFieldSerializer 2018-07-30 12:41:20 -04:00
Dave Cameron
e071b7dfd5 The id__in field is a csv-separated string of ids
drf_yasg is interpreting it as a number because NumericInFilter inherits
from django's NumberFilter which explicitly identifies as being a
DecimalField.
2018-03-15 17:07:58 -04:00
Dave Cameron
53e4e74930 Differentiate better between boolean and 0, 1 choices 2018-03-15 17:07:58 -04:00
Dave Cameron
b83de7eb11 Use drf_yasg to generate swagger
drf_yasg provides more complete swagger output, allowing for generation
of usable clients.

Some custom work was needed to accommodate Netbox's custom field
serializers, and to provide x-nullable attributes where appropriate.
2018-03-15 17:07:58 -04:00