Validate API Router Schema

Is there a way for the API Kit router to check the incoming circuit? I have the following in my RAML file, but it does not check the incoming circuit.

- emails: | { "$schema": "http://json-schema.org/draft-04/schema#", "type" : "object", "properties" : { "email" : { "type" : "string" }, "name" : { "type" : "string" }, "emailOrigin" : { "type" : "string" } } } resourceTypes: - postbase: post: responses: 200: body: application/json: 500: body: application/json: - putBase: put: responses: 200: body: application/json: 500: body: application/json: /emails: type: postbase post: description: | Recieve emails captured from various parts of the site. body: schema: emails 
+5
source share
2 answers

As far as I can see, any body will be valid for this scheme. All fields are string, not mandatory, and not a specific format. Try to put some fields as needed and see what happens

Hurrah!

0
source

The following links will help you http://forums.raml.org/t/examples-validations-in-raml-parsers/80

Further example: employeeDetailsSchema.json

 { "type": "object", "$schema": "http://json-schema.org/draft-03/schema", "id": "http://jsonschema.net", "required": true, "properties": { "employeeID": { "type": "string", -------> Validates the Data type "required": true -------> Validates whether data is present or not }, "employeeFirstName": { "type": "string", "required": true }, "employeeLastName": { "type": "string", "required": true }, "employeeDOB": { "type": "string", "required": true } } } 

Schema file used in my RAML

 #%RAML 0.8 title: ManageEmployees version: 1.0 baseUri: http://api.acme.com/ mediaType: application/json /newEmployee: post: description: Create new employees body: schema: !include com/ww/schema/employeeDetailsSchema.json put: description: Update employees details body: schema: !include com/ww/schema/employeeDetailsSchema.json responses: 200: body: example: !include com/ww/schema/employeeExample.json 
+1
source

Source: https://habr.com/ru/post/1203937/


All Articles