raml-spec icon indicating copy to clipboard operation
raml-spec copied to clipboard

Allow Dynamic, parameter-driven !includes

Open nohorbee opened this issue 10 years ago • 13 comments

The following syntax for !includes should be allowed in resource types and traits.

#%RAML 0.8
title: My Sample API
resourceTypes:
  - collection:
      get:
      post:
        body:
          example: !include <<resourcePathName!singularize>>.json

nohorbee avatar Aug 29 '14 13:08 nohorbee

+1

cybertk avatar Sep 02 '14 16:09 cybertk

+1

joetech avatar May 15 '15 17:05 joetech

We will not add support for this feature immediately in v1.0! Don't panic, it's just for this version ;)

sichvoge avatar Sep 30 '15 17:09 sichvoge

+1 Create traits and resourceTypes for reuse commons operations and after this, rewrite the operations again for include examples it's a lot of work...

aldhor avatar Nov 10 '16 13:11 aldhor

The problem is that !includes are resolved at YAML level where it does not know anything about parameters, since its a RAML construct. Unfortunately, thats not easy to solve without drastically changing how includes work.

sichvoge avatar Nov 22 '16 11:11 sichvoge

An idea would be to bring !include one level up and introduce it as part of the RAML syntax. That would give us the advantage to do what the OP ask for and also that there is no need for a specific YAML parser anymore.

sichvoge avatar Jan 23 '17 15:01 sichvoge

Any update on this? Would be a valuable improvement for the project I am working on right now.

InfopactMLoos avatar Mar 22 '17 09:03 InfopactMLoos

No direct update except that its definitely on the "idea" state and that we need to think about any implications bringing !include directly into the RAML syntax instead of a YAML extension.

I see more advantages doing that, but that's only me :)

sichvoge avatar Mar 22 '17 10:03 sichvoge

Ah YAML extension, I now understand what you meant with it being on the YAML level in the comments above. Because I could not find it in the YAML spec so did not really understand what you meant with it. Anyway, me and my company are using RAML more and more as we are turning processes into RAML microservies. And we would love to see this language evolve and become even better then it already is. Is there anything we can do to contribute to this feature request process?

InfopactMLoos avatar Mar 22 '17 10:03 InfopactMLoos

For this feature request, it is important to understand different scenarios and how + when parameters should be resolved. I believe that this is not an easy change.

sichvoge avatar Mar 22 '17 11:03 sichvoge

This is on futur spec?

It could be very helpful ! 👍

alex-lairan avatar Apr 26 '17 08:04 alex-lairan

We trying to figure out what the best way would be to do this. Most probably not a very easy task without changing some behavior.

sichvoge avatar Apr 26 '17 11:04 sichvoge

Any change?

Hit this as well and instead of doing resource types that are truly 'generic', had to duplicate quite a lot to get the required effect.

krodyrobi avatar Mar 01 '18 16:03 krodyrobi