I couldn't find a dedicated Swagger ML, so I hope it's okay to post here. Everyone else seems to :-)
I have a situation where the type of a field in my Swagger model may very depending on the message. Based on the examples at
json-schema.org, I think it should look something like this (where the type of Obj.varies could be one of Foo, Bar or Bam):
"models": {
"Foo": { "id": "Foo", "properties": { ... } },
"Bar": { "id": "Bar", "properties": { ... } },
"Bam": { "id": "Bam", "properties": { ... } },
"Obj": { "id": "Obj",
"properties": {
...
"varies": {
"type": "object",
"oneOf": [
{ "$ref": "Foo" },
{ "$ref": "Bar" },
{ "$ref": "Bam" }
]
}
}
}
}
Of course, this isn't working. Is this sort of thing supported by Swagger's models? If not, is there something similar, like inheritance or discriminated unions?
Thanks!
--
David M. Lee
Digium, Inc. | Software Developer
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA