I defined a raml file.
I want to valid a queryParameter(coefficient) that greater than 0 and less than or equal to 1.
(0< coefficient ≦ 1 )
Here is my raml.
#%RAML 1.0
title: sample API
baseUri: http://localhost:8081/api
version: 1.0
/inventory:
get:
coefficient:
type: number
minimum: 0
maximum: 1
I use the minimum and maximum but this will make 0 possible. How can I set the validation to greater than 0, but not equal to 0.
Any ideas?
(For some reasons I have to use the number type.I know with type string and regex may solve this problem as a work around.)
CodePudding user response:
The RAML specification doesn't seem to define ranges clearly but it looks to me that the current version of the specification (RAML 1.0) doesn't has the expressive power to differentiate a half-open interval nor an open interval.
The RAML 1.0 specification just says:
Facet Description
minimum? The minimum value.
maximum? The maximum value.
If you want to enforce this validation you will need to implement it in the API implementation instead of its RAML definition.