raml-java-parser icon indicating copy to clipboard operation
raml-java-parser copied to clipboard

Example on array dataType is wrapped in a TypeInstanceProperty named 'example'

Open constint opened this issue 8 years ago • 0 comments

Ok case

If we have an example on an object type containing an array property, all is well : When parsing the following.

/example:
  post:
    body:
      application/json:
        properties:
          arrayProperty:
            type: array
            items: string
        example:
          arrayProperty:
          - x
          - y

We get from the body example : body.example().value() : {\narrayProperty: Array[x,y]\n} body.example().structuredValue().properties().get(0).name() : arrayProperty

Problematic case

If we have an example on an array, then the example is wrapped in an extra TypeInstanceProperty

/example:
  post:
    body:
      application/json:
        type: array
        items: string
        example:
        - x
        - y

We get from the body example : body.example().value() : Array[x,y] body.example().structuredValue().properties().get(0).name() : example

So to get access to the structured example I have to unwrap it by calling : body.example().structuredValue().properties().get(0).values(), and only then do I get the list of TypeInstance I was expecting.

Aha! Link: https://mulesoft-roadmap.aha.io/features/APIRAML-101

constint avatar Feb 17 '17 14:02 constint