An API console for RAML (Restful Api Modeling Language) documents. The RAML Console allows browsing of API documentation and in-browser testing of API methods.
There are two ways you can include the console: directly, or within an iframe. The direct method is seamless but has the potential of CSS and JS conflicts. Using an iframe avoids conflicts, but has its own quirks noted below.
-
Include the packaged CSS and JS in your document
<head> … <link href="styles/vendor.css" rel="stylesheet" type="text/css"> <link rel="stylesheet" href="path/to/dist/styles/light-theme.css" type="text/css" /> </head> <body ng-app="ramlVoicebaseConsoleApp" ng-cloak> … <script src="path/to/dist/scripts/voicebase-developer-experience-vendor.js"></script> <script type="text/javascript" src="scripts/voicebase-developer-experience.js"></script> <script type="text/javascript"> $.noConflict(); </script> </body>
-
Include the
<raml-console>
directive, specifying your RAML as asrc
attribute. -
Please ensure that the container for the console directive provides the CSS properties
overflow: auto
andposition: relative
.
The CSS for the console is namespaced so that it won't affect other parts of the page it's included on. However, general styles you have (such as on h1
s) may inadvertently bleed into the console.
The console's javascript includes various dependencies, for example AngularJS and jQuery. If your document requires different versions or includes conflicting libraries, your page may break.
-
Within the page that you would like to include the console into, add the following:
<iframe src="path/to/dist/index.html?raml=path/to/your.api.raml"/>
You will need to specify a fixed height for the iframe that fits into the design of your page. Since iframes do not automatically resize to fit content, the user may have to scroll within the iframe.
- Your RAML document needs to be hosted on the same domain as the console, or on a domain that allows CORS requests from your domain.
- To use Try It functionality within the console, your API needs to enable CORS from the console's domain, or you need to use a proxy.
A proxy for Try It can be provided after loading the console JavaScript. For example:
RAML.Settings.proxy = 'http://www.someproxy.com/somepath/'
Given the above, trying a GET to http://www.someapi.com/resource
would get
http://www.someproxy.com/somepath/http://www.someapi.com/resource
A redirect URI for OAuth 2 can be provided in a similar manner:
RAML.Settings.oauth2RedirectUri = 'http://www.raml.org/console/'
Given the above, OAuth 2 requests would redirect back to that URL.
In Single View mode you will be able to see only documentation or try-it.
<raml-console single-view></raml-console>
Theme Switcher can be disable if needed by adding the following setting:
<raml-console disable-theme-switcher></raml-console>
To run the console, you'll need the following:
- Install Sass -
gem install sass
- Install grunt-cli globally -
npm install -g grunt-cli
- Install bower globally -
npm install -g bower
- Install the console's NPM packages -
npm install
- Install the console's Bower packages -
bower install
$ grunt server
$ open http://localhost:9000
To run tests, you'll need the following:
- Install Sass -
gem install sass
- Install grunt-cli globally -
npm install -g grunt-cli
- Install protractor globally -
npm install -g protractor
- Install the console's NPM packages -
npm install
- Run
node_modules/grunt-protractor-runner/node_modules/protractor/bin/webdriver-manager update
$ grunt regression