Api-blueprint: Nullable type doesn't work within method declaration

Created on 13 Apr 2016  ·  3Comments  ·  Source: apiaryio/api-blueprint

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!

Apiary.io Question

Most helpful comment

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

All 3 comments

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

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

This is now visible, in ApiaryUI:
image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

robbinjanssen picture robbinjanssen  ·  6Comments

alronlam picture alronlam  ·  4Comments

bennettellis picture bennettellis  ·  7Comments

pete001 picture pete001  ·  6Comments

BigBlueHat picture BigBlueHat  ·  3Comments