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

Resource.getResolvedUriParameters() does not return all inherited URI parameters and they are in unexpected order

Open benken-parasoft opened this issue 9 years ago • 2 comments

This method has two bugs.

Issue 1: It returns URI parameters for the current resources and only the immediately parent. This is contrary to the javadoc which says "all URI parameters defined in the resource hierarchy".

Issue 2: It returns the result in an unordered Map (HashMap). Instead, it should return the URI parameters in order (LinkedHashMap). This way, when iterating over the entries in the map, I get the parameters in order as they appear in the resource path.

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

benken-parasoft avatar Aug 06 '15 23:08 benken-parasoft

For example, take the below RAML. getResolvedUriParameters() won't return me all the parameters for "/artists/{artistId}/songs/{songId}". It would only return "songId" but not "artistId". I suspect the method was intended to recursively collect parameters from parent resources, but it isn't actually doing any recursion.


#%RAML 0.8
title: Simple path test
version: v3
baseUri: http://fakehost/some/base/path
/artists:
  post:
    responses:
      200:
        description: OK
  /{artistId}:
    uriParameters:
      artistId:
        type: integer
    get:
      responses:
        200:
          description: OK
    /songs:
      /{songId}:
        uriParameters:
          songId:
            type: integer
        get:
          responses:
            200:
              description: OK

benken-parasoft avatar Aug 10 '15 16:08 benken-parasoft

Resource.getResolvedUriParameters() does not exist in raml-parser-2. So, this may no longer be applicable.
However, Resource.getUriParameters() no longer returns parameterized path segments that are not explicitly defined which used to work in the original raml-parser. See https://github.com/raml-org/raml-java-parser/issues/201

benken-parasoft avatar Nov 23 '16 21:11 benken-parasoft