Under the hood raml4js
uses the extraordinary raml-parser
to load your RAML:
var fs = raml4js = ; ;
CLI
Since 0.2.1
you can install raml4js
globally:
$ npm install -g raml4js$ raml4js path/to/api.raml > client.js
Use raml4js -h
to see full usage info.
Methods
-
raml4js(file, callback)
-
raml4js.read(file, callback)
Will parse the RAML file and then will invoke the callback(err, data) function.
If no error occurs data will contain the parsed RAML as object, otherwise err will be fulfilled.
-
raml4js.client(data, class_name)
Generate static code using data as RAML object input.
Will use class_name for the client instance, defaults to
APIClient
.
Since 0.2.0
the method validate()
was deprecated in favor of ramlev.
Client usage
The generated client isn't capable to perform any request, you're encouraged to provide a wrapper for this using the requestHandler
method:
var http = client = ; client;
If you have a resource like GET /articles/{articleId}
, then:
clientresourcesarticles;
Yet another RAML client generator?
Yes, there's an official raml-client-generator for full-featured Javascript clients.
Since raml4js
doesn't ship any dependency you can use fetch()
or even jQuery's $.ajax
for.