raml-org / raml-tck

Test Compatibility Kit for RAML 1.0
http://raml-org.github.io/raml-tck/
8 stars 10 forks source link

relativeUriPathSegments is missing for resource in 1.0 #18

Closed xaka closed 8 years ago

xaka commented 8 years ago

RAML 0.8:

"relativeUri": "/media/recent",
"relativeUriPathSegments": [
  "media",
  "recent"
],

RAML 1.0:

"relativeUri": "/media/recent",
KonstantinSviridov commented 8 years ago

Actually, RAML spec does not say that API has "relativeUriPathSegments" property. But I do not see any reasons for not introducing it for sake of compatibility.

sichvoge commented 8 years ago

I am wondering how that get introduced in 0.8? @xaka

fmezas commented 8 years ago

this discussion is completely unnecessary.

the fact that the object returned by the raml parser includes any arbitrary property not defined in the raml spec hasn't got anything to do with the correctness of the parser:

RAML -> [ parser ] -> arbitrary representation of raml input

it's very likely that some of the properties will be there just for convenience and historical reasons. The objective of this task is to achieve as much compatibility with the output of the old parser in order to reuse existing tooling in the platform

with this new perspective, could you add the requested property?

KonstantinSviridov commented 8 years ago

@fmezas Sure, we'll add it.

sichvoge commented 8 years ago

@fmezas I d get your point, but failure in the past sometimes led us to decisions that no body understood. Someone looking at the spec and comparing it with the output WILL wonder why that is in. So what is the rationality to have it? What is this used for?

Not saying that I am against it, but just making decisions because it was there before does not get us anywhere if the thing that was there before is actually unnecessary. That would just lead us repeating the mistakes again. That is what I want to clarify here.

KonstantinSviridov commented 8 years ago

@xaka Do I understand it correct, that expected relativeUriPathSegments is as follows:

?

xaka commented 8 years ago

Here is what we do in raml-js-parser:

          pathParts = resource.relativeUri.split('\/');
          while (!pathParts[0] && pathParts.length) {
            pathParts.shift();
          }
          resource.relativeUriPathSegments = pathParts;

As you can see, we remove all empty segments, not only the first one.

KonstantinSviridov commented 8 years ago

Great, thanks!