Skip to content

Incorrect Field Type in Response for GET /api/dcim/device-type(/{id}/) Model Schema #15184

Closed
@jniec-js

Description

@jniec-js

Deployment Type

Self-hosted

NetBox Version

v3.7.1

Python Version

3.11

Steps to Reproduce

  1. Look at the API documentation for /api/dcim/device-types/{id}, on the demo site (https://demo.netbox.dev/api/schema/swagger-ui/#/dcim/dcim_device_types_retrieve) and inspect the Schema for DeviceType, see that front_image and rear_image are declared as strings
  2. Use https://demo.netbox.dev/dcim/device-types/7/ as an example to test, a device_type that has no front or rear images associated with the object
  3. Send an http GET request to /api/dcim/device-types/7/ using the netbox demo's swagger documentation website here: https://demo.netbox.dev/api/schema/swagger-ui/#/dcim/dcim_device_types_retrieve, click "try it out!", for the ID, enter in 7, click Execute
  4. Observe that the response payload for front_image and/or rear_image is set to null and not an empty string despite the Model specifying "string" for the type and not specfying "nullable:true" on the field. See screenshots below:

Expected Behavior

I expected that the types in the response from the query would match what types are defined in the model.

Observed Behavior

We get back the wrong type in the response from the API when a front and/or rear image is not attached to a device_type.
Screenshot from 2024-02-16 21-12-05
Screenshot from 2024-02-16 21-11-55

Metadata

Metadata

Assignees

Labels

severity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtopic: OpenAPItype: bugA confirmed report of unexpected behavior in the application

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions