.Swagger: haritası <dize, Nesne>
Örnek:
{
"a_property": {
"foo": {
"property_1": "a string 1",
"property_2": "a string 2"
},
"bar": {
"property_1": "a string 3",
"property_2": "a string 4"
}
}
}
"foo" ve "çubuk" herhangi bir dize tuşları olabilir, ama bunlar tuşlarının set arasında benzersiz olmalıdır.
Ben Swagger, ben nesneleri dizisi tanımlayabilirsiniz, biliyorum, ama biz o zaman bir şey olurdu çünkü bu farklı bir API verir: Ben 'Open API Specification' - 'Add support for Map data types #38' sayfasını okudum
{
"a_property": [
{
"key": "foo"
"property_1": "a string 1",
"property_2": "a string 2"
},
{
"key": "bar"
"property_1": "a string 3",
"property_2": "a string 4"
}
]
}
. Anladığım kadarıyla, ekProperties kullanılmasını önerir, ancak benim ihtiyacım (veya kullandığım Swagger UI 2.1.4 ile çalışmıyor) yanıt vermiyor gibi görünüyor. Bir şey mi özledim?
buldum Şimdiye kadar aşağıdaki iş çevresinde (Swagger JSON cinsinden):
a_property: {
description: "This is a map that can contain several objects indexed by different keys.",
type: object,
properties: {
key: {
description: "map item",
type: "object",
properties: {
property_1: {
description: "first property",
type: string
},
property_2: {
description: "second property",
type: string
}
}
}
}
}
Bu neredeyse iş yapar, ancak okuyucu herhangi bir dize "anahtar" olabileceğini anlamak zorundadır ve birkaç kez tekrarlanabilir.
ihtiyacım olanı başarmak için daha iyi bir yolu var mı?
Şahsen bana anlamak için biraz zaman harcamış * neden * 'ekProperties' doğru cevaptır: http://stackoverflow.com/a/41240118/110488 –