ソースを参照

added api info

bubble
Tony Tam 11年前
コミット
e980cca6b4
10個のファイルの変更189行の追加10行の削除
  1. +28
    -0
      dist/css/screen.css
  2. +2
    -3
      dist/index.html
  3. +5
    -0
      dist/lib/swagger.js
  4. +107
    -2
      dist/swagger-ui.js
  5. +1
    -1
      dist/swagger-ui.min.js
  6. +5
    -0
      lib/swagger.js
  7. +2
    -0
      src/main/coffeescript/SwaggerUi.coffee
  8. +28
    -0
      src/main/html/css/screen.css
  9. +2
    -3
      src/main/html/index.html
  10. +9
    -1
      src/main/template/main.handlebars

+ 28
- 0
dist/css/screen.css ファイルの表示

@@ -1756,4 +1756,32 @@ pre code {

.message-fail {
color: #cc0000;
}

.info_title {
padding-left: 25px;
padding-bottom: 10px;
font-weight: bold;
font-size: 25px;
}

.info_description {
padding-left: 25px;
padding-bottom: 10px;
font-size: 15px;
}

.info_tos {
padding-left: 25px;
padding-bottom: 5px;
}

.info_license {
padding-left: 25px;
padding-bottom: 5px;
}

.info_contact {
padding-left: 25px;
padding-bottom: 5px;
}

+ 2
- 3
dist/index.html ファイルの表示

@@ -20,9 +20,8 @@
<script type="text/javascript">
$(function () {
window.swaggerUi = new SwaggerUi({
url:"http://petstore.swagger.wordnik.com/api/api-docs.json",
dom_id:"swagger-ui-container",
supportHeaderParams: false,
url: "http://localhost:8002/api/api-docs",
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
onComplete: function(swaggerApi, swaggerUi){
if(console) {


+ 5
- 0
dist/lib/swagger.js ファイルの表示

@@ -15,6 +15,8 @@

SwaggerApi.prototype.authorizationScheme = null;

SwaggerApi.prototype.info = null;

function SwaggerApi(url, options) {
if (options == null) {
options = {};
@@ -71,6 +73,9 @@
}
_this.apis = {};
_this.apisArray = [];
if (response.info != null) {
_this.info = response.info;
}
isApi = false;
_ref = response.apis;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {


+ 107
- 2
dist/swagger-ui.js ファイルの表示

@@ -246,6 +246,99 @@ templates['main'] = template(function (Handlebars,depth0,helpers,partials,data)

function program1(depth0,data) {
var buffer = "", stack1, stack2;
buffer += "\n <div class=\"info_title\">";
foundHelper = helpers.info;
stack1 = foundHelper || depth0.info;
stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1.title);
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "info.title", { hash: {} }); }
buffer += escapeExpression(stack1) + "</div>\n <div class=\"info_description\">";
foundHelper = helpers.info;
stack1 = foundHelper || depth0.info;
stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1.description);
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "info.description", { hash: {} }); }
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "</div>\n ";
foundHelper = helpers.info;
stack1 = foundHelper || depth0.info;
stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1.termsOfServiceUrl);
stack2 = helpers['if'];
tmp1 = self.program(2, program2, data);
tmp1.hash = {};
tmp1.fn = tmp1;
tmp1.inverse = self.noop;
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
foundHelper = helpers.info;
stack1 = foundHelper || depth0.info;
stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1.contact);
stack2 = helpers['if'];
tmp1 = self.program(4, program4, data);
tmp1.hash = {};
tmp1.fn = tmp1;
tmp1.inverse = self.noop;
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
foundHelper = helpers.info;
stack1 = foundHelper || depth0.info;
stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1.license);
stack2 = helpers['if'];
tmp1 = self.program(6, program6, data);
tmp1.hash = {};
tmp1.fn = tmp1;
tmp1.inverse = self.noop;
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
return buffer;}
function program2(depth0,data) {
var buffer = "", stack1;
buffer += "<div class=\"info_tos\"><a href=\"";
foundHelper = helpers.info;
stack1 = foundHelper || depth0.info;
stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1.termsOfServiceUrl);
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "info.termsOfServiceUrl", { hash: {} }); }
buffer += escapeExpression(stack1) + "\">Terms of service</a></div>";
return buffer;}

function program4(depth0,data) {
var buffer = "", stack1;
buffer += "<div class='info_contact'><a href=\"mailto:";
foundHelper = helpers.info;
stack1 = foundHelper || depth0.info;
stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1.contact);
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "info.contact", { hash: {} }); }
buffer += escapeExpression(stack1) + "\">Contact the developer</a></div>";
return buffer;}

function program6(depth0,data) {
var buffer = "", stack1;
buffer += "<div class='info_license'><a href='";
foundHelper = helpers.info;
stack1 = foundHelper || depth0.info;
stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1.licenseUrl);
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "info.licenseUrl", { hash: {} }); }
buffer += escapeExpression(stack1) + "'>";
foundHelper = helpers.info;
stack1 = foundHelper || depth0.info;
stack1 = (stack1 === null || stack1 === undefined || stack1 === false ? stack1 : stack1.license);
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
else if(stack1=== undef) { stack1 = helperMissing.call(depth0, "info.license", { hash: {} }); }
buffer += escapeExpression(stack1) + "</a></div>";
return buffer;}

