Haran
Haran

Reputation: 1130

How to reference enum value in API Blueprint(MSON)

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)

Upvotes: 5

Views: 3927

Answers (1)

Jonny
Jonny

Reputation: 16338

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

Upvotes: 5

Related Questions