Open carowright opened 6 years ago
Hi Caro. It is defined, but not very clear indeed. Look into the first example of yours. the important line is:
comment: nil | string # equivalent to ->
# comment: string?
As you can see, comment: string?
is syntactic sugar and equivalent to comment: nil | string
.
I am sure we could clarify this a bit more. If you have time, may I ask you to send us a PR?
@sichvoge seems to be a bug.
according to nil | string
equals to comment?
means that comment
is optional, but it should be not like that.
technically comment
must be required, but can have as null as string values as well.
@alvassin: comment?
and string?
are two different things.
comment: nil | string
is equivalent to:
comment: string?
and means that the value of comment
can be null
whereas:
comment?: string
means that comment
is not required.
We could also have:
comment?: string?
which would mean that comment
can be null
and is also not required.
@jstoiko I'm trying to create a required, nullable property with a user-defined type in a separate file. For some reason, my IDE (MuleSoft Anypoint Studio) considers this invalid. Am I trying to do something invalid or is my IDE incorrect?
Response.raml
#%RAML 1.0 DataType
type: object
properties:
error: nil | !include Error.raml
Error.raml
#%RAML 1.0 DataType
type: object
properties:
code: string
message: string
@sheamunion: you cannot use an !include
in a union. If you’d like to discuss this further though, could you please create a separate issue. This is a different topic. Also, feel to join our (Slack community)[https://raml.org/slack]!
Thanks! Done and done.
There is an example in nil type section that adds a question mark on the property type side:
As it's mentioned in the comment, it's the same as:
This example can be found in here. Besides this example there is no mention of how this construction works. So, either the example is invalid or this construction needs to be defined somewhere in the spec.