Browse Source

fix for #121

bubble
Tony Tam 11 years ago
parent
commit
9b1bd11f2d
10 changed files with 50 additions and 31 deletions
  1. +1
    -1
      dist/index.html
  2. +3
    -2
      dist/lib/swagger.js
  3. +31
    -16
      dist/swagger-ui.js
  4. +1
    -1
      dist/swagger-ui.min.js
  5. +3
    -2
      lib/swagger.js
  6. +3
    -3
      src/main/coffeescript/view/OperationView.coffee
  7. +3
    -3
      src/main/coffeescript/view/ParameterView.coffee
  8. +1
    -1
      src/main/html/index.html
  9. +2
    -2
      src/main/template/content_type.handlebars
  10. +2
    -0
      src/main/template/operation.handlebars

+ 1
- 1
dist/index.html View File

@@ -45,7 +45,7 @@
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
window.swaggerUi = new SwaggerUi({ window.swaggerUi = new SwaggerUi({
discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json",
discoveryUrl:"http://localhost:8002/api/api-docs.json",
apiKey:"special-key", apiKey:"special-key",
dom_id:"swagger-ui-container", dom_id:"swagger-ui-container",
supportHeaderParams: false, supportHeaderParams: false,


+ 3
- 2
dist/lib/swagger.js View File

@@ -269,7 +269,7 @@
if (o.supportedContentTypes) { if (o.supportedContentTypes) {
consumes = o.supportedContentTypes; consumes = o.supportedContentTypes;
} }
op = new SwaggerOperation(o.nickname, resource_path, o.httpMethod, o.parameters, o.summary, o.notes, o.responseClass, o.errorResponses, this, o.consumes);
op = new SwaggerOperation(o.nickname, resource_path, o.httpMethod, o.parameters, o.summary, o.notes, o.responseClass, o.errorResponses, this, o.consumes, o.produces);
this.operations[op.nickname] = op; this.operations[op.nickname] = op;
_results.push(this.operationsArray.push(op)); _results.push(this.operationsArray.push(op));
} }
@@ -427,7 +427,7 @@


SwaggerOperation = (function() { SwaggerOperation = (function() {


function SwaggerOperation(nickname, path, httpMethod, parameters, summary, notes, responseClass, errorResponses, resource, consumes) {
function SwaggerOperation(nickname, path, httpMethod, parameters, summary, notes, responseClass, errorResponses, resource, consumes, produces) {
var parameter, v, _i, _j, _len, _len1, _ref, _ref1, _ref2, var parameter, v, _i, _j, _len, _len1, _ref, _ref1, _ref2,
_this = this; _this = this;
this.nickname = nickname; this.nickname = nickname;
@@ -440,6 +440,7 @@
this.errorResponses = errorResponses; this.errorResponses = errorResponses;
this.resource = resource; this.resource = resource;
this.consumes = consumes; this.consumes = consumes;
this.produces = produces;
this["do"] = __bind(this["do"], this); this["do"] = __bind(this["do"], this);


if (this.nickname == null) { if (this.nickname == null) {


+ 31
- 16
dist/swagger-ui.js View File

@@ -192,8 +192,8 @@ function program1(depth0,data) {
var buffer = "", stack1, stack2; var buffer = "", stack1, stack2;
buffer += "\n "; buffer += "\n ";
foundHelper = helpers.consumes;
stack1 = foundHelper || depth0.consumes;
foundHelper = helpers.produces;
stack1 = foundHelper || depth0.produces;
stack2 = helpers.each; stack2 = helpers.each;
tmp1 = self.program(2, program2, data); tmp1 = self.program(2, program2, data);
tmp1.hash = {}; tmp1.hash = {};
@@ -225,8 +225,8 @@ function program4(depth0,data) {
return "\n <option value=\"application/json\">application/json</option>\n";} return "\n <option value=\"application/json\">application/json</option>\n";}


buffer += "<label for=\"contentType\"></label>\n<select name=\"contentType\">\n"; buffer += "<label for=\"contentType\"></label>\n<select name=\"contentType\">\n";
foundHelper = helpers.consumes;
stack1 = foundHelper || depth0.consumes;
foundHelper = helpers.produces;
stack1 = foundHelper || depth0.produces;
stack2 = helpers['if']; stack2 = helpers['if'];
tmp1 = self.program(1, program1, data); tmp1 = self.program(1, program1, data);
tmp1.hash = {}; tmp1.hash = {};
@@ -300,16 +300,21 @@ function program3(depth0,data) {
function program5(depth0,data) { function program5(depth0,data) {
return "\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Status Codes</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n ";}
return "\n <h4>Parameters</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th style=\"width: 100px; max-width: 100px\" >Parameter</th>\n <th style=\"width: 310px; max-width: 310px\">Value</th>\n <th style=\"width: 200px; max-width: 200px\">Description</th>\n <th style=\"width: 320px; max-width: 330px\">Data Type</th>\n </tr>\n </thead>\n <tbody class=\"operation-params\">\n\n </tbody>\n </table>\n ";}


function program7(depth0,data) { function program7(depth0,data) {
return "\n ";}
return "\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Status Codes</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n ";}


function program9(depth0,data) { function program9(depth0,data) {
return "\n ";}

function program11(depth0,data) {
return "\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />\n </div>\n ";} return "\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />\n </div>\n ";}


buffer += "\n <ul class='operations' >\n <li class='"; buffer += "\n <ul class='operations' >\n <li class='";
@@ -453,11 +458,21 @@ function program9(depth0,data) {
tmp1.inverse = self.noop; tmp1.inverse = self.noop;
stack1 = stack2.call(depth0, stack1, tmp1); stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; } if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Parameters</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th style=\"width: 100px; max-width: 100px\" >Parameter</th>\n <th style=\"width: 310px; max-width: 310px\">Value</th>\n <th style=\"width: 200px; max-width: 200px\">Description</th>\n <th style=\"width: 320px; max-width: 330px\">Data Type</th>\n </tr>\n </thead>\n <tbody class=\"operation-params\">\n\n </tbody>\n </table>\n ";
buffer += "\n <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n ";
foundHelper = helpers.parameters;
stack1 = foundHelper || depth0.parameters;
stack2 = helpers['if'];
tmp1 = self.program(5, program5, 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.errorResponses; foundHelper = helpers.errorResponses;
stack1 = foundHelper || depth0.errorResponses; stack1 = foundHelper || depth0.errorResponses;
stack2 = helpers['if']; stack2 = helpers['if'];
tmp1 = self.program(5, program5, data);
tmp1 = self.program(7, program7, data);
tmp1.hash = {}; tmp1.hash = {};
tmp1.fn = tmp1; tmp1.fn = tmp1;
tmp1.inverse = self.noop; tmp1.inverse = self.noop;
@@ -467,10 +482,10 @@ function program9(depth0,data) {
foundHelper = helpers.isReadOnly; foundHelper = helpers.isReadOnly;
stack1 = foundHelper || depth0.isReadOnly; stack1 = foundHelper || depth0.isReadOnly;
stack2 = helpers['if']; stack2 = helpers['if'];
tmp1 = self.program(7, program7, data);
tmp1 = self.program(9, program9, data);
tmp1.hash = {}; tmp1.hash = {};
tmp1.fn = tmp1; tmp1.fn = tmp1;
tmp1.inverse = self.program(9, program9, data);
tmp1.inverse = self.program(11, program11, data);
stack1 = stack2.call(depth0, stack1, tmp1); stack1 = stack2.call(depth0, stack1, tmp1);
if(stack1 || stack1 === 0) { buffer += stack1; } if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n"; buffer += "\n </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n";
@@ -1439,10 +1454,10 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
isParam: false isParam: false
}; };
if (this.model.supportedContentTypes) { if (this.model.supportedContentTypes) {
contentTypeModel.consumes = this.model.supportedContentTypes;
contentTypeModel.produces = this.model.supportedContentTypes;
} }
if (this.model.consumes) {
contentTypeModel.consumes = this.model.consumes;
if (this.model.produces) {
contentTypeModel.produces = this.model.produces;
} }
contentTypeView = new ContentTypeView({ contentTypeView = new ContentTypeView({
model: contentTypeModel model: contentTypeModel
@@ -1789,10 +1804,10 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
isParam: false isParam: false
}; };
if (this.model.supportedContentTypes) { if (this.model.supportedContentTypes) {
contentTypeModel.consumes = this.model.supportedContentTypes;
contentTypeModel.produces = this.model.supportedContentTypes;
} }
if (this.model.consumes) {
contentTypeModel.consumes = this.model.consumes;
if (this.model.produces) {
contentTypeModel.produces = this.model.produces;
} }
contentTypeView = new ContentTypeView({ contentTypeView = new ContentTypeView({
model: contentTypeModel model: contentTypeModel


+ 1
- 1
dist/swagger-ui.min.js
File diff suppressed because it is too large
View File


+ 3
- 2
lib/swagger.js View File

@@ -269,7 +269,7 @@
if (o.supportedContentTypes) { if (o.supportedContentTypes) {
consumes = o.supportedContentTypes; consumes = o.supportedContentTypes;
} }
op = new SwaggerOperation(o.nickname, resource_path, o.httpMethod, o.parameters, o.summary, o.notes, o.responseClass, o.errorResponses, this, o.consumes);
op = new SwaggerOperation(o.nickname, resource_path, o.httpMethod, o.parameters, o.summary, o.notes, o.responseClass, o.errorResponses, this, o.consumes, o.produces);
this.operations[op.nickname] = op; this.operations[op.nickname] = op;
_results.push(this.operationsArray.push(op)); _results.push(this.operationsArray.push(op));
} }
@@ -427,7 +427,7 @@


SwaggerOperation = (function() { SwaggerOperation = (function() {


function SwaggerOperation(nickname, path, httpMethod, parameters, summary, notes, responseClass, errorResponses, resource, consumes) {
function SwaggerOperation(nickname, path, httpMethod, parameters, summary, notes, responseClass, errorResponses, resource, consumes, produces) {
var parameter, v, _i, _j, _len, _len1, _ref, _ref1, _ref2, var parameter, v, _i, _j, _len, _len1, _ref, _ref1, _ref2,
_this = this; _this = this;
this.nickname = nickname; this.nickname = nickname;
@@ -440,6 +440,7 @@
this.errorResponses = errorResponses; this.errorResponses = errorResponses;
this.resource = resource; this.resource = resource;
this.consumes = consumes; this.consumes = consumes;
this.produces = produces;
this["do"] = __bind(this["do"], this); this["do"] = __bind(this["do"], this);


if (this.nickname == null) { if (this.nickname == null) {


+ 3
- 3
src/main/coffeescript/view/OperationView.coffee View File

@@ -30,10 +30,10 @@ class OperationView extends Backbone.View


# support old syntax # support old syntax
if @model.supportedContentTypes if @model.supportedContentTypes
contentTypeModel.consumes = @model.supportedContentTypes
contentTypeModel.produces = @model.supportedContentTypes


if @model.consumes
contentTypeModel.consumes = @model.consumes
if @model.produces
contentTypeModel.produces = @model.produces


contentTypeView = new ContentTypeView({model: contentTypeModel}) contentTypeView = new ContentTypeView({model: contentTypeModel})
$('.content-type', $(@el)).append contentTypeView.render().el $('.content-type', $(@el)).append contentTypeView.render().el


+ 3
- 3
src/main/coffeescript/view/ParameterView.coffee View File

@@ -24,10 +24,10 @@ class ParameterView extends Backbone.View


# support old syntax # support old syntax
if @model.supportedContentTypes if @model.supportedContentTypes
contentTypeModel.consumes = @model.supportedContentTypes
contentTypeModel.produces = @model.supportedContentTypes


if @model.consumes
contentTypeModel.consumes = @model.consumes
if @model.produces
contentTypeModel.produces = @model.produces


contentTypeView = new ContentTypeView({model: contentTypeModel}) contentTypeView = new ContentTypeView({model: contentTypeModel})
$('.content-type', $(@el)).append contentTypeView.render().el $('.content-type', $(@el)).append contentTypeView.render().el


+ 1
- 1
src/main/html/index.html View File

@@ -45,7 +45,7 @@
<script type="text/javascript"> <script type="text/javascript">
$(function () { $(function () {
window.swaggerUi = new SwaggerUi({ window.swaggerUi = new SwaggerUi({
discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json",
discoveryUrl:"http://localhost:8002/api/api-docs.json",
apiKey:"special-key", apiKey:"special-key",
dom_id:"swagger-ui-container", dom_id:"swagger-ui-container",
supportHeaderParams: false, supportHeaderParams: false,


+ 2
- 2
src/main/template/content_type.handlebars View File

@@ -1,7 +1,7 @@
<label for="contentType"></label> <label for="contentType"></label>
<select name="contentType"> <select name="contentType">
{{#if consumes}}
{{#each consumes}}
{{#if produces}}
{{#each produces}}
<option value="{{{this}}}">{{{this}}}</option> <option value="{{{this}}}">{{{this}}}</option>
{{/each}} {{/each}}
{{else}} {{else}}


+ 2
- 0
src/main/template/operation.handlebars View File

@@ -29,6 +29,7 @@
{{/if}} {{/if}}
<form accept-charset='UTF-8' class='sandbox'> <form accept-charset='UTF-8' class='sandbox'>
<div style='margin:0;padding:0;display:inline'></div> <div style='margin:0;padding:0;display:inline'></div>
{{#if parameters}}
<h4>Parameters</h4> <h4>Parameters</h4>
<table class='fullwidth'> <table class='fullwidth'>
<thead> <thead>
@@ -43,6 +44,7 @@


</tbody> </tbody>
</table> </table>
{{/if}}
{{#if errorResponses}} {{#if errorResponses}}
<div style='margin:0;padding:0;display:inline'></div> <div style='margin:0;padding:0;display:inline'></div>
<h4>Status Codes</h4> <h4>Status Codes</h4>


Loading…
Cancel
Save