api-blueprint icon indicating copy to clipboard operation
api-blueprint copied to clipboard

Apiary: Fields not displayed in json Body

Open regmimilan opened this issue 8 years ago • 3 comments

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.

  • Request (application/json)

    • Headers

        REW3-UserId: string
      
    • Attributes (Add Preference)

  • Response 202

    • Attributes (JSONResponse)
      • preferenceId (number)

In Data Structure

Add Preference

  • name(string, optional) - preference name
  • min_price(number, optional) - minimum amount of Property
  • max_price(number, optional) - maximum amount of Property
  • designed_move_in_date(string, optional) - date format must be as in 2014-11-11T08:40:51.620Z
  • cities(array[string], optional) - List of Preference Cities
  • max_lot_size(number, optional) - Maximum empty land size
  • min_lot_size(number, optional) - Minimum empty land size

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.

regmimilan avatar May 11 '17 10:05 regmimilan

@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

kylef avatar May 11 '17 10:05 kylef

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

regmimilan avatar May 11 '17 10:05 regmimilan

@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.

kylef avatar May 11 '17 10:05 kylef