Swagger descriptions are incorrect in several places #5864

Closed
opened 2025-12-29 19:33:36 +01:00 by adam · 4 comments
Owner

Originally created by @abhi1693 on GitHub (Jan 2, 2022).

NetBox version

v3.1.3

Python version

3.9

Steps to Reproduce

Go to https://demo.netbox.dev/api/swagger.json and inspect the description for GET /dcim/power-feeds/.

"/dcim/power-feeds/": {"get": {"operationId": "dcim_power-feeds_list", "description": "Overrides ListModelMixin to allow processing ExportTemplates.",

Expected Behavior

The descriptions should describe the component

Observed Behavior

On most GET method description, the same text is displayed

Overrides ListModelMixin to allow processing ExportTemplates.
Originally created by @abhi1693 on GitHub (Jan 2, 2022). ### NetBox version v3.1.3 ### Python version 3.9 ### Steps to Reproduce Go to https://demo.netbox.dev/api/swagger.json and inspect the description for `GET` `/dcim/power-feeds/`. ``` "/dcim/power-feeds/": {"get": {"operationId": "dcim_power-feeds_list", "description": "Overrides ListModelMixin to allow processing ExportTemplates.", ``` ### Expected Behavior The descriptions should describe the component ### Observed Behavior On most `GET` method description, the same text is displayed ``` Overrides ListModelMixin to allow processing ExportTemplates. ```
adam added the type: bugstatus: needs ownerpending closure labels 2025-12-29 19:33:36 +01:00
adam closed this issue 2025-12-29 19:33:36 +01:00
Author
Owner

@jeremystretch commented on GitHub (Jan 3, 2022):

It looks like Swagger is returning the docstring for the viewset method for some reason. IMO this is not desirable behavior, as the docstring is intended for developer use and often not suitable for display to the end user.

@jeremystretch commented on GitHub (Jan 3, 2022): It looks like Swagger is returning the docstring for the viewset method for some reason. IMO this is not desirable behavior, as the docstring is intended for developer use and often not suitable for display to the end user.
Author
Owner

@DanSheps commented on GitHub (Jan 10, 2022):

Went down the rabbit hole, unless we override it, this is the function that defines view names:

f9ccbad4d9/rest_framework/views.py (L47)

def get_view_description(view, html=False):
    """
    Given a view instance, return a textual description to represent the view.
    This name is used in the browsable API, and in OPTIONS responses.

    This function is the default for the `VIEW_DESCRIPTION_FUNCTION` setting.
    """
    # Description may be set by some Views, such as a ViewSet.
    description = getattr(view, 'description', None)
    if description is None:
        description = view.__class__.__doc__ or ''

    description = formatting.dedent(smart_str(description))
    if html:
        return formatting.markup_description(description)
    return description

It looks like we can assign the description with a "description" attribute on the class.

@DanSheps commented on GitHub (Jan 10, 2022): Went down the rabbit hole, unless we override it, this is the function that defines view names: https://github.com/encode/django-rest-framework/blob/f9ccbad4d910d19e4298300ee90467051fc08f47/rest_framework/views.py#L47 ```python def get_view_description(view, html=False): """ Given a view instance, return a textual description to represent the view. This name is used in the browsable API, and in OPTIONS responses. This function is the default for the `VIEW_DESCRIPTION_FUNCTION` setting. """ # Description may be set by some Views, such as a ViewSet. description = getattr(view, 'description', None) if description is None: description = view.__class__.__doc__ or '' description = formatting.dedent(smart_str(description)) if html: return formatting.markup_description(description) return description ``` It looks like we can assign the description with a "description" attribute on the class.
Author
Owner

@github-actions[bot] commented on GitHub (Mar 12, 2022):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our contributing guide.

@github-actions[bot] commented on GitHub (Mar 12, 2022): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. NetBox is governed by a small group of core maintainers which means not all opened issues may receive direct feedback. Please see our [contributing guide](https://github.com/netbox-community/netbox/blob/develop/CONTRIBUTING.md).
Author
Owner

@github-actions[bot] commented on GitHub (Apr 14, 2022):

This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.

@github-actions[bot] commented on GitHub (Apr 14, 2022): This issue has been automatically closed due to lack of activity. In an effort to reduce noise, please do not comment any further. Note that the core maintainers may elect to reopen this issue at a later date if deemed necessary.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#5864