Skip to content

Commit ea632cf

Browse files
committed
Showing headers and queryParameters from securitySchemes.describeBy
1 parent 6a8d2f6 commit ea632cf

File tree

12 files changed

+250
-76
lines changed

12 files changed

+250
-76
lines changed

dist/examples/leagues.raml

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,21 @@ securitySchemes:
3737
authorizationGrants: [ code, credentials, owner ]
3838
scopes:
3939
- "user"
40-
- "user:email"
41-
- "user:follow"
42-
- "public_repo"
43-
- "repo"
44-
- "repo:status"
45-
- "delete_repo"
46-
- "notifications"
47-
- "gist"
40+
- "league"
41+
- custom_scheme_1:
42+
type: x-custom
43+
describedBy:
44+
headers:
45+
auth:
46+
queryParameters:
47+
access_token:
48+
- custom_scheme_2:
49+
type: x-custom
50+
describedBy:
51+
headers:
52+
auth:
4853

49-
securedBy: [ basic, digest_auth, oauth_2_0 ]
54+
securedBy: [ basic, digest_auth, oauth_2_0, custom_scheme_1, custom_scheme_2 ]
5055

5156
/teams:
5257
displayName: Teams
@@ -130,14 +135,16 @@ securedBy: [ basic, digest_auth, oauth_2_0 ]
130135
get:
131136
description: |
132137
*Obtain* information from a collection of teams simultaneously
138+
headers:
139+
header:
133140
queryParameters:
134141
city:
135142
description:
136143
Filter the list of teams by home city.
137144
type: string
138145
required: false
139146
default: BAR
140-
example: Barcelona
147+
example: BAR
141148
responses:
142149
200:
143150
body:

