petrochenko-pavel-a / raml-js-parser2-issues

0 stars 0 forks source link

Expand annotations to allow annotating scalar-valued nodes #49

Closed VasiliyLysokobylko closed 8 years ago

VasiliyLysokobylko commented 8 years ago

It is often useful to annotate scalar-valued nodes, e.g. baseUri. Since annotations are applied as extra key-value pairs to nodes that accept key-value pairs already (i.e. map-valued nodes), they cannot currently be applied to scalar-valued nodes.

For the scope of this proposal, scalar-valued nodes are ones that cannot already be expressed as maps, e.g. the type node can take a scalar value or a map value, so it is not covered in this proposal.

The proposal is to allow any scalar-valued node, which is normally expressed as

baseUri: http://www.example.com/api

to alternatively be expressed as a map, with the single allowed key value:

baseUri:
  value: http://www.example.com/api

and then annotations may be applied as usual, e.g.

baseUri:
  value: http://www.example.com/api
  (redirectable): true

As part of this proposal, the list of allowedTargets for annotation type declarations is expanded to include all scalar-valued nodes, such as baseUri, description, type, etc. The spec need not list them explicitly in the allowedTargets table, but may refer to a detailed table of all scalar-valued nodes.

VasiliyLysokobylko commented 8 years ago

https://github.com/raml-org/raml-spec/issues/225