Nullable fields in RAML 1.0


#1

Hi,

I have a quick question regarding nullable fields in RAML 1.0.

I would think that the ? would mark a field as nullable, but it appears it is just an idiom of the required: false.

When I tried to set:

type: null | integer

I get an error in API workbench.

Would any one have any idea how to create a nullable field in RAML?

thanks
Neil


#2

The question mark is indeed an idiom for indicating if a property is required or not. It is not to mark if the property can have or cannot have a value. That’s done using null.

Did you install the API Workbench via APM or the code base? The team is currently working on the support for RC2/GA and will be able to push the final version to APM. Currently, you can basically install the RC2/GA version from its sources here.

I am using that version, and defining null works.


#3

I am using the current version 0.8.45 and cannot define null values.

I am defining property: userId: number | null

The link is now broken and cannot download the version “in which null values work”.

Any help would be appreciated.


#4

Hi @amir,

Null is a legacy type and has been replaced by nil (see here).


#5

Thanks a lot, did not know about the nil type.