RAML 1.0: Using type expressions in type definitions


Here’s a fragment RAML document that defines a (not very interesting) type:

        type: string | integer

Should this fragment be considered equivalent, or is it invalid?

    RestrictedScalar: string | integer

I don’t see any examples quite like this in the spec, but the spec does state “Type expressions can be used wherever a type is expected.” (first paragraph at https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md/#type-expressions)


That is perfectly valid! What you did in the second example is to use the short form if you don’t specify any additional type facets like properties or others. If the type facet is the only one you define, you can shorten the syntax from the first example to the second.

So in short, both are equivalent! :smiley:


Excellent! I’ll see about getting this handled in ramlfications today. Not being able to spell it this way would make the RAML for my own application much less readable.