我正在使用API Blueprint和Agilo来呈现我的API文档。使用枚举类型时,我观察到一个奇怪的行为。没有显示已定义的枚举值的响应,而架构显示的是所有枚举值(预期的)以及声明的值(“星期一”-引用实际)。
数据结构部分
# Data Structures
## Days (enum[string])
+ `Monday`
+ `Tuesday`
+ `Wednesday`
+ `Thursday`
## ListEntry
- playOrder: 1 (number)
- Id: 37a21975a499494f03367 (string)
- programDay: `Tuesday` (Days)
## `sample-request-200`
- id: 58828b2941cc351348 (string)
- startDate: `2019-08-01T11:00:00.000Z` (string)
- endDate: `2019-08-05T11:55:59.000Z` (string)
- Language: `en-US` (string)
- entries: ListEntry (array[object])
API请求文档部分
+ Request
+ Headers
Content-Type: application/json
+ Attributes (sample-request-200)
实际
---- JSON Body ----
{
"playOrder": 1,
"Id": "37a21975a499494f03367",
"programDay": "Hello, world!" // Agilo shows "Hello,World" when some error occurred
}
-----Generated Schema-----
"programDay": {
"type": "string",
"enum": [
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Monday"
]
}
所需
---- JSON Body ----
{
"playOrder": 1,
"Id": "37a21975a499494f03367",
"programDay": "Monday"
}
-----Generated Schema-----
"programDay": {
"type": "string",
"enum": [
"Monday",
"Tuesday",
"Wednesday",
"Thursday"
]
}
关于如何在API蓝图(MSON)中使用已定义的枚举数据结构的任何想法。不确定如何在对象中引用枚举值。
以下引用枚举值是否正确?
- programDay: `Tuesday` (Days)