Closed DSpeichert closed 3 years ago
This could you be related to #98 can you give that PR a try @DSpeichert
@awlx I have tried that PR and it didn't quite help.
The problem is this part of swagger.json (it repeats multiple times):
"connected_endpoint": {
"title": "Connected endpoint",
"description": "\nReturn the appropriate serializer for the type of connected object.\n",
"type": "object",
"additionalProperties": {
"type": "string"
},
"readOnly": true
},
which generates simply:
// Connected endpoint
//
//
// Return the appropriate serializer for the type of connected object.
//
// Read Only: true
ConnectedEndpoint map[string]string `json:"connected_endpoint,omitempty"`
Here's an example of connected_endpoint
as part of a response to /api/dcim/interfaces
query:
"connected_endpoint": {
"id": 57,
"url": "http://netbox/api/dcim/interfaces/57/",
"device": {
"id": 4,
"url": "http://netbox/api/dcim/devices/4/",
"name": "tor02",
"display_name": "tor02"
},
"name": "Ethernet3",
"cable": 181,
"connection_status": {
"value": true,
"label": "Connected"
}
},
It fails at id
, which is clearly an integer. Likely the swagger spec has to have the whole structure defined.
I agree with @DSpeichert, PR #98 won't fix his problem.
I still get this error: cannot unmarshal number into Go struct field Interface.results.connected_endpoint of type string
How to get rid of it?
it looks like there is a fix out there: replace github.com/netbox-community/go-netbox => github.com/stefanhipfel/go-netbox v0.0.0-20200928114340-fcd4119414a4
When running:
We get:
I wasn't able to pinpoint what call exactly gets that (yet) because running the API call via e.g. curl does return a string value for that field (
"connected_endpoint_type": "dcim.interface",
).However, the model does expect a string and does not get one somehow.