netbox-community / go-netbox

The official Go API client for Netbox IPAM and DCIM service.
Other
194 stars 144 forks source link

Device ConfigContext rendered as wrong type #87

Closed dgjustice closed 3 years ago

dgjustice commented 4 years ago

This is only a problem when a device has a "config context" attached to it.

{"count":1,"next":null,"previous":null,"results":[{"id":511,"name":... ,
"config_context":{
    "name":"Somewhere",
    "devices":[
        "thing1", "thing2", "thing3"
    ]
},"created":"2019-04-29","last_updated":"2019-04-29T17:40:30
.440516Z"}]}
FATA[0000] Cannot get devices list: json: cannot unmarshal array into Go struct field DeviceWithConfigContext.results.config_context of type string
exit status 1

I believe the problem is in the swagger spec here: https://github.com/netbox-community/go-netbox/blob/master/swagger.json#L32639

Resulting in an incorrect type here: https://github.com/netbox-community/go-netbox/blob/master/netbox/models/device_with_config_context.go#L52

I believe it should be (works locally at least):

ConfigContext *ConfigContext `json:"config_context,omitempty"`

I haven't touched go in a while, but I'll try to PR this once I figure out the config gen.

dgjustice commented 4 years ago

When I run make clean && make generate, I get a ton of file changes and failing tests. Is there a pinned version of the go-swagger container that is being used? I assume this process should be idempotent.

swagger version
version: v0.24.0
commit: 094421c7a2e1a7982cb28fdc0fc2bda610bbcc56