How can I define a map
with arbitrary keys in a Swagger model
Say I have the following internationalised model (in Ruby-style pseudocode, assuming use of something like Globalize
)
class Thingy
translates :name
attribute :code
end
and my API wishes to be able to return something like
{
"thingy": {
"code": "barn",
"translations": {
"default": "barn",
"en": "barn",
"ru": "cарай",
"fr": "grange",
"nl": "schuur"
}
}
}
but I don't want to restrict the range of translation keys in the actual API
I can define in my swagger doc
definitions:
thingy:
required:
- code
properties:
code:
type: string
additionalProperties:
translations:
required:
- default
property:
default:
type: string
additonalProperties: string
That validates but the Swagger Codegen won't generate anything off the additionalProperties
and it's not very explicit compared to somehow being able to define a map
type with a mix of required and arbitrary keys.
Anyone working with internationalisation is going to face similar issues so my question is, how have other people dealt with this scenario?