function program8(depth0,data) {
var buffer = "", stack1;
buffer += "\n , <span style=\"font-variant: small-caps\">api version</span>: ";
foundHelper = helpers.apiVersion;
@@ -255,7 +348,17 @@ function program1(depth0,data) {
buffer += escapeExpression(stack1) + "\n ";
return buffer;}

buffer += "\n<div class='container' id='resources_container'>\n <ul id='resources'>\n </ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: ";
buffer += "<div class='info' id='api_info'>\n ";
foundHelper = helpers.info;
stack1 = foundHelper || depth0.info;
stack2 = helpers['if'];
tmp1 = self.program(1, program1, data);
tmp1.hash = {};
tmp1.fn = tmp1;
tmp1.inverse = self.noop;
stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n</div>\n<div class='container' id='resources_container'>\n <ul id='resources'>\n </ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: ";
foundHelper = helpers.basePath;
stack1 = foundHelper || depth0.basePath;
if(typeof stack1 === functionType) { stack1 = stack1.call(depth0, { hash: {} }); }
@@ -264,7 +367,7 @@ function program1(depth0,data) {
foundHelper = helpers.apiVersion;
stack1 = foundHelper || depth0.apiVersion;
stack2 = helpers['if'];
tmp1 = self.program(1, program1, data);
tmp1 = self.program(8, program8, data);
tmp1.hash = {};
tmp1.fn = tmp1;
tmp1.inverse = self.noop;
@@ -1402,6 +1505,8 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
SwaggerUi.prototype.render = function() {
var _this = this;
this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...');
console.log("here it comes!");
console.log(this.api);
this.mainView = new MainView({
model: this.api,
el: $('#' + this.dom_id)


+ 1
- 1
dist/swagger-ui.min.js
ファイル差分が大きすぎるため省略します
ファイルの表示


+ 5
- 0
lib/swagger.js ファイルの表示

@@ -15,6 +15,8 @@

SwaggerApi.prototype.authorizationScheme = null;

SwaggerApi.prototype.info = null;

function SwaggerApi(url, options) {
if (options == null) {
options = {};
@@ -71,6 +73,9 @@
}
_this.apis = {};
_this.apisArray = [];
if (response.info != null) {
_this.info = response.info;
}
isApi = false;
_ref = response.apis;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {


+ 2
- 0
src/main/coffeescript/SwaggerUi.coffee ファイルの表示

@@ -50,6 +50,8 @@ class SwaggerUi extends Backbone.Router
# so it gets called when SwaggerApi completes loading
render:() ->
@showMessage('Finished Loading Resource Information. Rendering Swagger UI...')
console.log "here it comes!"
console.log @api
@mainView = new MainView({model: @api, el: $('#' + @dom_id)}).render()
@showMessage()
switch @options.docExpansion


+ 28
- 0
src/main/html/css/screen.css ファイルの表示

@@ -1756,4 +1756,32 @@ pre code {

.message-fail {
color: #cc0000;
}

.info_title {
padding-left: 25px;
padding-bottom: 10px;
font-weight: bold;
font-size: 25px;
}

.info_description {
padding-left: 25px;
padding-bottom: 10px;
font-size: 15px;
}

.info_tos {
padding-left: 25px;
padding-bottom: 5px;
}

.info_license {
padding-left: 25px;
padding-bottom: 5px;
}

.info_contact {
padding-left: 25px;
padding-bottom: 5px;
}

+ 2
- 3
src/main/html/index.html ファイルの表示

@@ -20,9 +20,8 @@
<script type="text/javascript">
$(function () {
window.swaggerUi = new SwaggerUi({
url:"http://petstore.swagger.wordnik.com/api/api-docs.json",
dom_id:"swagger-ui-container",
supportHeaderParams: false,
url: "http://localhost:8002/api/api-docs",
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
onComplete: function(swaggerApi, swaggerUi){
if(console) {


+ 9
- 1
src/main/template/main.handlebars ファイルの表示

@@ -1,4 +1,12 @@

<div class='info' id='api_info'>
{{#if info}}
<div class="info_title">{{info.title}}</div>
<div class="info_description">{{{info.description}}}</div>
{{#if info.termsOfServiceUrl}}<div class="info_tos"><a href="{{info.termsOfServiceUrl}}">Terms of service</a></div>{{/if}}
{{#if info.contact}}<div class='info_contact'><a href="mailto:{{info.contact}}">Contact the developer</a></div>{{/if}}
{{#if info.license}}<div class='info_license'><a href='{{info.licenseUrl}}'>{{info.license}}</a></div>{{/if}}
{{/if}}
</div>
<div class='container' id='resources_container'>
<ul id='resources'>
</ul>


読み込み中…
キャンセル
保存