Reusable enum types in json schema

馋奶兔 提交于 2021-02-20 03:45:13

问题


I'm trying to define reusable enum types with json schema (input for 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"]
    }
  }
}

Is there a way to define the schema without the "Value" property and use the enum values directly?


回答1:


schema definition with top level enum

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


来源:https://stackoverflow.com/questions/37701924/reusable-enum-types-in-json-schema

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!