How to override MSON Sample values

708 views Asked by At

If I define a resource type with sample values, how can I override them for specific examples?

I tried this, but the rendered output ignores the Body and uses the global Sample instead.

### Read item [GET]
+ Response 200
    + Attributes (A, fixed-type)
    + Body

            { "name": "Hello", "bs": [{ "key": "value" }]}

# Data Structures
## A
+ name: foo(string, required)
+ bs (array[B], optional, fixed-type)
    + Sample
        + key: baz
        + key: bat
## B
+ key (string, optional)

Bizarrely, if you remove the sample values from the schema it correctly uses the Body for Request but for Response it has every string parameter as "Hello, world!", every number as 1, etc.

2

There are 2 answers

11
Muranamo On

I know this is an old thread, but just came across this issue and wanted to elaborate on the above answer. In order to get this working, I had to set DRAFTER_EXAMPLES in the environment, and then execute the aglio command; for example:

set DRAFTER_EXAMPLES=true

aglio -i apiary.apib -o output.html
0
Ilya Petukhov On

if you use aglio and you get

string parameter as "Hello, world!", every number as 1

than use DRAFTER_EXAMPLES environment variable: DRAFTER_EXAMPLES=true aglio -i apiary.apib