Complex queryParameters


#1

I have some endpoints where the query parameters must be one of a string, but can be a list of these strings, however there is some complex options that I would also want to convey though raml for the api and docs. Here is an example (which doesn’t work):

  queryParameters:
    dimensions:
      type: DimensionsList
      properties:
        values:
          - minute:
          - hour:
          - author: [ 'Countable' ]
          - title: [ 'Countable', 'StartsWithFilterable' ]

Dimensions will change per end point.

An example query may be ?dimensions=minute,author[3],title[1]^=foo

I am using RAML to dynamically generate my api, and will be generating the docs with it too. So its used for a single source of truth. Hopeing I can get this in there so its not duplicated/fragmented.

I was planning on doing something like, adding the DimensionsList as a type that has a values parameter or such, but this isn’t working. I just get ‘unknown node: values’. Any suggestions on how to tackle this would be appreciated.

Thanks


#2

So I’ve resolved this by using an annotation. I then handle the DimensionsList type and expect it to be used with the parameter-values annotation. I could not work out how to get parameters under the type usage.

    dimensions:
      type: DimensionsList
      (parameter-values):
        defaults:
          name:
          count: { min: 1, max: 500 }
          startswithsearch: # eg { min: 3 }
        values:
          - { name: minute, count: }
          - { name: hour, count: }
          - { name: day, count: }
          - { name: week, count: }
          - { name: month, count: }
          - { name: author }
          - { name: author.username }
          - { name: author.properties.language }
          - { name: author.properties.gender }
          - { name: location.country }
          - { name: location.continent }
          - { name: location.country_guess }
          - { name: location.continent_guess }
          - { name: location.time_zone }
          - { name: properties.platform, startswithsearch: { min: 3 } }