mulesoft-labs / api-console-cli

A CLI tools for the API console.
Other
14 stars 15 forks source link

includes in resourceTypes do not get resolved correctly #22

Closed ericwood73 closed 5 years ago

ericwood73 commented 6 years ago

Our raml includes a resourceType with a resource description that is included from an external file, e.g.

resourceTypes:
  collection:
    usage: This resource type represents resources (and operations on resources) that are collections of objects.
   description: !include ./resourceDescriptions/<<resourcePathName>>.txt
    get:
      description: Get all <<resourcePathName|!pluralize>> to which the user has access
      responses:
        200:
          body:
            application/json:
              description: A JSON object containing <<resourcePathName|!pluralize>> to which the user has access

The resourcePathName is resolved correctly, but the console builder is unable to resolve the description file. In the api.json, I see "Can not resolve ./resourceDescriptions/address.txt". I am also including type fragments in the raml (e.g. address: !include ./schemas/address.raml, and those resolve correctly. The console is being run from a directory which contains both the resourceDescriptions folder and the schemas folder. Also if I take that same description and put it on the resource itself, substituting the resource path name (i.e.

/address:
  type: collection
  description: !include resourceDescriptions/address.txt

), it resolves the file and includes the description correctly.

jarrodek commented 6 years ago

Hi, Sorry for late response. I was involved in another project for a while. It looks like RAML parser's issue so I'll pass is to the parser team to investigate.

Thanks for reporting.

KonstantinSviridov commented 6 years ago

Hi @ericwood73 !

As the RAML spec states (right above Typed Fragments),

The !include tag argument must be static: namely, it MUST NOT contain any resource type parameters or trait parameters.

You have to pass description value as parameter if you want it to be located externally:

resourceTypes:
  collection:
    description: <<description>>

/address:
  type:
    collection:
      description: !include ./resourceDescriptions/address.txt   

Regards, Konstantin

jarrodek commented 5 years ago

Closing as resolved.