Closed a-thaler closed 10 years ago
My guess is that this is a YAML tokenization thing: the RAML document must be valid YAML and then the RAML-specific semantics are overlaid. So perhaps the improvement needed in the RAML documentation is to make that more explicit at the top, rather than reproducing all the documentation of the YAML standard itself. Makes sense? On May 23, 2014 7:26 AM, "Andreas Thaler" notifications@github.com wrote:
Assumed I want to use a pattern inside my uri by having a definition like that:
/testPattern{uriParam} : uriParameters: uriParam: type: string pattern: ^[a-z]*$
This will work fine and the raml file can be parsed. When changing the pattern expression to
pattern: [a-z]*
it will fail with:
org.yaml.snakeyaml.scanner.ScannerException: while scanning an alias in 'reader', line 14, column 21: pattern: [a-z] ^ expected alphabetic or numeric character, but found but found in 'reader', line 14, column 22: pattern: [a-z] ^
at org.yaml.snakeyaml.scanner.ScannerImpl.scanAnchor(ScannerImpl.java:1439) at org.yaml.snakeyaml.scanner.ScannerImpl.fetchAlias(ScannerImpl.java:918) at org.yaml.snakeyaml.scanner.ScannerImpl.fetchMoreTokens(ScannerImpl.java:366) at org.yaml.snakeyaml.scanner.ScannerImpl.checkToken(ScannerImpl.java:226) at org.yaml.snakeyaml.parser.ParserImpl$ParseBlockMappingKey.produce(ParserImpl.java:558) at org.yaml.snakeyaml.parser.ParserImpl.peekEvent(ParserImpl.java:158) at org.yaml.snakeyaml.parser.ParserImpl.checkEvent(ParserImpl.java:143) at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:226) at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:155) at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:233) at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:155) at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:233) at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:155) at org.yaml.snakeyaml.composer.Composer.composeMappingNode(Composer.java:233) at org.yaml.snakeyaml.composer.Composer.composeNode(Composer.java:155) at org.yaml.snakeyaml.composer.Composer.composeDocument(Composer.java:122) at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:105) at org.yaml.snakeyaml.Yaml.compose(Yaml.java:564) at org.raml.parser.visitor.YamlDocumentBuilder.build(YamlDocumentBuilder.java:84) at org.raml.parser.visitor.YamlDocumentBuilder.build(YamlDocumentBuilder.java:94)
Quoting the expression will work fine as well:
pattern: "[a-z]*"
It seems that the brackets are causing a problem when being the first character of expression. In the specification nothing is defined about escaping the expression in certain conditions.. "The pattern MAY be enclosed in double quotes for readability and clarity."
Would be nice if any expression will be supported without the need of escaping it. If not possible the specification should get adjusted.
— Reply to this email directly or view it on GitHubhttps://github.com/raml-org/raml-java-parser/issues/26 .
I agree, it is not a valid YAML document anymore and so the yaml tokenizer will fail. As in the spec it is defined that a raml file must be a valid yaml document (at least implicitly) it is fine and ticket can be closed. However a hint in the spec on using proper yaml escaping would be nice :) Thanks for the fast answer!
Assumed I want to use a pattern inside my uri by having a definition like that:
This will work fine and the raml file can be parsed. When changing the pattern expression to
it will fail with:
Quoting the expression will work fine as well:
It seems that the brackets are causing a problem when being the first character of expression. In the specification nothing is defined about escaping the expression in certain conditions.. "The pattern MAY be enclosed in double quotes for readability and clarity."
Would be nice if any expression will be supported without the need of escaping it. If not possible the specification should get adjusted.