Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support optionality for all the things #131

Open
econchick opened this issue Apr 16, 2017 · 3 comments
Open

Support optionality for all the things #131

econchick opened this issue Apr 16, 2017 · 3 comments

Comments

@econchick
Copy link
Contributor

In RAML 0.8, only methods w/i resource types were optional, denoted with a question mark (e.g. get?.

In RAML 1.0, a lot more can be optional. We should figure out a sane approach to parsing and reflecting how a named attribute is optional.

@sichvoge
Copy link

I don't think that this is true. The spec states

To accommodate this need, a resource type definition MAY append a question mark ("?") suffix to the name of any method to declare the method as optional, resulting in the following behavior:

@econchick
Copy link
Contributor Author

@sichvoge Under the General headline, it says:

A trailing question mark, for example description?, indicates an optional property.

There's also many examples of non-methods having trailing question marks. For instance, in the table listing nodes for the Root of a RAML file.

@sichvoge
Copy link

sichvoge commented Jun 1, 2017

OH, maybe it's a bit confusing first; but that general headline only talks about optional nodes in RAML. That means, when we say

A trailing question mark, for example description?, indicates an optional property.

It really mean, whenever you see (inside the specification document) a node with a question mark; it is an optional node. For example:

#%RAML 1.0
title: A

description: Test
#%RAML 1.0 
title: A

Both examples are valid, since description is an optional node. On the other hand, title is a required node and leaving it out is not valid.

When you said "In RAML 0.8, only methods w/i resource types were optional, denoted with a question mark (e.g. get?).", you referred to a mechanism that is available in a resource type definition. Marking a method "optional" does nothing else than having you to declare it explicitly on the resource to apply it. For example:

#%RAML 1.0
title: A

resourceTypes:
  collection:
    get:
    post?:

/resource:
  type: collection
/resource1:
  type: collection
  post:

In that case, /resource has only one HTTP method get, but resource1 has post and get.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants