Enum 枚举
结构声明
- TS Declaration
- Java Class
- JSON Schema
interface Enum {
"concept": "Enum", // 产品概念
"name": string, // 枚举名称
"label": string, // 枚举标题
"description": string, // 枚举描述
"enumItems": Array<EnumItem>, // 枚举值列表
}
class EnumTreeNode {
ConceptEnum concept; // 产品概念
String name; // 枚举名称
String label; // 枚举标题
String description; // 枚举描述
List<EnumItemTreeNode> enumItems; // 枚举值列表
}
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$ref": "#/definitions/Enum",
"definitions": {
"Enum": {
"type": "object",
"properties": {
"concept": {
"type": "string",
"const": "Enum"
},
"name": {
"type": "string"
},
"label": {
"type": "string"
},
"description": {
"type": "string"
},
"enumItems": {
"type": "array",
"items": {
"$ref": "#/definitions/EnumItem"
}
}
},
"required": [
"concept",
"name",
"label",
"description",
"enumItems"
],
"additionalProperties": false
}
}
}
示例
简单示例
- JSON
- YAML
{
"concept": "Enum",
"name": "Color",
"label": null,
"description": "颜色枚举",
"enumItems": []
}
concept: Enum
name: Color
label: null
description: 颜色枚举
enumItems: []
带枚举项
- JSON
- YAML
- Embedded in TS
{
"concept": "Enum",
"name": "Color",
"label": "颜色",
"description": "表示颜色的枚举",
"enumItems": [{
"concept": "EnumItem",
"value": "RED",
"label": "红"
},
{
"concept": "EnumItem",
"value": "GREEN",
"label": "绿"
},
{
"concept": "EnumItem",
"value": "BLUE",
"label": "蓝"
}]
}
concept: Enum
name: Color
label: 颜色
description: 表示颜色的枚举
enumItems:
- concept: EnumItem
value: RED
label: 红
- concept: EnumItem
value: GREEN
label: 绿
- concept: EnumItem
value: BLUE
label: 蓝
enum Color {
RED = '红',
GREEN = '绿',
BLUE = '蓝',
}