diff --git a/index.js b/index.js
index f67712e0..ac84d039 100644
--- a/index.js
+++ b/index.js
@@ -105,6 +105,16 @@ function getDefaultConfig(mainTemplate, templatesPath) {
var env = nunjucks.configure(templatesPath, {watch: false});
markdown.register(env, marked);
+ // Add extra function for finding a security scheme by name
+ ramlObj.securitySchemeWithName = function(name) {
+ return ramlObj.securitySchemes[0][name];
+ };
+
+ //typeof function
+ ramlObj.getTypeOf = function(v) {
+ return typeof v;
+ };
+
_traverse(ramlObj);
// Render the main template using the raml object and fix the double quotes
diff --git a/lib/resource.nunjucks b/lib/resource.nunjucks
index 10b4945d..0eb9ec94 100644
--- a/lib/resource.nunjucks
+++ b/lib/resource.nunjucks
@@ -61,10 +61,30 @@
{% if method.securedBy.length %}
- Secured by {{ method.securedBy }}
+ Secured by
+
+ {% if getTypeOf(method.securedBy)=='object' %}
+ {% set i=0 %}
+ {% for securedByItem in method.securedBy %}
+ {% for secureByName, securedByValue in method.securedBy[i] %}
+ {% if securitySchemeWithName(secureByName).type == "OAuth 2.0" %}
+ OAuth 2.0.
+ {% if securedByValue.authorizationGrants %}
+ Grant types: {{ securedByValue.authorizationGrants | join(',') | replace('credentials','client_credentials',1) | replace('code','authorization_code',1) | replace('token','implicit',1) }}.
+ {% endif %}
+ {% if securedByValue.scopes %}
+ Scopes: {{ securedByValue.scopes | join(',')}}.
+ {% endif %}
+ {% endif %}
+ {% endfor %}
+ {% set i=i+1 %}
+ {% endfor %}
+ {% else %}
+ {{ method.securedBy }}
+ {% endif %}
{% endif %}
-
+
{% if method.allUriParameters.length or method.queryParameters or method.headers or method.body %}