I need to define a swagger property that doesn't have a known name.
{
"type": "object",
"properties": {
"?????": {
"type": "array",
"items": { "$ref": "#/definitions/ModelRelease" }
}
}
The ????? portion of my definition is an integer of an unknown value. Any ideas?
OpenAPI 3.0 data types are based on an extended subset JSON Schema Specification Wright Draft 00 (aka Draft 5). The data types are described using a Schema object. To learn how to model various data types, see the following topics: Data Types.
You could use additionalProperties
to define a hashmap ("?????" being a key in this hashmap without the need to define it):
{
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"$ref": "#/definitions/ModelRelease"
}
}
}
In the general case, hashmaps can have an arbitrary number of items, but you can use minProperties
and maxProperties
to limit the item count. For example, if your object must have just one property:
{
"type": "object",
"additionalProperties": {
"type": "array",
"items": {
"$ref": "#/definitions/ModelRelease"
}
},
"minProperties": 1,
"maxProperties": 1
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With