aglio
aglio copied to clipboard
nullable members weird rendering behaviour
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.
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
Here's the source of this behavior https://github.com/danielgtaylor/aglio/blob/olio-theme/src/example.coffee#L17
Looks like you can disable it by setting DRAFTER_EXAMPLES=true
.
Like so: DRAFTER_EXAMPLES=true aglio -i apiary.apib
.
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 looks like #177 and #304 my be relevant. PR is sitting idle.