问题
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