Skip to content

Commit 3e9ef05

Browse files
committed
Render externalDocs when it's available
1 parent eeb83a4 commit 3e9ef05

File tree

4 files changed

+39
-22
lines changed

4 files changed

+39
-22
lines changed

dist/swagger-ui.js

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -431,59 +431,71 @@ this["Handlebars"]["templates"]["main"] = Handlebars.template({"1":function(dept
431431
+ "</div>\n <div class=\"info_description markdown\">";
432432
stack1 = lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.description : stack1), depth0);
433433
if (stack1 != null) { buffer += stack1; }
434-
buffer += "</div>\n ";
435-
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.termsOfServiceUrl : stack1), {"name":"if","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data});
434+
buffer += "</div>\n";
435+
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.externalDocs : depth0), {"name":"if","hash":{},"fn":this.program(2, data),"inverse":this.noop,"data":data});
436+
if (stack1 != null) { buffer += stack1; }
437+
buffer += " ";
438+
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.termsOfServiceUrl : stack1), {"name":"if","hash":{},"fn":this.program(4, data),"inverse":this.noop,"data":data});
436439
if (stack1 != null) { buffer += stack1; }
437440
buffer += "\n ";
438-
stack1 = helpers['if'].call(depth0, ((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.name : stack1), {"name":"if","hash":{},"fn":this.program(4, data),"inverse":this.noop,"data":data});
441+
stack1 = helpers['if'].call(depth0, ((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.name : stack1), {"name":"if","hash":{},"fn":this.program(6, data),"inverse":this.noop,"data":data});
439442
if (stack1 != null) { buffer += stack1; }
440443
buffer += "\n ";
441-
stack1 = helpers['if'].call(depth0, ((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.url : stack1), {"name":"if","hash":{},"fn":this.program(6, data),"inverse":this.noop,"data":data});
444+
stack1 = helpers['if'].call(depth0, ((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.url : stack1), {"name":"if","hash":{},"fn":this.program(8, data),"inverse":this.noop,"data":data});
442445
if (stack1 != null) { buffer += stack1; }
443446
buffer += "\n ";
444-
stack1 = helpers['if'].call(depth0, ((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.email : stack1), {"name":"if","hash":{},"fn":this.program(8, data),"inverse":this.noop,"data":data});
447+
stack1 = helpers['if'].call(depth0, ((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.email : stack1), {"name":"if","hash":{},"fn":this.program(10, data),"inverse":this.noop,"data":data});
445448
if (stack1 != null) { buffer += stack1; }
446449
buffer += "\n ";
447-
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.license : stack1), {"name":"if","hash":{},"fn":this.program(10, data),"inverse":this.noop,"data":data});
450+
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.license : stack1), {"name":"if","hash":{},"fn":this.program(12, data),"inverse":this.noop,"data":data});
448451
if (stack1 != null) { buffer += stack1; }
449452
return buffer + "\n";
450453
},"2":function(depth0,helpers,partials,data) {
454+
var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
455+
return " <h5>More documentations</h5>\n <p>"
456+
+ escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.externalDocs : depth0)) != null ? stack1.description : stack1), depth0))
457+
+ "</p>\n <a href=\""
458+
+ escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.externalDocs : depth0)) != null ? stack1.url : stack1), depth0))
459+
+ "\" target=\"_blank\">"
460+
+ escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.externalDocs : depth0)) != null ? stack1.url : stack1), depth0))
461+
+ "</a>\n";
462+
},"4":function(depth0,helpers,partials,data) {
451463
var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
452464
return "<div class=\"info_tos\"><a href=\""
453465
+ escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.termsOfServiceUrl : stack1), depth0))
454466
+ "\">Terms of service</a></div>";
455-
},"4":function(depth0,helpers,partials,data) {
467+
},"6":function(depth0,helpers,partials,data) {
456468
var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
457469
return "<div class='info_name'>Created by "
458470
+ escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.name : stack1), depth0))
459471
+ "</div>";
460-
},"6":function(depth0,helpers,partials,data) {
472+
},"8":function(depth0,helpers,partials,data) {
461473
var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
462474
return "<div class='info_url'>See more at <a href=\""
463475
+ escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.url : stack1), depth0))
464476
+ "\">"
465477
+ escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.url : stack1), depth0))
466478
+ "</a></div>";
467-
},"8":function(depth0,helpers,partials,data) {
479+
},"10":function(depth0,helpers,partials,data) {
468480
var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
469481
return "<div class='info_email'><a href=\"mailto:"
470482
+ escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.contact : stack1)) != null ? stack1.email : stack1), depth0))
471483
+ "?subject="
472484
+ escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.title : stack1), depth0))
473485
+ "\">Contact the developer</a></div>";
474-
},"10":function(depth0,helpers,partials,data) {
486+
},"12":function(depth0,helpers,partials,data) {
475487
var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
476488
return "<div class='info_license'><a href='"
477489
+ escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.license : stack1)) != null ? stack1.url : stack1), depth0))
478490
+ "'>"
479491
+ escapeExpression(lambda(((stack1 = ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.license : stack1)) != null ? stack1.name : stack1), depth0))
480492
+ "</a></div>";
481-
},"12":function(depth0,helpers,partials,data) {
493+
},"14":function(depth0,helpers,partials,data) {
482494
var stack1, lambda=this.lambda, escapeExpression=this.escapeExpression;
483495
return " , <span style=\"font-variant: small-caps\">api version</span>: "
484496
+ escapeExpression(lambda(((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.version : stack1), depth0))
485497
+ "\n ";
486-
},"14":function(depth0,helpers,partials,data) {
498+
},"16":function(depth0,helpers,partials,data) {
487499
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
488500
return " <span style=\"float:right\"><a href=\""
489501
+ escapeExpression(((helper = (helper = helpers.validatorUrl || (depth0 != null ? depth0.validatorUrl : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"validatorUrl","hash":{},"data":data}) : helper)))
@@ -501,10 +513,10 @@ this["Handlebars"]["templates"]["main"] = Handlebars.template({"1":function(dept
501513
buffer += "</div>\n<div class='container' id='resources_container'>\n <ul id='resources'></ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: "
502514
+ escapeExpression(((helper = (helper = helpers.basePath || (depth0 != null ? depth0.basePath : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"basePath","hash":{},"data":data}) : helper)))
503515
+ "\n";
504-
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.version : stack1), {"name":"if","hash":{},"fn":this.program(12, data),"inverse":this.noop,"data":data});
516+
stack1 = helpers['if'].call(depth0, ((stack1 = (depth0 != null ? depth0.info : depth0)) != null ? stack1.version : stack1), {"name":"if","hash":{},"fn":this.program(14, data),"inverse":this.noop,"data":data});
505517
if (stack1 != null) { buffer += stack1; }
506518
buffer += "]\n";
507-
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.validatorUrl : depth0), {"name":"if","hash":{},"fn":this.program(14, data),"inverse":this.noop,"data":data});
519+
stack1 = helpers['if'].call(depth0, (depth0 != null ? depth0.validatorUrl : depth0), {"name":"if","hash":{},"fn":this.program(16, data),"inverse":this.noop,"data":data});
508520
if (stack1 != null) { buffer += stack1; }
509521
return buffer + " </h4>\n </div>\n</div>\n";
510522
},"useData":true});

