Validating invalid query parameters using raml


Hi Everyone,

I just wanted to know, is there any good way to handle invalid query parameters which is not mentioned in the raml file. So one way to do is using required but problem is the fields in my use case can be optional. So is there a better way to check the query is invalid and return like a 400 bad request response to the user?. Any help would be appreciated.



You have some ways to define validation rules against parameters: enums, regular expression for string, range for numbers, sizes for list, date formats for the dates… I am using these items inside all my types to document which kind of items my APIs use in both ways, in and out.


I need a bit more detail. Are you using one of the RAML 2… projects… and trying to find a way for the auto generated code to validate incoming request query params? RAML simply defines the API. How you use RAML to generate code or other artifacts is outside of the RAML definition/tools itself. In other words, if you are using RAML2JAXRS to generate code from RAML (and presumably JSON Schema), you have to implement the logic to determine if a query parameter is invalid or not. However, in the case of RAML2JAXRS, it builds method signatures that only pass in the query parameters defined in RAML.

Not entirely sure if I am understanding the question though.