apiaryio / api-blueprint

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

Apiary: Fields not displayed in json Body #394

Open regmimilan opened 7 years ago

regmimilan commented 7 years ago

I have done the following:

Create a New Preference [POST /preferences]

Accepts json request with preference object and creates preference, returns preference id after successful creation.

In Data Structure

Add Preference

In Response Body { "cities": [] }

But I expect to get all the fields of Add Preference as I have called Add Preference while creating the Preference.

kylef commented 7 years ago

@regmimilan You have not included any sample values, and the attributes are optional and thus they are not included in the rendered JSON example. If you make them either required, or attach sample values they should show up.

For example:

## Add Preference
+ name: Test (string, optional) - preference name
+ `min_price`: 1.99 (number, optional) - minimum amount of Property
+ `max_price`: 99.99 (number, optional) - maximum amount of Property
+ `designed_move_in_date`: `2014-11-11T08:40:51.620Z` (string, optional) - date format must be as in 2014-11-11T08:40:51.620Z
+ cities: London, Prague (array[string], optional) - List of Preference Cities
+ max_lot_size: 1000 (number, optional) - Maximum empty land size
+ min_lot_size: 1 (number, optional)  - Minimum empty land size
regmimilan commented 7 years ago

@kylef cities is displayed which do not include sample value neither it is a required field but other fields are not displayed.

kylef commented 7 years ago

@regmimilan Non primitive types such as array and object are rendered differently because they may contain other value types inside them. I may be wrong, but I think this is down to an implementation detail for the API Blueprint parser, it doesn't recursively check inside the type to check if there are values anywhere inside.