【问题标题】:Reusable enum types in json schemajson 模式中的可重用枚举类型
【发布时间】:2016-10-08 16:30:20
【问题描述】:

我正在尝试使用 json 模式定义可重用的枚举类型(phoenixnap/springmvc-raml-plugin 的输入)。

{
  "$schema": "http://json-schema.org/schema",
  "definitions": {
    "MyEnum": {
      "type": "object",
      "javaType": "foo.bar.MyEnum",
        "properties": {
          "Value": { "enum": [ "OPT_1", "OPT_2" ] }
        },
      "required": ["Value"]
    }
  }
}

有没有办法在没有“Value”属性的情况下定义架构并直接使用枚举值?

【问题讨论】:

    标签: java json schema


    【解决方案1】:

    顶级枚举的模式定义

    {
      "$schema": "http://json-schema.org/schema",
      "definitions": {
      "MyEnum": {
        "type": "object",
        "javaType": "foo.bar.MyEnum",
        "enum": [ "OPT_1", "OPT_2" ]
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2021-04-29
      • 2015-10-15
      • 2019-06-25
      • 1970-01-01
      • 1970-01-01
      • 2017-06-03
      • 1970-01-01
      • 2022-01-16
      • 2019-01-18
      相关资源
      最近更新 更多