5

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)
Haran
  • 1,040
  • 2
  • 13
  • 26
  • Is it working in apiary.io editor? The Aglio is unmaintained now, so it might be lacking in support of API Blueprint features https://github.com/danielgtaylor/aglio/commit/0cef09ab83d680689bcadf53aa45fc7bca3b5af3 – Honza Javorek Jan 23 '19 at 11:15
  • Even in apiary.io editor the enum values are duplicated as like Agilo. But the defined value is getting displayed in the JSON response. – Haran Jan 25 '19 at 08:49
  • Any progress on this? Just stumped into this also. – Jonny May 09 '19 at 03:42

1 Answers1

5

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

Jonny
  • 15,955
  • 18
  • 111
  • 232