How can I define a map with arbitrary keys in a Swagger model
Let's say I have the following internationalized model (in a Ruby-style pseudo-code that assumes using something like Globalize )
class Thingy translates :name attribute :code end
and my API wants to return something like
{ "thingy": { "code": "barn", "translations": { "default": "barn", "en": "barn", "ru": "c", "fr": "grange", "nl": "schuur" } } }
but I don't want to limit the range of translation keys in the actual API
I can spot in my swag doc
definitions: thingy: required: - code properties: code: type: string additionalProperties: translations: required: - default property: default: type: string additonalProperties: string
This is confirmed, but Swagger Codegen does not generate anything from additionalProperties and is not very explicit compared to somehow able to determine the type of map with a combination of required and arbitrary keys.
Anyone who works with internationalization will run into similar problems, so my question is, how do other people handle this scenario?
internationalization rails-i18n swagger
Dave sag
source share