dist/scripts/api-console-vendor.js

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var block = {
2020
lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
2121
blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
2222
list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
23-
html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
23+
html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,
2424
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
2525
table: noop,
2626
paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
@@ -868,7 +868,7 @@ Renderer.prototype.link = function(href, title, text) {
868868
} catch (e) {
869869
return '';
870870
}
871-
if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0) {
871+
if (prot.indexOf('javascript:') === 0) {
872872
return '';
873873
}
874874
}
@@ -1154,13 +1154,8 @@ function marked(src, opt, callback) {
11541154

11551155
pending = tokens.length;
11561156

1157-
var done = function(err) {
1158-
if (err) {
1159-
opt.highlight = highlight;
1160-
return callback(err);
1161-
}
1162-
1163-
var out;
1157+
var done = function() {
1158+
var out, err;
11641159

11651160
try {
11661161
out = Parser.parse(tokens, opt);
@@ -1189,7 +1184,6 @@ function marked(src, opt, callback) {
11891184
return --pending || done();
11901185
}
11911186
return highlight(token.text, token.lang, function(err, code) {
1192-
if (err) return done(err);
11931187
if (code == null || code === token.text) {
11941188
return --pending || done();
11951189
}
@@ -1259,7 +1253,7 @@ marked.inlineLexer = InlineLexer.output;
12591253

12601254
marked.parse = marked;
12611255

1262-
if (typeof module !== 'undefined' && typeof exports === 'object') {
1256+
if (typeof exports === 'object') {
12631257
module.exports = marked;
12641258
} else if (typeof define === 'function' && define.amd) {
12651259
define(function() { return marked; });
@@ -40231,7 +40225,7 @@ CodeMirror.defineMIME("text/x-yaml", "yaml");
4023140225
})();
4023240226

4023340227
/**
40234-
* @license AngularJS v1.2.29-build.590+sha.e81b2f7
40228+
* @license AngularJS v1.2.28
4023540229
* (c) 2010-2014 Google, Inc. http://angularjs.org
4023640230
* License: MIT
4023740231
*/
@@ -40300,7 +40294,7 @@ function minErr(module) {
4030040294
return match;
4030140295
});
4030240296

40303-
message = message + '\nhttp://errors.angularjs.org/1.2.29-build.590+sha.e81b2f7/' +
40297+
message = message + '\nhttp://errors.angularjs.org/1.2.28/' +
4030440298
(module ? module + '/' : '') + code;
4030540299
for (i = 2; i < arguments.length; i++) {
4030640300
message = message + (i == 2 ? '?' : '&') + 'p' + (i-2) + '=' +
@@ -40714,8 +40708,6 @@ noop.$inject = [];
4071440708
return (transformationFn || angular.identity)(value);
4071540709
};
4071640710
```
40717-
* @param {*} value to be returned.
40718-
* @returns {*} the value passed in.
4071940711
*/
4072040712
function identity($) {return $;}
4072140713
identity.$inject = [];
@@ -42221,11 +42213,11 @@ function setupModuleLoader(window) {
4222142213
* - `codeName` – `{string}` – Code name of the release, such as "jiggling-armfat".
4222242214
*/
4222342215
var version = {
42224-
full: '1.2.29-build.590+sha.e81b2f7', // all of these placeholder strings will be replaced by grunt's
42216+
full: '1.2.28', // all of these placeholder strings will be replaced by grunt's
4222542217
major: 1, // package task
4222642218
minor: 2,
42227-
dot: 29,
42228-
codeName: 'snapshot'
42219+
dot: 28,
42220+
codeName: 'finnish-disembarkation'
4222942221
};
4223042222

4223142223

@@ -44657,11 +44649,6 @@ function Browser(window, document, $log, $sniffer) {
4465744649
}
4465844650
}
4465944651

44660-
function getHash(url) {
44661-
var index = url.indexOf('#');
44662-
return index === -1 ? '' : url.substr(index + 1);
44663-
}
44664-
4466544652
/**
4466644653
* @private
4466744654
* Note: this method is used only by scenario runner
@@ -44773,10 +44760,8 @@ function Browser(window, document, $log, $sniffer) {
4477344760
}
4477444761
if (replace) {
4477544762
location.replace(url);
44776-
} else if (!sameBase) {
44777-
location.href = url;
4477844763
} else {
44779-
location.hash = getHash(url);
44764+
location.href = url;
4478044765
}
4478144766
}
4478244767
return self;
@@ -49531,10 +49516,6 @@ function stripHash(url) {
4953149516
return index == -1 ? url : url.substr(0, index);
4953249517
}
4953349518

49534-
function trimEmptyHash(url) {
49535-
return url.replace(/(#.+)|#$/, '$1');
49536-
}
49537-
4953849519

4953949520
function stripFile(url) {
4954049521
return url.substr(0, stripHash(url).lastIndexOf('/') + 1);
@@ -50191,11 +50172,10 @@ function $LocationProvider(){
5019150172
// update browser
5019250173
var changeCounter = 0;
5019350174
$rootScope.$watch(function $locationWatch() {
50194-
var oldUrl = trimEmptyHash($browser.url());
50195-
var newUrl = trimEmptyHash($location.absUrl());
50175+
var oldUrl = $browser.url();
5019650176
var currentReplace = $location.$$replace;
5019750177

50198-
if (!changeCounter || oldUrl != newUrl) {
50178+
if (!changeCounter || oldUrl != $location.absUrl()) {
5019950179
changeCounter++;
5020050180
$rootScope.$evalAsync(function() {
5020150181
if ($rootScope.$broadcast('$locationChangeStart', $location.absUrl(), oldUrl).
@@ -55794,12 +55774,37 @@ function limitToFilter(){
5579455774
limit = int(limit);
5579555775
}
5579655776

55797-
//NaN check on limit
55798-
if (limit) {
55799-
return limit > 0 ? input.slice(0, limit) : input.slice(limit);
55777+
if (isString(input)) {
55778+
//NaN check on limit
55779+
if (limit) {
55780+
return limit >= 0 ? input.slice(0, limit) : input.slice(limit, input.length);
55781+
} else {
55782+
return "";
55783+
}
55784+
}
55785+
55786+
var out = [],
55787+
i, n;
55788+
55789+
// if abs(limit) exceeds maximum length, trim it
55790+
if (limit > input.length)
55791+
limit = input.length;
55792+
else if (limit < -input.length)
55793+
limit = -input.length;
55794+
55795+
if (limit > 0) {
55796+
i = 0;
55797+
n = limit;
5580055798
} else {
55801-
return isString(input) ? "" : [];
55799+
i = input.length + limit;
55800+
n = input.length;
5580255801
}
55802+
55803+
for (; i<n; i++) {
55804+
out.push(input[i]);
55805+
}
55806+
55807+
return out;
5580355808
};
5580455809
}
5580555810

@@ -60072,7 +60077,7 @@ var ngIfDirective = ['$animate', function($animate) {
6007260077
<select ng-model="template" ng-options="t.name for t in templates">
6007360078
<option value="">(blank)</option>
6007460079
</select>
60075-
url of the template: <code>{{template.url}}</code>
60080+
url of the template: <tt>{{template.url}}</tt>
6007660081
<hr/>
6007760082
<div class="slide-animate-container">
6007860083
<div class="slide-animate" ng-include="template.url"></div>

dist/scripts/api-console.js

Lines changed: 73 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,10 @@
376376
}
377377
}
378378

379+
function beautifyCustomSecuritySchemeName (name) {
380+
return (name.charAt(0).toUpperCase() + name.slice(1)).replace(/_/g, ' ');
381+
}
382+
379383
$scope.readTraits = function (traits) {
380384
var list = [];
381385

@@ -435,19 +439,25 @@
435439
type: 'Anonymous'
436440
};
437441

442+
Object.keys($scope.securitySchemes).map(function (key) {
443+
var type = $scope.securitySchemes[key].type;
444+
445+
$scope.securitySchemes[key].name = type;
446+
$scope.securitySchemes[key].id = type + '|' + key;
447+
448+
if (type === 'x-custom') {
449+
$scope.securitySchemes[key].name = beautifyCustomSecuritySchemeName(key);
450+
$scope.securitySchemes[key].id = type + '|' + key;
451+
}
452+
});
453+
438454
/*jshint camelcase: false */
439455
// Digest Authentication is not supported
440456
delete $scope.securitySchemes.digest_auth;
441457
/*jshint camelcase: true */
442458

443459
loadExamples();
444460

445-
var defaultScheme = Object.keys($scope.securitySchemes).sort()[0];
446-
$scope.currentScheme = {
447-
type: $scope.securitySchemes[defaultScheme].type,
448-
name: defaultScheme
449-
};
450-
451461
// Hack for codemirror
452462
setTimeout(function () {
453463
var editors = jQuery('.raml-console-sidebar-content-wrapper #sidebar-body .raml-console-codemirror-body-editor .CodeMirror');
@@ -876,6 +886,7 @@
876886
replace: true,
877887
controller: function ($scope, $location, $anchorScroll) {
878888
$scope.currentSchemeType = 'Anonymous';
889+
$scope.currentScheme = 'Anonymous|anonymous';
879890
$scope.responseDetails = false;
880891

881892
function completeAnimation (element) {
@@ -1131,6 +1142,57 @@
11311142

11321143
$scope.context.forceRequest = false;
11331144

1145+
function pirula (type, scheme, collection, context) {
1146+
var details = $scope.securitySchemes[scheme].describedBy || {};
1147+
var securityHeaders = details[type] || {};
1148+
1149+
Object.keys(collection).map(function (key) {
1150+
if (collection[key][0].isFromSecurityScheme) {
1151+
delete collection[key];
1152+
}
1153+
1154+
if (context.plain[key].definitions[0].isFromSecurityScheme) {
1155+
delete context.plain[key];
1156+
}
1157+
});
1158+
1159+
if (securityHeaders) {
1160+
Object.keys(securityHeaders).map(function (key) {
1161+
if (!securityHeaders[key]) {
1162+
securityHeaders[key] = {
1163+
id: key,
1164+
type: 'string'
1165+
};
1166+
}
1167+
1168+
securityHeaders[key].displayName = key;
1169+
securityHeaders[key].isFromSecurityScheme = true;
1170+
collection[key] = [securityHeaders[key]];
1171+
1172+
context.plain[key] = {
1173+
definitions: [securityHeaders[key]],
1174+
selected: securityHeaders[key].type
1175+
};
1176+
context.values[key] = [undefined];
1177+
});
1178+
}
1179+
}
1180+
1181+
$scope.securitySchemeChanged = function (scheme) {
1182+
var info = scheme.split('|');
1183+
var type = info[0];
1184+
var name = info[1];
1185+
1186+
$scope.currentSchemeType = type;
1187+
1188+
if (!$scope.methodInfo.headers.plain) {
1189+
$scope.methodInfo.headers.plain = {};
1190+
}
1191+
1192+
pirula('headers', name, $scope.methodInfo.headers.plain, $scope.context.headers);
1193+
pirula('queryParameters', name, $scope.methodInfo.queryParameters, $scope.context.queryParameters);
1194+
};
1195+
11341196
$scope.tryIt = function ($event) {
11351197
$scope.requestOptions = null;
11361198
$scope.responseDetails = false;
@@ -1879,6 +1941,8 @@
18791941
return new RAML.Client.AuthStrategies.Oauth2(scheme, credentials);
18801942
case 'OAuth 1.0':
18811943
return new RAML.Client.AuthStrategies.Oauth1(scheme, credentials);
1944+
case 'x-custom':
1945+
return RAML.Client.AuthStrategies.anonymous();
18821946
default:
18831947
throw new Error('Unknown authentication strategy: ' + scheme.type);
18841948
}
@@ -4994,7 +5058,7 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
49945058
" <span marked=\"param.definitions[0].description\"></span>\n" +
49955059
" </span>\n" +
49965060
" </span>\n" +
4997-
" <label for=\"{{param.definitions[0].id}}\" class=\"raml-console-sidebar-label\">{{param.definitions[0].displayName}} <a class=\"raml-console-sidebar-override\" ng-if=\"canOverride(param.definitions[0])\" ng-click=\"overrideField($event, param.definitions[0])\">Override</a> <span class=\"raml-console-side-bar-required-field\" ng-if=\"param.definitions[0].required\">*</span></label>\n" +
5061+
" <label for=\"{{param.definitions[0].id}}\" class=\"raml-console-sidebar-label\">{{param.definitions[0].displayName}} <a class=\"raml-console-sidebar-override\" ng-if=\"canOverride(param.definitions[0])\" ng-click=\"overrideField($event, param.definitions[0])\">Override</a> <span class=\"raml-console-side-bar-required-field\" ng-if=\"param.definitions[0].required\">*</span><label ng-if=\"param.definitions[0].isFromSecurityScheme\" class=\"raml-console-sidebar-security-label\">from security scheme</label></label>\n" +
49985062
"\n" +
49995063
" <span class=\"raml-console-sidebar-input-tooltip-container raml-console-sidebar-input-left\" ng-if=\"hasExampleValue(param.definitions[0])\">\n" +
50005064
" <button tabindex=\"-1\" class=\"raml-console-sidebar-input-reset\" ng-click=\"reset(param.definitions)\"><span class=\"raml-console-visuallyhidden\">Reset field</span></button>\n" +
@@ -5219,8 +5283,8 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
52195283
" <div class=\"raml-console-sidebar-row raml-console-sidebar-securty\">\n" +
52205284
" <div class=\"raml-console-toggle-group raml-console-sidebar-toggle-group\">\n" +
52215285
" <label class=\"raml-console-sidebar-label\">Security Scheme</label>\n" +
5222-
" <select class=\"raml-console-sidebar-input\" ng-model=\"currentSchemeType\" style=\"margin-bottom: 0;\">\n" +
5223-
" <option ng-repeat=\"(key, scheme) in securitySchemes\" value=\"{{scheme.type}}\" ng-selected=\"scheme.type=='Anonymous'\">{{scheme.type}}</option>\n" +
5286+
" <select ng-change=\"securitySchemeChanged(currentScheme)\" class=\"raml-console-sidebar-input\" ng-model=\"currentScheme\" style=\"margin-bottom: 0;\">\n" +
5287+
" <option ng-repeat=\"(key, scheme) in securitySchemes\" value=\"{{scheme.id}}\" ng-selected=\"scheme.type=='Anonymous'\">{{scheme.name}}</option>\n" +
52245288
" </select>\n" +
52255289
" </div>\n" +
52265290
" </div>\n" +

dist/styles/api-console-dark-theme.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3219,6 +3219,15 @@ a.raml-console-resource-path-active {
32193219
font-weight: 700;
32203220
}
32213221

3222+
.raml-console-sidebar-security-label {
3223+
display: inline;
3224+
float: right;
3225+
font-size: 11px;
3226+
font-weight: normal;
3227+
margin-right: 5px;
3228+
margin-top: 9px;
3229+
}
3230+
32223231
.raml-console-sidebar-input {
32233232
display: block;
32243233
width: 100%;

0 commit comments

Comments
 (0)