aglio icon indicating copy to clipboard operation
aglio copied to clipboard

nullable members weird rendering behaviour

Open CameronLonsdale opened this issue 8 years ago • 5 comments

I have the following data structures defined

### LocationStruct (object)
+ country: Australia (CountryStruct)
+ city: Sydney (string)
+ latitude (number, nullable)
+ longitude (number, nullable)

### CountryStruct (object)
+ name: Australia (string)
+ code (string, nullable)

And the use case for this data is the following

+ Request (application/json)
    + Attributes (LocationStruct)

This renders to the following JSON

{
  "country": {
    "name": "Australia",
    "code": "Hello, world!"
  },
  "city": "Sydney",
  "latitude": 1,
  "longitude": 1
}

I was expecting code, latitude and longitude to have the value null, as a sample value was not specified for them.

However, when I change the CountryStruct to be empty. eg.

### CountryStruct (object)

The following is rendered.

{
  "country": {},
  "city": "Sydney",
  "latitude": null,
  "longitude": null
}

Fairly strange behaviour. The functionality I'm looking for is to have the value null be rendered when no sample value is given to an objects member.

CameronLonsdale avatar Dec 19 '16 04:12 CameronLonsdale

Please sort this out. It's so infuriating that all optional members in the schema get instantiated as "Hello World!", 1, etc. instead of using the actual Body I have supplied.

See also http://stackoverflow.com/q/41986351/476716

OrangeDog avatar Feb 02 '17 11:02 OrangeDog

Here's the source of this behavior https://github.com/danielgtaylor/aglio/blob/olio-theme/src/example.coffee#L17

stipsan avatar May 28 '17 20:05 stipsan

Looks like you can disable it by setting DRAFTER_EXAMPLES=true. Like so: DRAFTER_EXAMPLES=true aglio -i apiary.apib.

stipsan avatar May 28 '17 20:05 stipsan

DRAFTER_EXAMPLES=true does nothing for me. Super frustrating as I was seeing the samples I put in the blueprints and now I only see the Hello, World! stuff.

optimuspaul avatar Aug 06 '18 19:08 optimuspaul

@optimuspaul looks like #177 and #304 my be relevant. PR is sitting idle.

brendensoares avatar Sep 21 '18 05:09 brendensoares