Prevent repeating queryparams for every endpoint?


#1

Hello,
I recently started to document our Api in a raml format. For all my endpoints I have a queryParam ‘token’ that has an unique key so that the backend can verify client is authenticated. Currently I have to repeat that qp in all my endpoints user.

Is there a way to define those few lines once at the beginning pof the .raml file and refer to those everywhere I need in the configuration file?

e.g. I need to add this for all endpoints:

author:
         displayName: Author
         type: string
         description: An author's full name
         example: Mary Roach
         required: false

and include it further down in the file


#2

This seems to be asked before and replied to: http://forums.raml.org/t/best-way-to-refactor-reused-query-parameters/622.
But it is not a valid response for Raml 1.0: I get an error “Traits should be a map in Raml 1.0” when using the Api Designer from Mulesoft… Anyone knows how to use maps to achieve this?

Easier than I thought…

traits:
  - needs_authentication:
    queryParameters:
      token:
        displayName: token
        type: string
        description: The server-generated token issued to the user after a successful login
        example: E27B40D6-6C62-6D46-AC144BDF0E9A1D68
        required: false
        minLength: 35
        maxLength: 35

…gives the error “Traits should be a map in Raml 1.0”, so make it a map:

traits:
  needs_authentication:
    queryParameters:
      token:
        displayName: token
        type: string
        description: The server-generated token issued to the user after a successful login
        example: E27B40D6-6C62-6D46-AC144BDF0E9A1D68
        required: false
        minLength: 35
        maxLength: 35

…and this gives no error in the Api designer


#3

I use this in api-workbench

traits:
  paged: !include traits/paged.raml

and something similar to this in paged,raml

#%RAML 1.0 Trait
queryParameters:
  start:
    type: string
    required: false
  limit:
    type: integer
    required: false