drafter icon indicating copy to clipboard operation
drafter copied to clipboard

JSON Visitor should use `sample` value for rendering JSON in array

Open kylef opened this issue 7 years ago • 2 comments

For example, if I want to reference another data structure inside an array of fixed-type. I'd like to provide multiple examples to be rendered in the JSON array example.

# API

## GET /users

+ Response 200 (application/json)
    + Attributes
        + users (array[User], fixed-type)
            + Sample
                + (User)
                    + username: doe
                + (User)
                    + username: tim

## Data Structures

### User

+ username: kyle

The Sample section is ignored when it comes to rendering a JSON body and I think the sample should be included.

Current Behaviour

{
  "users": [
    {
      "username": "kyle"
    }
  ]
}

Expected Behaviour

{
  "users": [
    {
      "username": "doe"
    },
    {
      "username": "tim"
    }
  ]
}

kylef avatar Nov 08 '17 13:11 kylef

The same problem exists for objects as well as array.

kylef avatar Dec 23 '17 22:12 kylef

Another case to reproduce:

+ Response 200 (application/json)
    + Attributes
        + location (array, fixed)
            + `43.3` (number, sample)
            + `-8.41` (number, sample)

kylef avatar Apr 19 '18 22:04 kylef