- Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
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