When to use queryString and when to use queryParameter?


#1

Hi,

I’m new to RAML (using 1.0). The specs (https://github.com/raml-org/raml-spec/blob/master/versions/raml-10/raml-10.md/#query-strings-and-query-parameters) say that I can use queryString or queryParameter and that they are mutually exclusive.

After reading that chapter I still don’t understand the difference, and when to use one over the other. Can anyone help me out with an explanation based on clear examples with use cases?


#2

Hi @wilko

Please go through the below URL.


#3

Off the top of my head, a query string would be the entire set of query params… e.g. ?a=1&b=2&c=3 where as query parameters would be each parameter defined, as in

a:
type: string
required: false
description: …

The end result would be the same potential URL (e.g. some combo of 0 or more query parameters), but defining the parameters allows you more details, good for documentation, etc.


#4

Thank you for your replies.

It’s possibly just that Kevin, that using queryParameter allows for more fine grained detail.

But if anyone has a good reason to use one over the other, please illustrate, I’m still interested to learn why.

I can’t seem to edit my original post (topic starter), likely because it’s too long ago, but to elaborate on my original question.

I still don’t understand the difference, and when to use one over the other.

I don’t mean the difference between a query string and a query parameter, because that is already very clear to me. I am referring to the keys queryParameter and queryString, one of which may be defined for the method property (such as get or post) of a resource. When to use the queryParameter key, and when to use the queryString key instead?


#5

You could also add that with queryString you would be able to define conditional parameters using unions etc. That’s not working with queryParameters as you define each explicitly and separately.