swagger-blocks
swagger-blocks copied to clipboard
What is the proper way to define different object structures inside an array schema?
I hope this is a legit question, I searched everywhere for an example or any source of information on how to do this. I tried this https://github.com/fotinakis/swagger-blocks/issues/17 as well. But the same result.
The end result I would like to get generated is below:
{
"name": "Awesome Promotion",
"description": "30% off",
"qualifiers": [
{
"id": 12,
"type": "Rental"
},
{
"id": 13,
"type": "Qualifier",
"user_id": 23
},
{
"id": 14,
"type": "First",
"location_id": 32
}
]
I have the model writen out like this:
swagger_schema :PromotionResponse do
property :name, type: :string, example: 'Awesome Promotion'
property :description, type: :string, example: '30% off'
property :qualifiers do
key :type, :array
items do
property :id, type: :integer, example: 2
property :type, type: :string, exmple: 'Location'
end
end
end
What gets generated by swagger right now:
{
"name": "Awesome Promotion",
"description": "30% off",
"qualifiers": [
{
"id": 2,
"type": "Location"
}
]
}
What is the proper way to define different object structures inside an array schema?
Hi, I'm not sure if this is helping but if I were in your place, I would have added user_id
, location_id
or any other key into the items do end
block and define id
and type
as required properties.