货币的类型是什么?

vic*_*vic 7 swagger swagger-editor openapi

我无法在对象定义中找到货币数据类型的样本,也找不到有关该主题的文档.

Hel*_*len 5

没有内置的“货币”类型。通常type: number,您可以使用可选的format修饰符来指示数字类型的含义:

type: number
format: currency
Run Code Online (Sandbox Code Playgroud)

format可以具有任意值,因此您可以使用format: currencyformat: decimal或您的工具支持的任何值。识别给定format值的工具会将值映射到相应的类型。

  • 格式字段的可接受值没有明确定义。您可以使用任何字符串。通用格式的注册表正在进行中,“十进制”是目前建议添加到该注册表的最合适字段。https://github.com/OAI/OpenAPI-Specification/issues/845#issuecomment-378139730 (2认同)