3

我正在使用API BlueprintAgilo来呈现我的 API 文档。使用枚举类型时,我观察到一种奇怪的行为。响应未显示定义的枚举值,而架构也显示了所有枚举值(这是预期的)以及声明的值('Monday'-Refer Actual)。

数据结构部分

# 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) 中使用定义的枚举数据结构的任何想法。不知道如何在 Object 中引用枚举值。

如下使用来引用枚举值是否正确?

- programDay: `Tuesday` (Days)
4

1 回答 1

3

结构:

# Data Structures
## Device (enum)
+ `mobile`
+ `desktop`

像这样使用:

+ Request (multipart/form-data)
    + Attributes
        + `id`: abc (required)
        + `device` (Device)

结果:

在此处输入图像描述

于 2019-05-09T03:55:20.710 回答