【发布时间】:2017-04-06 00:28:24
【问题描述】:
我正在使用 API 蓝图记录一个 API,并且我有几个端点使用相同的枚举类型和相同的值。我不想在使用此枚举的每个点重复所有值,而是将其放在数据结构部分中,并对其进行引用,从而使其干燥。但是,我无法从文档中弄清楚如何将枚举放入数据结构部分。我可以很好地处理对象,但是当我在数据结构部分声明枚举时,它似乎忽略了指定的成员。
这是我现在拥有的一个(非常做作的)示例(不是 DRY):
### Some Request [GET]
+ Parameters
+ name: `sample` (string) - the name
+ type: `A` (enum[string]) - the type
+ Members
+ A
+ B
+ C
### Another Request [GET]
+ Parameters
+ address: `123 St.` (string) - the address
+ type: `B` (enum[string]) - the same type as above
+ Members
+ A
+ B
+ C
这就是我想做的事情:
### Some Request [GET]
+ Parameters
+ name: `sample` (string) - the name
+ type: `A` (The Type) - the type
### Another Request [GET]
+ Parameters
+ address: `123 St.` (string) - the address
+ type: `A` (The Type) - the type
# Data Structures
## The Type (enum[string])
+ Members
+ A
+ B
+ C
我已经尝试了这种语法的一些变体,但都没有运气。当然,我完全有可能只是找错了树,还有一种完全不同的方法可以让重复的枚举变干。
【问题讨论】:
标签: enums apiblueprint