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

0 stars 0 forks source link

The "parameters" property in RAML 1.0 annotation type declarations is flawed #62

Closed VasiliyLysokobylko closed 8 years ago

VasiliyLysokobylko commented 8 years ago

In annotations one may want to have something to the right of the colon:

(myAnnotation): something

The way to specify the format of that "something" is through a parameters property in the annotation type declaration. According to the spec, that property takes a map of parameter names to types, so e.g.

annotationTypes:
  myAnnotation:
    parameters:
      p1: string
      p2: string

then allows annotations of the following format:

(myAnnotation):
  p1: my value of p1
  p2: my value of p2

But then the "something" could never be a basic type. The examples and the current parser implementation seem to imply that there is a hack for this: to use the parameter name value. So

annotationTypes:
  myAnnotation:
    parameters:
      value: string

allows the following annotation:

(myAnnotation): my value

This is IMHO a bad design, that could be fixed by replacing the parameters property with a value property. This property would expect a type reference or inline type as value so that the examples above would look like this:

annotationTypes:
  mySimpleAnnotation:
    value: string
  myComplexAnnotation:
    value:
      type: object
      properties:
        p1: string
        p2: string
VasiliyLysokobylko commented 8 years ago

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

petrochenko-pavel-a commented 8 years ago

This is implemented already (both in workbench and parser)