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

URI parameters should not allow '/' in default, enum & example

Open quilicicf opened this issue 9 years ago • 0 comments

Affects: 1.0.0

Issue

URI parameters should never contain slashes. The parser could check that this rule in enforced in URI parameters attributes:

  • default
  • example(s)
  • enum

Spec pointer (9th paragraph)

To avoid ambiguous matching, the values matched by URI parameters MUST NOT contain slash (/) characters. In the first example in this section, /jobs/123 is a URI (relative to the baseUri) that matches the /{jobId} resource nested within the /jobs resource, but the URI /jobs/123/x does not match any resource.

How to reproduce

RAML file

#%RAML 1.0
title: Resources with query parameters
/invalid/{first}:
  uriParameters:
    first:
      default: "invalid/value"
      enum: [ "invalid/value" ]
      example: "invalid/value"
  /{second}:
    uriParameters:
      second:
        examples:
          whatever: "invalid/value"

Java file

package com.restlet.definitions.raml10.reader;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.raml.v2.api.RamlModelBuilder;
import org.raml.v2.api.RamlModelResult;
import org.raml.v2.api.model.v10.api.Api;

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-120

quilicicf avatar Aug 19 '16 09:08 quilicicf