How to parse schemas


#1

Hi,

I am new to using RAML and wanted some help with how to parse the schemas.I have the following RAML file and do not know how to read/get the json object of the defined schema:

#%RAML 0.8
title: EndpointRegistration
version: v1.0
baseUri: http://localhost:8080/{version}/instances
mediaType: application/json
/volumes:
get:
description: returns a list of volumes
/{volumeId}:
post:
description: create a single volume
body:
application/json:
schema : |
{
"$schema": “http://json-schema.org/schema”,
“type”: “object”,
“channel”: “production.volume.create”,
“properties”: {
“name”: {
“required”: true,
“type”: “string”
},
“type”: {
“required”: true,
“type”: “string”
},
“size”: {
“required”: true,
“type”: “string”
},
“processId”: {
“required”: false,
“type”: “string”
},
“startTimeStamp”: {
“required”: false,
“type”: “string”
}
}
}

I tried walking the structure up to the post and was able to read the description, however I cannot proceed further. I did try raml.getSchemas() and getConsolidatedSchemas() but both seem to return an empty list. I would like to use RAML to define all of my REST endpoints and parse the file to determine the valid endpoints and needed paramaters for commands. If there is a better way please let me know.

Thanks.


#2

It worked out, I am all set now after modifying my RAML file to use dash notation for naming schemas.


#3

Fantastic. Can you enlighten what your solution was and/or what you discovered? May help others if they come across this and have a similar issue. Thank you.