Enum 枚举
1. 结构声明
- TS Declaration
- JSON Schema
class Enum extends BaseNode {
name: string = '';
label: string;
description: string;
enumItems: Array<EnumItem>;
}
{
"type": "object",
"properties": {
"composedBy": {
"type": "array",
"items": {
"type": "string"
}
},
"name": {
"type": "string"
},
"label": {
"type": "string"
},
"description": {
"type": "string"
},
"enumItems": {
"type": "array",
"items": {
"$ref": "#/definitions/EnumItem"
}
}
},
"required": [
"name",
"label",
"description",
"enumItems"
],
"additionalProperties": false
}
2. 节点示例
(1) 示例
AST 如下:
- JSON
- YAML
{
"concept": "Enum",
"name": "ProductStatus",
"label": "",
"description": "",
"enumItems": [
{
"concept": "EnumItem",
"value": "Listing",
"label": "上架"
},
{
"concept": "EnumItem",
"value": "Delisting",
"label": "下架"
}
]
}
concept: Enum
name: ProductStatus
label: ""
description: ""
enumItems:
- concept: EnumItem
value: Listing
label: 上架
- concept: EnumItem
value: Delisting
label: 下架
对应的代码如下:
- 文本化 NASL
@(
label = "",
description = "",
)
enum ProductStatus {
@(label = "上架")
Listing
@(label = "下架")
Delisting
}
(2) 带描述的示例
AST 如下:
- JSON
- YAML
{
"concept": "Enum",
"name": "ProductStatus",
"label": "商品状态",
"description": "表示商品状态的枚举",
"enumItems": [
{
"concept": "EnumItem",
"value": "Listing",
"label": "上架"
},
{
"concept": "EnumItem",
"value": "Delisting",
"label": "下架"
}
]
}
concept: Enum
name: ProductStatus
label: 商品状态
description: 表示商品状态的枚举
enumItems:
- concept: EnumItem
value: Listing
label: 上架
- concept: EnumItem
value: Delisting
label: 下架
对应的代码如下:
- 文本化 NASL
@(
label = "商品状态",
description = "表示商品状态的枚举",
)
enum ProductStatus {
@(label = "上架")
Listing
@(label = "下架")
Delisting
}