apiaryio / api-blueprint

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

Nullable type doesn't work within method declaration #320

Closed danilvalov closed 8 years ago

danilvalov commented 8 years ago

I'm trying to use nullable type in my mson following sample in the documentation, but it fails with semantic error.

Please help me to figure out what's wrong with my mson and how to make correct documentation for my use case?

Thanks!

kylef commented 8 years ago

Hi @danilvalov, Apiary isn't using the latest version of the API Blueprint Parser which adds support for nullability.

Apiary does have a beta for improve attributes rendering, which includes support for nullability. You can find more about the beta at https://github.com/apiaryio/api-blueprint/issues/191#issuecomment-178044764 along with how to join it.

Regards,

Kyle

kylef commented 8 years ago

I just want to point out that this has now been deployed to Apiary (without a beta).

As an example, you can use nullable like the following:

+ Response 200 (application/json)
    + Attributes
        + example1 (string, optional, nullable) - An example optional nullable string
        + example2: value (string, optional, nullable) - An example optional nullable string with a sample value

Where this would result in an example payload of the following:

{
  "example1": null,
  "example2": "value"
}

Along with the following JSON schema:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "example1": {
      "type": [
        "string",
        "null"
      ],
      "description": "An example optional nullable string"
    },
    "example2": {
      "type": [
        "string",
        "null"
      ],
      "description": "An example optional nullable string with a sample value"
    }
  }
}

The table of attributes in Apiary doesn't yet mention that the value is nullable, but this is coming.

screen shot 2016-06-20 at 17 46 45
patricksmms commented 4 years ago

This is now visible, in ApiaryUI: image