Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Object count fields are documented in Swagger for REST API GET requests but not included in the response #16085

Open
atownson opened this issue May 10, 2024 · 1 comment
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation topic: OpenAPI type: bug A confirmed report of unexpected behavior in the application

Comments

@atownson
Copy link
Contributor

Deployment Type

Self-hosted

NetBox Version

v4.0.1

Python Version

3.11

Steps to Reproduce

The RelatedObjectCountField REST API serializer fields are being documented in the REST API Swagger for GET requests but not actually returned in the response.

  1. View the Swagger documentation for /dcim/devices/:
    image
  2. Invoke a corresponding GET request and review the response content:
{
    "count": 1,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": 1,
            "url": "https://mynetbox.com/api/dcim/devices/1/",
            "display": "mydevice",
            "name": "mydevice",
            "device_type": {
                "id": 1,
                "url": "https://mynetbox.com/api/dcim/device-types/1/",
                "display": "mytype",
                "manufacturer": {
                    "id": 1,
                    "url": "https://mynetbox.com/api/dcim/manufacturers/1/",
                    "display": "mymanufacturer",
                    "name": "mymanufacturer",
                    "slug": "mymanufacturer",
                    "description": ""
                },
                "model": "mytype",
                "slug": "mytype",
                "description": ""
            },
            "role": {
                "id": 1,
                "url": "https://mynetbox.com/api/dcim/device-roles/1/",
                "display": "server",
                "name": "server",
                "slug": "server",
                "description": ""
            },
            "tenant": null,
            "platform": null,
            "serial": "",
            "asset_tag": null,
            "site": {
                "id": 1,
                "url": "https://mynetbox.com/api/dcim/sites/1/",
                "display": "mysite",
                "name": "mysite",
                "slug": "mysite",
                "description": ""
            },
            "location": null,
            "rack": null,
            "position": null,
            "face": null,
            "latitude": null,
            "longitude": null,
            "parent_device": null,
            "status": {
                "value": "active",
                "label": "Active"
            },
            "airflow": null,
            "primary_ip": {
                "id": 2,
                "url": "https://mynetbox.com/api/ipam/ip-addresses/2/",
                "display": "192.168.0.10/32",
                "family": {
                    "value": 4,
                    "label": "IPv4"
                },
                "address": "192.168.0.10/32",
                "description": ""
            },
            "primary_ip4": {
                "id": 2,
                "url": "https://mynetbox.com/api/ipam/ip-addresses/2/",
                "display": "192.168.0.10/32",
                "family": {
                    "value": 4,
                    "label": "IPv4"
                },
                "address": "192.168.0.10/32",
                "description": ""
            },
            "primary_ip6": null,
            "oob_ip": null,
            "cluster": null,
            "virtual_chassis": null,
            "vc_position": null,
            "vc_priority": null,
            "description": "",
            "comments": "",
            "config_template": null,
            "config_context": {},
            "local_context_data": null,
            "tags": [],
            "custom_fields": {},
            "created": "2023-10-04T17:05:56.749955Z",
            "last_updated": "2023-10-04T23:36:26.264584Z",
            "console_port_count": 0,
            "console_server_port_count": 0,
            "power_port_count": 0,
            "power_outlet_count": 0,
            "interface_count": 1,
            "front_port_count": 0,
            "rear_port_count": 0,
            "device_bay_count": 0,
            "module_bay_count": 0,
            "inventory_item_count": 0
        }
    ]
}

The behavior seems consistent wherever RelatedObjectCountField is used.

Expected Behavior

Based on the serializer classes, I assume the intention is to include these count fields since they're included in the brief fields. Either way, the Swagger scheme documentation should match the response content.

Observed Behavior

The Swagger documented schemes differ from the response content.

@atownson atownson added status: needs triage This issue is awaiting triage by a maintainer type: bug A confirmed report of unexpected behavior in the application labels May 10, 2024
@jeremystretch
Copy link
Member

Related object counts are intended to be included only for the root object: The data is not available on the underlying queryset when nesting. Opening this for anyone who would like to correct the OpenAPI schema to reflect this.

@jeremystretch jeremystretch removed their assignment May 13, 2024
@jeremystretch jeremystretch added status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation severity: low Does not significantly disrupt application functionality, or a workaround is available and removed status: needs triage This issue is awaiting triage by a maintainer labels May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity: low Does not significantly disrupt application functionality, or a workaround is available status: needs owner This issue is tentatively accepted pending a volunteer committed to its implementation topic: OpenAPI type: bug A confirmed report of unexpected behavior in the application
Projects
None yet
Development

No branches or pull requests

2 participants