Last active
January 1, 2020 10:46
-
-
Save jacknie84/de64b317f1d5e13026be88014d57d325 to your computer and use it in GitHub Desktop.
Rest API Rules(Pagination, Filters)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"pagination": { | |
"bounds[offset]": { | |
"value": "int", | |
"validations": ["positiveOrZero"] | |
}, | |
"bounds.limit": { | |
"value": "int", | |
"validations": ["positive"] | |
}, | |
"orders[{index}].property": { | |
"value": "string", | |
"validations": ["notBlank"], | |
"templates": { | |
"index": { | |
"value": "integer", | |
"validations": ["positiveOrZero"] | |
} | |
} | |
}, | |
"orders[{index}].direction": { | |
"value": "string", | |
"validations": ["notBlank", "direction"], | |
"templates": { | |
"index": { | |
"value": "integer", | |
"validations": ["positiveOrZero"] | |
} | |
} | |
}, | |
"orders[{index}].nulls": { | |
"value": "string", | |
"validations": ["notBlank", "nulls"], | |
"templates": { | |
"index": { | |
"value": "integer", | |
"validations": ["positiveOrZero"] | |
} | |
} | |
}, | |
"x-total-count": { | |
"value": "response header", | |
"validations": ["positive"] | |
}, | |
"link": { | |
"value": "response header", | |
"validations": ["notBlank", "link"] | |
} | |
}, | |
"filters": { | |
"filters[{index}].{property}[{index}].{operator}": { | |
"value": "string", | |
"validations": ["notBlank"], | |
"templates": { | |
"property": { | |
"value": "string", | |
"validations": ["notBlank"] | |
}, | |
"index": { | |
"value": "integer", | |
"validations": ["positiveOrZero"] | |
}, | |
"operator": { | |
"value": "string", | |
"validations": ["notBlank", "operator"] | |
} | |
} | |
} | |
}, | |
"validators": { | |
"positive": "x => x > 0", | |
"positiveOrZero": "x => x >= 0", | |
"notBlank": "x => exists(x) && trim(x).length > 0", | |
"direction": "x => ['ASC', 'DESC'].contains(x)", | |
"nulls": "x => ['FIRST', 'LAST'].contains(x)", | |
"link": "x => format('(<{paginationUrl}>; rel=\"{linkRel}\",?)+').test(x)", | |
"operator": "x => ['EQ', 'NE', 'IN', 'SW', 'EW', 'IC', 'EC', 'LT', 'LE', 'GT', 'GE'].contains(x)" | |
}, | |
"direction": { | |
"ASC": "ascending", | |
"DESC": "descending" | |
}, | |
"nulls": { | |
"FIRST": "null을 첫번째로", | |
"LAST": "null을 마지막으로" | |
}, | |
"link": { | |
"paginationUrl": "(http|https)://{domain}?{pagination}&{filters}", | |
"linkRel": "next, last, first, prev" | |
}, | |
"operator": { | |
"EQ": "equals or is", | |
"NE": "not equals or is not", | |
"IN": "x in (...)", | |
"SW": "starts with", | |
"EW": "ends with", | |
"IC": "include or contains or like '%x%'", | |
"EC": "exclude or not contains or not like '%x%'", | |
"LT": "target < value", | |
"LE": "target <= value", | |
"GT": "target > value", | |
"GE": "target >= value" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment