Allow untyped objects to be specified as bytes
drmaas opened this issue · 3 comments
In many of our specs, we have things like this:
authorization_data:
type: object
description: Data, as an arbitrary json blob
or
authorization_data:
type: object
description: Data, as an arbitrary json blob
additionalProperties: true
This allows arbitrary data, per https://swagger.io/docs/specification/data-models/dictionaries/
Currently, this will be generated as an empty Message
or a map<string, empty Message>
by this library. This does't work well. My proposal is that these should actually be modeled as the scalar type bytes
. That way, whatever language implementation is using the schema can decide how to convert the arbitrary data into and from bytes.
Another option would be to use google.protobuf.Any
, as it does basically the same thing, but also allows packing/unpacking to different Message
types.
@jprobinson any thoughts on what is preferred?
Looking into the further, it seems like using Any
is the most flexible option.
I take that back - Any
is intended to represent any other Message
type. It seems a poor fit. I'm not sure what the best solve is for this.
I updated my PR to use Struct
. Let me know your thoughts.