apiaryio / api-blueprint

API Blueprint
https://apiblueprint.org
MIT License
8.63k stars 2.14k forks source link

Invalid value for 'boolean' type in nested request body on apiary.io #453

Closed ir-fuel closed 4 years ago

ir-fuel commented 4 years ago

The following gives me a warning for the subscription attribute, but not for the testBool attribute, and I have no idea why

## Collection [/user]

### Update user profile [PATCH /user/{id}]

+ Parameters
    + id (string) - Id of the user

+ Request 

    + Attributes (object)
        + testBool (boolean)
        + arr (array[object])
            + id (string)
            + subscription (boolean)

    + Body

            {
            }

+ Response 204
kylef commented 4 years ago

The syntax for placing items in array is as follows:

+ Attributes (array)
    + hello (string)
    + true (boolean)
    + (object)
        + key: value

Which equates to the following structure in JSON:

[
  "hello",
  true,
  {
    "key": "value"
  }
]

The line from your API Blueprint + subscription (boolean) is stating that you want a boolean, with the value "subscription" inside the array. As "subscription" is not a valid boolean (it is not true or false, the warning is emitted).

Instead, I think you are intending to wrap these array values in an object, for example an object with a key id and another with subscription. To do this in MSON you would write the following:

+ Attributes
    + arr (array, fixed-type)
        + (object)
            + id (string)
            + subscription (boolean)