-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Hello!
Currently the MMDS get operation is defined as follows:
/mmds:
# ...snip...
get:
summary: Get the MMDS data store.
responses:
200:
description: The MMDS data store JSON.
schema:
type: object
400:
description: Cannot get the MMDS data store due to bad input.
schema:
$ref: "#/definitions/Error"
default:
description: Internal server error
schema:
$ref: "#/definitions/Error"The schema is defined as object, which is parallel to the schema of the put and patch operations as well. In the Firecracker SDK for Go, we've received a pull request to add a GetMetadata method to retrieve the metadata from the MMDS. However, the definition of the schema as object (and the way that go-openapi generates a client) makes that difficult to work with.
When object is defined, our Swagger client generator gives us an interface{}, which is Go's equivalent of a void pointer; we then need figure out some way of converting that to a useful value. One mechanism is to implement dynamic type discovery, which is a lot of boilerplate and error-prone code. Another is to send this back through another serialization-deserialization round-trip to use Go's built-in JSON decoding, but that will be inefficient especially for large objects. Or there are other approaches that involve digging beneath the Swagger client library's abstractions.
Would you be willing to change this to a string (and format: binary) instead of object? If this were defined as a string, we would get the serialized data back and can deserialize it ourselves instead of needing these workarounds.
If this isn't a change you'd be willing to make, we do have some options:
- Dynamic type discovery
- Reserialize-deserialize round-trip
- Patch the swagger spec ourselves
- Implement a separate
Clientwith a separateruntime.ClientResponseReaderjust for this operation
But these approaches are all more complicated, and (though I haven't looked) I suspect that other Swagger client generators in other programming languages will have similar challenges with a returned object.
Thanks,
Sam