Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

Clarify nilable type syntax regarding unions #733

Merged
merged 3 commits into from
Apr 9, 2021
Merged

Conversation

jstoiko
Copy link
Contributor

@jstoiko jstoiko commented Aug 17, 2020

Closes #708

@jstoiko jstoiko changed the title Closes #708 Clarify nilable type syntax regarding unions Aug 17, 2020
@BlockLucas
Copy link

Hi!

Before in 1.0 there wasn’t any definition for this nilable sugar for references, just a comment in an example (here) for a scalar & a definition for properties (here).
For us is not a PATCH change.

To discuss a little further on this, as we previously talked a little in raml-org/raml-tck#138 with
this example:

types:
  TypeWithTrailing?:
    type: string
  TypeWithTrailing:
    type: int
  TestObject:
    type: object
    properties:
      prop: TypeWithTrailing?

If "prop" should reference type "TypeWithTrailing" (int), marking it as nilable.
How we should behave in cases like these:

types:
  TypeWithTrailing?:
    type: string
  TestObject:
    type: object
    properties:
      notnilable: TypeWithTrailing?

Under that logic, this should fail (because "TypeWithTrailing" doesn't exists), but "TypeWithTrailing?" becomes unreachable or unusable for this sugar

@jstoiko
Copy link
Contributor Author

jstoiko commented Sep 4, 2020

This was an obvious omission. This has also been extensively discussed before (see #569, #665).

To answer your question Re: what happens when a type name contains a trailing question mark, I think the referencing mechanism should first look at types with that name before inferring that it means | nil. The Property Declarations has an example of a "double question mark" key. Maybe we can add one for values too.

Copy link
Contributor

@dukesphere dukesphere left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggests avoiding use of terms like "in lieu of" and Latin abbreviations so that it is understood by a wider audience

versions/raml-10/raml-10.md Outdated Show resolved Hide resolved
versions/raml-10/raml-10.md Outdated Show resolved Hide resolved
@jstoiko jstoiko merged commit b8c2f4f into master Apr 9, 2021
@jstoiko jstoiko deleted the 708-nilable-props branch April 9, 2021 22:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Clarify nilable property alternative syntax
3 participants