Closed rpazos98 closed 3 years ago
The RAML 1.0 spec says:
The queryString value is either the name of a data type or an inline data type declaration (...) If the type is derived from a scalar type, the query string as a whole MUST be described by the type.
So what you wrote is valid. Any query string for GET /flights
is not required but when set, must be of type string. That being said, it doesn't restrict much. If that's intended, that's fine. If not, you might want to add either a pattern
property or declare an object
type with properties instead.
Hi @jstoiko. The spec doesn't define the required
facet for scalar types
. It only defines it for property declarations
. Therefore, if someone specifies a queryString defined by a scalar type then that type should always be required.
It seems that only way an optional queryString can be defined is if a queryString has an object type like below where none of its properties are required:
/flights:
get:
queryString:
properties:
something?:
responses:
200:
body:
application/json:
type: string
On another note, the quote:
If the type is derived from a scalar type, the query string as a whole MUST be described by the type.
is quite confusing as a query string can't be described by every scalar type. How would a queryString be describe by a number, file or null?
@tomsfernandez: You're right, the required:
node in the example above shouldn't be there.
How would a queryString be describe by a number, file or null?
I think it's up to the processor to cast whatever "raw" value it gets into the declared type. This is the same issue as with uriParameters
or anything that's part of the URI for that matter.
@rpazos98: you might be better of using the queryParameters:
node instead since the value of that node is a properties declaration.
Thank you both @tomsfernandez and @jstoiko! I'm closing the issue.
Hi everyone!
I am working with query string and I have a doubt about how I can define it, specifically to determine whether it is required or not.
I have this simple example:
As far as I have checked in the spec it never points out for queryString if
required
is something I can define, so I just wanted to check if it is possible to define it or if it is always optional or not