Questions on Java RAML Parser


#1

Hi,

I’ve started to use the java-raml-parser and have some questions / issues:

  1. queryParameters in traits with parameterized descriptions seem to get a null description; parsing the last example before the Security section in the spec works fine, but querying the description of the “access_token” and “numPages” query parameters introduced by the “secured” and “paged” traits returns null
  2. the formParameters exposed by a mediaType is a map of parameter name to list of FormParameter objects - instead of just a single FormParameter object (the spec seems to say that a name is mapped to a single set of parameter attributes)
  3. When parsing the RAML for GitHub at http://www.apihub.com/github/api/github-api-v3/github-api-v3.raml I get the following exception (which might be due to an invalid RAML of course):

java.lang.IllegalArgumentException: Null property value for 'application/vnd’
at org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1622)
at org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:1677)
at org.raml.parser.utils.ReflectionUtils.setProperty(ReflectionUtils.java:71)
at org.raml.parser.builder.PojoTupleBuilder.buildValue(PojoTupleBuilder.java:99)
at org.raml.parser.visitor.YamlDocumentBuilder.onMappingNodeStart(YamlDocumentBuilder.java:133)
at org.raml.parser.visitor.RamlDocumentBuilder.onMappingNodeStart(RamlDocumentBuilder.java:62)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:53)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:138)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:101)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:56)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:138)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:101)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:56)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:138)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:101)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:56)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:138)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:101)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:56)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:138)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:101)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:56)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:138)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:101)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:56)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:138)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:101)
at org.raml.parser.visitor.NodeVisitor.visitDocument(NodeVisitor.java:129)
at org.raml.parser.visitor.YamlDocumentBuilder.build(YamlDocumentBuilder.java:76)
at org.raml.parser.visitor.YamlDocumentBuilder.build(YamlDocumentBuilder.java:111)
at org.raml.parser.visitor.YamlDocumentBuilder$build.call(Unknown Source)

  1. For the instagram RAML at http://www.apihub.com/instagram/api/instagram-api/instagram-api.raml I get another exception:

java.lang.ClassCastException: org.yaml.snakeyaml.nodes.MappingNode cannot be cast to org.yaml.snakeyaml.nodes.ScalarNode
at org.raml.parser.builder.ScalarTupleBuilder.buildValue(ScalarTupleBuilder.java:24)
at org.raml.parser.visitor.YamlDocumentBuilder.onMappingNodeStart(YamlDocumentBuilder.java:133)
at org.raml.parser.visitor.RamlDocumentBuilder.onMappingNodeStart(RamlDocumentBuilder.java:62)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:53)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:138)
at org.raml.parser.visitor.NodeVisitor.visitSequence(NodeVisitor.java:159)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:146)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:101)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:56)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:138)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:101)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:56)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:138)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:101)
at org.raml.parser.visitor.NodeVisitor.visitMappingNode(NodeVisitor.java:56)
at org.raml.parser.visitor.NodeVisitor.visit(NodeVisitor.java:138)
at org.raml.parser.visitor.NodeVisitor.doVisitMappingNode(NodeVisitor.java:101)
at org.raml.parser.visitor.NodeVisitor.visitDocument(NodeVisitor.java:129)
at org.raml.parser.visitor.YamlDocumentBuilder.build(YamlDocumentBuilder.java:76)
at org.raml.parser.visitor.YamlDocumentBuilder.build(YamlDocumentBuilder.java:111)
at org.raml.parser.visitor.YamlDocumentBuilder$build.call(Unknown Source)

Thanks for any insights!

/Ole

SmartBear Software


#2

Hi Ole,

I’ll let the Java parser folks respond to most of this, but regarding 2): the spec allows for a single named parameter property (whether a formParameter or other kind of parameter) to have a value that’s a list, allowing for different data types for that parameter’s value. See the section on “Named Parameters With Multiple Types”. So a parameter called “file” could be of type string or of type file, to cite the example in the spec. That’s probably why the parser always returns a list.

The RAML you cite above seems valid, so again let’s see what the Java parser folks say…

Thanks,
Uri


#3

Hi Uri,

Thanks for the clarification on the parameters-with-multiple-types - makes sense to me. Looking forward to feedback for the other items

regards!

/Ole


#4

Hi Ole, a quick comment on #3. Looks like the example has a small error. In the line 16381 there should be an example (is declared as if the example is about to follow “example : |”), but there is no example. Not saying that is the cause of the problem, but maybe could be related.

Fede


#5

Fede has the eyes of a hawk. Nice catch!

The parser seems to be complaining about something within an application/vnd(.something) node rather than your observation that’s within an application/json node, so that’s probably something else – maybe it’s not happy with the media type application/vnd.github.v3 having periods in it?


#6

Hi Ole,

  1. in the spec example you mention the queryParameters declarations are not correct.

For example instead of the following:

traits:
  - secured:
      queryParameters:
        <<tokenName>>: A valid <<tokenName>> is required

it should be:

traits:
  - secured:
      queryParameters:
        <<tokenName>>:
          description: A valid <<tokenName>> is required	    

I’ve already sent a pull request to address it:
https://github.com/raml-org/raml-spec/pull/ 22
(note: I had to break the url adding a space before “22” because otherwise would attach an image to the message and my user cannot submit posts with images)

  1. besides the error in the RAML file that Federico mentioned, there’s a bug in the parser that cannot process keys with dots, parentheses and sqare brackets.

The one that’s causing problems is at line 19654:

application/vnd.github.v3:

github issue: #2
(note: cannot paste the link because I cannot submit more than 2 links! )

  1. the java parser does not support passing parameters to security schemes yet.

github issue: #3

Both 3 & 4 will be fixed soon.

Thanks,
Santiago


#7

Hi Santiago,

thanks for all this - I’ve fixed the example locally and all works fine… looking forward to the other fixes, I’ll keep an eye on the repo.

regards!

/Ole


#8

And I’ve enabled more liberal settings on this forum so it’s not so hard to put in links and such.