raml-org / raml-java-parser

(deprecated) A RAML parser based on SnakeYAML written in Java
Other
174 stars 121 forks source link

Version base URI parameter can be explicitly declared and its value is not validated #235

Open quilicicf opened 8 years ago

quilicicf commented 8 years ago

Affects: 1.0.0

Issue

The reserved base URI parameter version can be explicitly declared in the base URI parameters. When it is, the value of #/version is not validated against the URI parameter's schema.

The parameter being reserved and its value being set, I'd expect either:

The version base URI parameter is reserved and it's value is The value of the root-level version node.

How to reproduce

RAML file

#%RAML 1.0

title: My API title
version: v3

baseUri: https://myapp.com/{version}
baseUriParameters:
  baseUriParameter:
    version: integer

Java file

package com.restlet.definitions.raml10.reader;

import org.raml.v2.api.RamlModelBuilder;
import org.raml.v2.api.RamlModelResult;

import static org.junit.Assert.fail;

public class Test {

    @org.junit.Test
    public void test() throws Exception {
        String savedRamlLocation = Test.class.getResource("fileName").toString();
        RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(savedRamlLocation);
        if (ramlModelResult.hasErrors()) {
            return;
        }

        fail("Should not pass parser validation");
    }
}

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

quilicicf commented 8 years ago

Also, shouldn't the parsing fail if the URI contains {version} but the field .version is unassigned ?