define default values in openapi spec #4954

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

Originally created by @FalcoSuessgott on GitHub (Jun 1, 2021).

NetBox version

v2.11.1

Feature type

Data model extension

Proposed functionality

It would be nice if the default values for each property (if any) are also defined in the Netbox OpenAPI spec. They are, so far I can see, not defined for each and every object.

For example:

        "status": {
          "title": "Status",
          "type": "string",
          "enum": [
            "planned",
            "provisioning",
            "active",
            "offline",
            "deprovisioning",
            "decommissioned"
          ]
        },

could be defined as

        "status": {
          "title": "Status",
          "type": "string",
          "default": "active",
          "enum": [
            "planned",
            "provisioning",
            "active",
            "offline",
            "deprovisioning",
            "decommissioned"
          ]
        },

Since active value for status is the default returned by the API.

Use case

This helps us updating various netbox resources using OpenAPI libs.

Database changes

No response

External dependencies

No response

Originally created by @FalcoSuessgott on GitHub (Jun 1, 2021). ### NetBox version v2.11.1 ### Feature type Data model extension ### Proposed functionality It would be nice if the default values for each property (if any) are also defined in the Netbox OpenAPI spec. They are, so far I can see, not defined for each and every object. For example: ```json "status": { "title": "Status", "type": "string", "enum": [ "planned", "provisioning", "active", "offline", "deprovisioning", "decommissioned" ] }, ``` could be defined as ```json "status": { "title": "Status", "type": "string", "default": "active", "enum": [ "planned", "provisioning", "active", "offline", "deprovisioning", "decommissioned" ] }, ``` Since `active` value for status is the default returned by the API. ### Use case This helps us updating various netbox resources using OpenAPI libs. ### Database changes _No response_ ### External dependencies _No response_
adam added the type: featurestatus: needs ownerpending closure labels 2025-12-29 19:22:36 +01:00
adam closed this issue 2025-12-29 19:22:37 +01:00
Author
Owner

@FalcoSuessgott commented on GitHub (Jul 12, 2021):

@jeremystretch we are really interested in that fix/feature.
I would like to give it a try, may you can assist me in where to start? I have a more or less complete list with missing default values.

Really appreciate your assistance.

@FalcoSuessgott commented on GitHub (Jul 12, 2021): @jeremystretch we are really interested in that fix/feature. I would like to give it a try, may you can assist me in where to start? I have a more or less complete list with missing default values. Really appreciate your assistance.
Author
Owner

@jeremystretch commented on GitHub (Jul 12, 2021):

I'm happy to assign this issue to you but don't have any availability to help at the moment. Maybe someone else would like to step up to help.

@jeremystretch commented on GitHub (Jul 12, 2021): I'm happy to assign this issue to you but don't have any availability to help at the moment. Maybe someone else would like to step up to help.
Author
Owner

@FalcoSuessgott commented on GitHub (Jul 12, 2021):

@jeremystretch nvm, I found an example:

28ca815c88/netbox/dcim/api/serializers.py (L902-L920)

I will look into it this week then

@FalcoSuessgott commented on GitHub (Jul 12, 2021): @jeremystretch nvm, I found an example: https://github.com/netbox-community/netbox/blob/28ca815c8855b06e4250e7610fadc7c968c91dcb/netbox/dcim/api/serializers.py#L902-L920 I will look into it this week then
Author
Owner

@github-actions[bot] commented on GitHub (Jan 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 (Jan 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 (Feb 11, 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 (Feb 11, 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#4954