Skip to content

Commit 8d0230a

Browse files
committed
Add support for protocols
1 parent e4eabbd commit 8d0230a

File tree

5 files changed

+44
-6
lines changed

5 files changed

+44
-6
lines changed

dist/examples/leagues.raml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ resourceTypes:
5959
traits:
6060
- filterable: {}
6161

62-
securedBy: [ basic, digest_auth, oauth_2_0, custom_scheme_1, custom_scheme_2 ]
62+
securedBy: [ null, basic, digest_auth, oauth_2_0, custom_scheme_1, custom_scheme_2 ]
6363

6464
/teams:
6565
type: base

dist/scripts/api-console.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,6 +920,7 @@
920920
$scope.currentSchemeType = defaultSchema.type;
921921
$scope.currentScheme = defaultSchema.id;
922922
$scope.responseDetails = false;
923+
$scope.currentProtocol = $scope.raml.protocols[0];
923924

924925
function completeAnimation (element) {
925926
jQuery(element).removeAttr('style');
@@ -1088,6 +1089,7 @@
10881089

10891090
$scope.currentSchemeType = defaultSchema.type;
10901091
$scope.currentScheme = defaultSchema.id;
1092+
$scope.currentProtocol = $scope.raml.protocols[0];
10911093
});
10921094

10931095
$scope.cancelRequest = function () {
@@ -1220,7 +1222,11 @@
12201222
}
12211223
}
12221224

1223-
$scope.securitySchemeChanged = function (scheme) {
1225+
$scope.protocolChanged = function protocolChanged(protocol) {
1226+
$scope.currentProtocol = protocol;
1227+
};
1228+
1229+
$scope.securitySchemeChanged = function securitySchemeChanged(scheme) {
12241230
var info = scheme.split('|');
12251231
var type = info[0];
12261232
var name = info[1];
@@ -1272,6 +1278,8 @@
12721278
}
12731279
client.baseUriParameters(pathBuilder.baseUriContext);
12741280
});
1281+
1282+
client.baseUri = client.baseUri.replace(/(https)|(http)/, $scope.currentProtocol.toLocaleLowerCase());
12751283
url = client.baseUri + pathBuilder(segmentContexts);
12761284
} catch (e) {
12771285
$scope.response = {};
@@ -5435,8 +5443,19 @@ angular.module('ramlConsoleApp').run(['$templateCache', function($templateCache)
54355443
" </header>\n" +
54365444
"\n" +
54375445
" <div class=\"raml-console-sidebar-content-wrapper\">\n" +
5438-
" <section>\n" +
5446+
" <section ng-if=\"raml.protocols.length > 1\">\n" +
54395447
" <header class=\"raml-console-sidebar-row raml-console-sidebar-subheader raml-console-sidebar-subheader-top\">\n" +
5448+
" <h4 class=\"raml-console-sidebar-subhead\">Protocols</h4>\n" +
5449+
" </header>\n" +
5450+
" <div class=\"raml-console-sidebar-row raml-console-sidebar-securty\">\n" +
5451+
" <select ng-change=\"protocolChanged(currentProtocol)\" class=\"raml-console-sidebar-input\" ng-model=\"currentProtocol\" style=\"margin-bottom: 0;\">\n" +
5452+
" <option ng-repeat=\"protocol in raml.protocols\" value=\"{{protocol}}\">{{protocol}}</option>\n" +
5453+
" </select>\n" +
5454+
" </div>\n" +
5455+
" </section>\n" +
5456+
"\n" +
5457+
" <section>\n" +
5458+
" <header class=\"raml-console-sidebar-row raml-console-sidebar-subheader\" ng-class=\"{'raml-console-sidebar-subheader-top':raml.protocols.length == 1}\">\n" +
54405459
" <h4 class=\"raml-console-sidebar-subhead\">Authentication</h4>\n" +
54415460
" </header>\n" +
54425461
"\n" +

src/app/directives/sidebar.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
$scope.currentSchemeType = defaultSchema.type;
1515
$scope.currentScheme = defaultSchema.id;
1616
$scope.responseDetails = false;
17+
$scope.currentProtocol = $scope.raml.protocols[0];
1718

1819
function completeAnimation (element) {
1920
jQuery(element).removeAttr('style');
@@ -182,6 +183,7 @@
182183

183184
$scope.currentSchemeType = defaultSchema.type;
184185
$scope.currentScheme = defaultSchema.id;
186+
$scope.currentProtocol = $scope.raml.protocols[0];
185187
});
186188

187189
$scope.cancelRequest = function () {
@@ -314,7 +316,11 @@
314316
}
315317
}
316318

317-
$scope.securitySchemeChanged = function (scheme) {
319+
$scope.protocolChanged = function protocolChanged(protocol) {
320+
$scope.currentProtocol = protocol;
321+
};
322+
323+
$scope.securitySchemeChanged = function securitySchemeChanged(scheme) {
318324
var info = scheme.split('|');
319325
var type = info[0];
320326
var name = info[1];
@@ -366,6 +372,8 @@
366372
}
367373
client.baseUriParameters(pathBuilder.baseUriContext);
368374
});
375+
376+
client.baseUri = client.baseUri.replace(/(https)|(http)/, $scope.currentProtocol.toLocaleLowerCase());
369377
url = client.baseUri + pathBuilder(segmentContexts);
370378
} catch (e) {
371379
$scope.response = {};

src/app/directives/sidebar.tpl.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,19 @@ <h3 class="raml-console-sidebar-head">
1818
</header>
1919

2020
<div class="raml-console-sidebar-content-wrapper">
21-
<section>
21+
<section ng-if="raml.protocols.length > 1">
2222
<header class="raml-console-sidebar-row raml-console-sidebar-subheader raml-console-sidebar-subheader-top">
23+
<h4 class="raml-console-sidebar-subhead">Protocols</h4>
24+
</header>
25+
<div class="raml-console-sidebar-row raml-console-sidebar-securty">
26+
<select ng-change="protocolChanged(currentProtocol)" class="raml-console-sidebar-input" ng-model="currentProtocol" style="margin-bottom: 0;">
27+
<option ng-repeat="protocol in raml.protocols" value="{{protocol}}">{{protocol}}</option>
28+
</select>
29+
</div>
30+
</section>
31+
32+
<section>
33+
<header class="raml-console-sidebar-row raml-console-sidebar-subheader" ng-class="{'raml-console-sidebar-subheader-top':raml.protocols.length == 1}">
2334
<h4 class="raml-console-sidebar-subhead">Authentication</h4>
2435
</header>
2536

src/assets/examples/leagues.raml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ resourceTypes:
5959
traits:
6060
- filterable: {}
6161

62-
securedBy: [ basic, digest_auth, oauth_2_0, custom_scheme_1, custom_scheme_2 ]
62+
securedBy: [ null, basic, digest_auth, oauth_2_0, custom_scheme_1, custom_scheme_2 ]
6363

6464
/teams:
6565
type: base

0 commit comments

Comments
 (0)