の二次元マップ私はこの(数字の2次元マップ)のように見えるオブジェクトを持っている:闊歩 - 数字
{
10: {
12000: 10000000,
14000: 23432423,
},
20: {
35000: 6747665,
45000: 54635454
}
}
闊歩で、このためのスキーマ定義とは何ですか?
ありがとうございました。
の二次元マップ私はこの(数字の2次元マップ)のように見えるオブジェクトを持っている:闊歩 - 数字
{
10: {
12000: 10000000,
14000: 23432423,
},
20: {
35000: 6747665,
45000: 54635454
}
}
闊歩で、このためのスキーマ定義とは何ですか?
ありがとうございました。
残念ながら、JSONのみキー名(参照Using number as "index" (JSON))として文字列を可能にする、提供された例は、このようにする必要があります:
{
"10": {
"12000": 10000000,
"14000": 23432423,
},
"20": {
"35000": 6747665,
"45000": 54635454
}
}
とOpenAPIの(。FKA SWAGGER)仕様で、あなたはマップを定義することができますが、キーのタイプは暗黙的であり、(JSONと同様に)文字列になっているはずです。
<string, something>
マップのオブジェクトを記述するときは、something
を記述するにはadditionalProperties
を使用する必要があります。ここ
は<string, <string, integer>>
マップに対応するスキーマを記述する2つの方法がある:
swagger: '2.0'
info:
version: 1.0.0
title: Maps
paths: {}
definitions:
# a <string, <string, integer>> map using
# inline definition of <string, integer> map item
TwoDimensionMap:
additionalProperties:
additionalProperties:
type: integer
format: int64
# a <string, integer> map
SimpleMap:
additionalProperties:
type: integer
format: int64
# a <string, <string, integer>> map using
# $ref definition of <string, integer> map item
TwoDimensionMapWithRef:
additionalProperties:
$ref: '#/definitions/SimpleMap'
TwoDimensionMap
フルインライン定義であり、TwoDimensionMapWithRef
は正確に同じことを記述するが、内側<string, integer>
マップの別の定義への参照を使用して。