How to reference enum value in API Blueprint(MSON)

3.8k views Asked by At

I'm using API Blueprint and Agilo to render my API documentation. When using enum type, I'm observing a weird behavior. The response is not shown with the defined enum value whereas the schema is showing all the enum values (which is expected) along with the declared value ('Monday'- Refer Actual) as well.

Data Structure section

# 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 Doc section

+ Request
+ Headers

        Content-Type: application/json

+ Attributes (sample-request-200)

Actual

---- 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"
              ]
            }

Desired

 ---- JSON Body ----
    {
      "playOrder": 1,
      "Id": "37a21975a499494f03367",
      "programDay": "Monday"
    }


-----Generated Schema-----  

"programDay": {
              "type": "string",
              "enum": [
                "Monday",
                "Tuesday",
                "Wednesday",
                "Thursday"
              ]
            }

Any idea on how to use the defined enum data structure in API blueprint (MSON). Not sure how to reference an enum value in the Object.

Is it right to use as below to reference an enum value?

- programDay: `Tuesday` (Days)
1

There are 1 answers

0
Jonny On

Structure:

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

Use like this:

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

Results:

enter image description here