dist/swagger-ui.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/coffeescript/view/MainView.coffee

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class MainView extends Backbone.View
2121
else
2222
# Default validator
2323
@model.validatorUrl = "http://online.swagger.io/validator"
24-
24+
2525
render: ->
2626
if @model.securityDefinitions
2727
for name of @model.securityDefinitions
@@ -61,10 +61,10 @@ class MainView extends Backbone.View
6161
# Render a resource and add it to resources li
6262
resource.id = resource.id.replace(/\s/g, '_')
6363
resourceView = new ResourceView({
64-
model: resource,
65-
tagName: 'li',
66-
id: 'resource_' + resource.id,
67-
className: 'resource',
64+
model: resource,
65+
tagName: 'li',
66+
id: 'resource_' + resource.id,
67+
className: 'resource',
6868
auths: auths,
6969
swaggerOptions: @options.swaggerOptions
7070
})

src/main/template/main.handlebars

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
{{#if info}}
33
<div class="info_title">{{info.title}}</div>
44
<div class="info_description markdown">{{{info.description}}}</div>
5+
{{#if externalDocs}}
6+
<h5>More documentations</h5>
7+
<p>{{externalDocs.description}}</p>
8+
<a href="{{externalDocs.url}}" target="_blank">{{externalDocs.url}}</a>
9+
{{/if}}
510
{{#if info.termsOfServiceUrl}}<div class="info_tos"><a href="{{info.termsOfServiceUrl}}">Terms of service</a></div>{{/if}}
611
{{#if info.contact.name}}<div class='info_name'>Created by {{info.contact.name}}</div>{{/if}}
712
{{#if info.contact.url}}<div class='info_url'>See more at <a href="{{info.contact.url}}">{{info.contact.url}}</a></div>{{/if}}

0 commit comments

Comments
 (0)