Parse JSON Schema


#1

Hello there,

I want to describe the JSON schema the same way like uriParameters are displayed, in a list with type, default value, required, etc… . Just displaying the plain schema is hard to read in my opinion. Is there any way I can parse the schema to a JSON object so I can use it inside the nunjucks template? Or would the better way be to use formParameters, although the API only accepts json? I am using the raml2html parser
I want to be able to do sth. like this:

{% for property in b.schema %}
<pre>{{ property }}</pre>
{% endfor %}

so it looks like this (per default showing examples and form parameters together is not allowed):


(the data doesnt fit to the params, was just a quick copy&paste in dev-tools)
cheers


#2

Look at RAML 1.0 Types. This uses YAML format just like the RAML file itself, and I believe has a 1 to 1 mapping to JSON. In other words, anything you can define using JSON Schema, you can define in RAML Types, only it is easier/prettier to read do to using YAML format. There are tools in the API Workbench (or if not, soon will be… work is still being done on this as of now) that will convert between RAML Type (YAML), JSON and I think XML and back again. To use this you will need to move to RAML 1.0.

Also, RAML2HTML is being worked on right now to support 1.0. I suspect it will be some time before it covers most if not all of RAML 1.0, but I would guess that RAML Types would be supported early on as it is a pretty big feature of RAML 1.0.