danielgtaylor / aglio

An API Blueprint renderer with theme support that outputs static HTML
4.75k stars 481 forks source link

Implement support for null / nullable fields #177

Open obihann opened 9 years ago

obihann commented 9 years ago

MSON is being updated to include support for null values using a 'nullable' attribute. Aglio should support this.

danielgtaylor commented 9 years ago

@obihann is there anything specific you would like to see? I'm planning to show tables/trees of data structures and it would include information like whether a property is required or nullable.

obihann commented 9 years ago

As long as the output follows the specs I think were fine, since they are not yet merged into the official MSON spec, you can find the example here as well as rendering examples here.

The actual change to the spec will be:

3.5.3 Type Attribute

Defines extra attributes associated with the implementation of a type.

  • required - instance of this type is required
  • optional - instance of this type is optional (default)
  • fixed - instance of this type structure and values are fixed
  • nullable - instance of this type Value MAY be unset (e.g. null or nil)
  • sample - Alternate way to indicate a [Value][] is a sample. See [Sample][].
  • default - Alternate way to indicate a [Value][] is a default. See [Default][].

A sample Type Attribute is mutually exclusive with default.

This is going to be merged to MSON master as soon as their is a new release of [drafter][https://github.com/apiaryio/drafter] which has a milestone so we can track when it is ready for release.

Thanks!

justinabrahms commented 9 years ago

This milestone 1.1.0 is now closed.

danielgtaylor commented 9 years ago

@obihann @justinabrahms there is now some support of nullable properties in Aglio. The generated JSON schema will show that it allows a null type. For example:

+ field (nullable)

Generates

{
  "type": ["string", "null"]
}

The attributes aren't shown in a nice table yet (that is underway at the moment but is quite a large task), so that's coming soon as part of #103.

Skeen commented 8 years ago

+1