説明
標準の数値 format を使う場合、integer には int32 または int64、number には float または double を指定します。format は省略できます。
想定される影響
ツールが形式に対応していないと、生成した SDK の数値型が想定と異なる場合があります。
対処方法
実際の値に合う形式を選びます。独自の形式を使う場合は、代表的な値を使って検証とシリアライズの結果を確認してください。
例
例では、整数の id の形式を int64 に、数値の percentage の形式を float に変更しています。
変更前
json
{
"openapi": "3.0.0",
"components": {
"schemas": {
"MyObject": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "double"
},
"percentage": {
"type": "number",
"format": "int32"
}
}
}
}
}
}
変更後
json
{
"openapi": "3.0.0",
"components": {
"schemas": {
"MyObject": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
},
"percentage": {
"type": "number",
"format": "float"
}
}
}
}
}
}