metal-stack / metal-api

API to manage and control plane resources like machines, switches, operating system images, machine sizes, networks, IP addresses and more
GNU Affero General Public License v3.0
126 stars 9 forks source link

Validate machine response against swagger spec. #515

Open Gerrit91 opened 3 months ago

Gerrit91 commented 3 months ago

We often produce responses with our server that are not valid against the Swagger spec. For Go clients this seems not to be a big issue as type safety is guaranteed and it's not possible to produce server responses that violate type constraints. For other clients like Python there are much stricter validations though.

Our main problem that we made is to declare arrays without omitempty, which for Go Clients does not matter but for other languages it might be problematic.

This PR is non-breaking for Go Clients.

Gerrit91 commented 3 months ago

For some fields we were lucky before because we returned directly what was returned from the RethinkDB, which never returns nil but an empty slice for document fields. Therefore we fulfilled the spec's contract without explicitly setting it, e.g. for destinationprefixes.