Type-Schema
Define JSON Schemas using TypeScript classes
Usage
Example #1 (Simple login schema):
; // AJV async schema ;
Where postSchema will be the following JSON schema:
{ "$async": true, "type": "object", "properties": { "body": { "additionalProperties": false, "type": "object", "properties": { "username": { "type": "string" }, "password": { "type": "string" } }, "required": [ "username", "password" ] } }, "required": [ "body" ]}
Example #2 (Administration of a user by id):
; // AJV async schema ;
Where postSchema will be the following JSON schema:
{ "$async": true, "type": "object", "properties": { "body": { "type": "object", "properties": { "username": { "type": "string" }, "permissions": { "type": "array", "items": { "enum": [ "admin", "user", "superAdmin" ], "type": "string" } } } }, "params": { "type": "object", "properties": { "userid": { "type": "string" } }, "required": [ "userid" ] } }, "required": [ "body", "params" ]}