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

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

Open quilicicf opened this issue 9 years ago • 1 comments

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 parser to validate the value of version against the parameter's schema or
  • the parsing to fail if version is explicitly declared in baseUriParameters

Spec pointer

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 avatar Aug 19 '16 08:08 quilicicf

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

quilicicf avatar Aug 22 '16 15:08 quilicicf