raml-java-parser
raml-java-parser copied to clipboard
Example on array dataType is wrapped in a TypeInstanceProperty named 'example'
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