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

Change API-Documentation for AvailailableIP/Prefix to accept list of objects #10311

Closed
amhn opened this issue Sep 9, 2022 · 3 comments
Closed
Labels
pending closure Requires immediate attention to avoid being closed for inactivity type: feature Introduction of new functionality to the application

Comments

@amhn
Copy link
Contributor

amhn commented Sep 9, 2022

NetBox version

v3.3.3

Feature type

Change to existing functionality

Proposed functionality

This is similar to #9471. But instead of changing the function, i propose to change only the API-Documentation.

The current swagger.json documents the functions to accept an object as input and return a list of objects. As far as i can see both can never be met. If the in put is a single object, the return value is always a single object, but never a list.

Changing the annotation in the post function of AvailableIPAddressesView from

request_body=serializers.AvailableIPSerializer

to

request_body=ListSerializer(serializers.AvailableIPSerializer)

changes the swagger.json while not affecting the functionality. The same can be done for AvailablePrefix.

The diff looks something like

60400c77296,77299
<                     "schema" : { "$ref" : "#/definitions/WritableAvailableIP" }
---
>                     "schema" : { 
>                         "items" : { "$ref" : "#/definitions/WritableAvailableIP" },
>                         "type" : "array"
>                       }
62497c79701,79704
<                     "schema" : { "$ref" : "#/definitions/PrefixLength" }
---
>                     "schema" : { 
>                         "items" : { "$ref" : "#/definitions/PrefixLength" },
>                         "type" : "array"
>                       }

If you want I can create a PR for this.

Use case

This would help users of strongly typed languages to generate a working library from swagger.json.

While not ideal, at least this allows users of the library to use this functionality by always providing a list, even for a single value.

Database changes

None

External dependencies

None

@amhn
Copy link
Contributor Author

amhn commented Sep 10, 2022

I thought about this a little more. If the Input object could be changed to WritableIpAddressSerializer it would be possible to create an object and set description, tenant and other parameters in just one API-Request.

For AvailablePrefix this does not work directly. Maybe adding a field data = WritablePrefixSerializer toPrefixLengthSerializer would be a solution. Maybe the same should be done for available-ip to help with backward compatibility.

As per spec address and prefix are required fields in the writable serializers, these would have to be ignored and the return values of available-ip/prefix should be used.

Currently my workflow consists of requesting an IP and then doing a PUT request to update all fields. This results in 2 changelog entries for 1 change.

@github-actions
Copy link
Contributor

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. Do not attempt to circumvent this process by "bumping" the issue; doing so will result in its immediate closure and you may be barred from participating in any future discussions. Please see our contributing guide.

@github-actions github-actions bot added the pending closure Requires immediate attention to avoid being closed for inactivity label Nov 10, 2022
@github-actions
Copy link
Contributor

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 github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 11, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
pending closure Requires immediate attention to avoid being closed for inactivity type: feature Introduction of new functionality to the application
Projects
None yet
Development

No branches or pull requests

1 participant