raml-org / raml-js-parser

(deprecated) A RAML parser based on PyYAML written in CoffeScript and available for use as NodeJs module or in-browser.
195 stars 53 forks source link

example: !include examples/<<resourcePathName>>-200.json not working #150

Closed inspell closed 8 years ago

inspell commented 9 years ago

This type of inclusion is not working in a resource type.

I have a master file for resource types which I include in the main RAML file as resourceTypes: !include resource-types.raml

In the resource-types.raml file I have the following definition:

#%RAML 0.8

- collection-controller:
    get:
        responses:
            200:
                body:
                    application/json:
                        schema: <<resourcePathName>>
                        example: !include examples/<<resourcePathName>>-200.json

The raml-js-parser fails to parse the !include examples/<<resourcePathName>>-200.json part. I expect it to include the example in the file examples/users-200.json for example. The RAML file should be valid as I am also using RAML Java Parser and it works just fine - it parses the RAML files without errors and also generates service interfaces out of it. The error that I get with raml-js-parser is:

... [19:01:56] Plumber found unhandled error: Error in plugin 'gulp-raml2html' Message: .... cannot read examples/%3C%3CresourcePathName%3E%3E-200.json (Error: ENOENT, open 'examples/%3C%3CresourcePathName%3E%3E-200.json'). I guess that the value of the 'example' property is not expanded properly. Workaround would be to pass the contents of the example as a parameter but I wanted to avoid that - I don't want to specify it explicitly for each resource.

dmartinezg commented 9 years ago

You are correct RAML 0.8 specifically left this out, RAML 1.0 has this as a proposal https://github.com/raml-org/raml-spec/issues/84

inspell commented 9 years ago

You are correct. I will go with the workaround for now.