fixes for content-type
This commit is contained in:
2
dist/index.html
vendored
2
dist/index.html
vendored
@@ -20,7 +20,7 @@
|
|||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
$(function () {
|
||||||
window.swaggerUi = new SwaggerUi({
|
window.swaggerUi = new SwaggerUi({
|
||||||
url: "http://petstore.swagger.wordnik.com/api/api-docs",
|
url: "http://localhost:8002/api/api-docs",
|
||||||
dom_id: "swagger-ui-container",
|
dom_id: "swagger-ui-container",
|
||||||
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
|
||||||
onComplete: function(swaggerApi, swaggerUi){
|
onComplete: function(swaggerApi, swaggerUi){
|
||||||
|
|||||||
39
dist/lib/swagger.js
vendored
39
dist/lib/swagger.js
vendored
@@ -73,6 +73,7 @@
|
|||||||
}
|
}
|
||||||
_this.apis = {};
|
_this.apis = {};
|
||||||
_this.apisArray = [];
|
_this.apisArray = [];
|
||||||
|
_this.produces = response.produces;
|
||||||
if (response.info != null) {
|
if (response.info != null) {
|
||||||
_this.info = response.info;
|
_this.info = response.info;
|
||||||
}
|
}
|
||||||
@@ -215,6 +216,7 @@
|
|||||||
produces = [];
|
produces = [];
|
||||||
consumes = [];
|
consumes = [];
|
||||||
this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
|
this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
|
||||||
|
console.log("we produce " + resourceObj.produces);
|
||||||
console.log('using path ' + this.path);
|
console.log('using path ' + this.path);
|
||||||
this.description = resourceObj.description;
|
this.description = resourceObj.description;
|
||||||
parts = this.path.split("/");
|
parts = this.path.split("/");
|
||||||
@@ -278,7 +280,7 @@
|
|||||||
_ref = response.apis;
|
_ref = response.apis;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
endpoint = _ref[_i];
|
endpoint = _ref[_i];
|
||||||
this.addOperations(endpoint.path, endpoint.operations);
|
this.addOperations(endpoint.path, endpoint.operations, response.consumes, response.produces);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.api[this.name] = this;
|
this.api[this.name] = this;
|
||||||
@@ -306,14 +308,14 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerResource.prototype.addOperations = function(resource_path, ops) {
|
SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes, produces) {
|
||||||
var consumes, method, o, op, produces, responseMessages, _i, _len, _results;
|
var method, o, op, responseMessages, type, _i, _len, _results;
|
||||||
if (ops) {
|
if (ops) {
|
||||||
_results = [];
|
_results = [];
|
||||||
for (_i = 0, _len = ops.length; _i < _len; _i++) {
|
for (_i = 0, _len = ops.length; _i < _len; _i++) {
|
||||||
o = ops[_i];
|
o = ops[_i];
|
||||||
consumes = null;
|
consumes = this.consumes;
|
||||||
produces = null;
|
produces = this.produces;
|
||||||
if (o.consumes != null) {
|
if (o.consumes != null) {
|
||||||
consumes = o.consumes;
|
consumes = o.consumes;
|
||||||
} else {
|
} else {
|
||||||
@@ -324,6 +326,7 @@
|
|||||||
} else {
|
} else {
|
||||||
produces = this.produces;
|
produces = this.produces;
|
||||||
}
|
}
|
||||||
|
type = o.type || o.responseClass;
|
||||||
responseMessages = o.responseMessages;
|
responseMessages = o.responseMessages;
|
||||||
method = o.method;
|
method = o.method;
|
||||||
if (o.httpMethod) {
|
if (o.httpMethod) {
|
||||||
@@ -336,7 +339,7 @@
|
|||||||
responseMessages = o.errorResponses;
|
responseMessages = o.errorResponses;
|
||||||
}
|
}
|
||||||
o.nickname = this.sanitize(o.nickname);
|
o.nickname = this.sanitize(o.nickname);
|
||||||
op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, o.responseClass, responseMessages, this, consumes, produces);
|
op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, type, responseMessages, this, consumes, produces);
|
||||||
this.operations[op.nickname] = op;
|
this.operations[op.nickname] = op;
|
||||||
_results.push(this.operationsArray.push(op));
|
_results.push(this.operationsArray.push(op));
|
||||||
}
|
}
|
||||||
@@ -515,8 +518,8 @@
|
|||||||
|
|
||||||
SwaggerOperation = (function() {
|
SwaggerOperation = (function() {
|
||||||
|
|
||||||
function SwaggerOperation(nickname, path, method, parameters, summary, notes, responseClass, responseMessages, resource, consumes, produces) {
|
function SwaggerOperation(nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces) {
|
||||||
var parameter, type, 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;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
@@ -524,7 +527,7 @@
|
|||||||
this.parameters = parameters != null ? parameters : [];
|
this.parameters = parameters != null ? parameters : [];
|
||||||
this.summary = summary;
|
this.summary = summary;
|
||||||
this.notes = notes;
|
this.notes = notes;
|
||||||
this.responseClass = responseClass;
|
this.type = type;
|
||||||
this.responseMessages = responseMessages;
|
this.responseMessages = responseMessages;
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
this.consumes = consumes;
|
this.consumes = consumes;
|
||||||
@@ -544,12 +547,12 @@
|
|||||||
this.method = this.method.toLowerCase();
|
this.method = this.method.toLowerCase();
|
||||||
this.isGetMethod = this.method === "get";
|
this.isGetMethod = this.method === "get";
|
||||||
this.resourceName = this.resource.name;
|
this.resourceName = this.resource.name;
|
||||||
if (((_ref = this.responseClass) != null ? _ref.toLowerCase() : void 0) === 'void') {
|
if (((_ref = this.type) != null ? _ref.toLowerCase() : void 0) === 'void') {
|
||||||
this.responseClass = void 0;
|
this.type = void 0;
|
||||||
}
|
}
|
||||||
if (this.responseClass != null) {
|
if (this.type != null) {
|
||||||
this.responseClassSignature = this.getSignature(this.responseClass, this.resource.models);
|
this.responseClassSignature = this.getSignature(this.type, this.resource.models);
|
||||||
this.responseSampleJSON = this.getSampleJSON(this.responseClass, this.resource.models);
|
this.responseSampleJSON = this.getSampleJSON(this.type, this.resource.models);
|
||||||
}
|
}
|
||||||
this.responseMessages = this.responseMessages || [];
|
this.responseMessages = this.responseMessages || [];
|
||||||
_ref1 = this.parameters;
|
_ref1 = this.parameters;
|
||||||
@@ -880,14 +883,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
responseContentType = null;
|
responseContentType = null;
|
||||||
if (this.type === "POST" || this.type === "GET" || this.type === "PATCH" || this.type === "PUT") {
|
if (this.type === "POST" || this.type === "GET" || this.type === "PATCH") {
|
||||||
if (this.opts.responseContentType) {
|
if (this.opts.responseContentType) {
|
||||||
requestContentType = this.opts.requestContentType;
|
responseContentType = this.opts.responseContentType;
|
||||||
} else {
|
} else {
|
||||||
requestContentType = "application/json";
|
responseContentType = "application/json";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
requestContentType = null;
|
responseContentType = null;
|
||||||
}
|
}
|
||||||
if (responseContentType && this.operation.produces) {
|
if (responseContentType && this.operation.produces) {
|
||||||
if (this.operation.produces.indexOf(responseContentType) === -1) {
|
if (this.operation.produces.indexOf(responseContentType) === -1) {
|
||||||
|
|||||||
6
dist/swagger-ui.js
vendored
6
dist/swagger-ui.js
vendored
@@ -552,8 +552,8 @@ function program11(depth0,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 ";
|
buffer += "\n ";
|
||||||
foundHelper = helpers.responseClass;
|
foundHelper = helpers.type;
|
||||||
stack1 = foundHelper || depth0.responseClass;
|
stack1 = foundHelper || depth0.type;
|
||||||
stack2 = helpers['if'];
|
stack2 = helpers['if'];
|
||||||
tmp1 = self.program(3, program3, data);
|
tmp1 = self.program(3, program3, data);
|
||||||
tmp1.hash = {};
|
tmp1.hash = {};
|
||||||
@@ -1747,7 +1747,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
|
|||||||
});
|
});
|
||||||
$('.model-signature', $(this.el)).append(responseSignatureView.render().el);
|
$('.model-signature', $(this.el)).append(responseSignatureView.render().el);
|
||||||
} else {
|
} else {
|
||||||
$('.model-signature', $(this.el)).html(this.model.responseClass);
|
$('.model-signature', $(this.el)).html(this.model.type);
|
||||||
}
|
}
|
||||||
contentTypeModel = {
|
contentTypeModel = {
|
||||||
isParam: false
|
isParam: false
|
||||||
|
|||||||
2
dist/swagger-ui.min.js
vendored
2
dist/swagger-ui.min.js
vendored
File diff suppressed because one or more lines are too long
@@ -73,6 +73,7 @@
|
|||||||
}
|
}
|
||||||
_this.apis = {};
|
_this.apis = {};
|
||||||
_this.apisArray = [];
|
_this.apisArray = [];
|
||||||
|
_this.produces = response.produces;
|
||||||
if (response.info != null) {
|
if (response.info != null) {
|
||||||
_this.info = response.info;
|
_this.info = response.info;
|
||||||
}
|
}
|
||||||
@@ -215,6 +216,7 @@
|
|||||||
produces = [];
|
produces = [];
|
||||||
consumes = [];
|
consumes = [];
|
||||||
this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
|
this.path = this.api.resourcePath != null ? this.api.resourcePath : resourceObj.path;
|
||||||
|
console.log("we produce " + resourceObj.produces);
|
||||||
console.log('using path ' + this.path);
|
console.log('using path ' + this.path);
|
||||||
this.description = resourceObj.description;
|
this.description = resourceObj.description;
|
||||||
parts = this.path.split("/");
|
parts = this.path.split("/");
|
||||||
@@ -278,7 +280,7 @@
|
|||||||
_ref = response.apis;
|
_ref = response.apis;
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
||||||
endpoint = _ref[_i];
|
endpoint = _ref[_i];
|
||||||
this.addOperations(endpoint.path, endpoint.operations);
|
this.addOperations(endpoint.path, endpoint.operations, response.consumes, response.produces);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.api[this.name] = this;
|
this.api[this.name] = this;
|
||||||
@@ -306,14 +308,14 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
SwaggerResource.prototype.addOperations = function(resource_path, ops) {
|
SwaggerResource.prototype.addOperations = function(resource_path, ops, consumes, produces) {
|
||||||
var consumes, method, o, op, produces, responseMessages, _i, _len, _results;
|
var method, o, op, responseMessages, type, _i, _len, _results;
|
||||||
if (ops) {
|
if (ops) {
|
||||||
_results = [];
|
_results = [];
|
||||||
for (_i = 0, _len = ops.length; _i < _len; _i++) {
|
for (_i = 0, _len = ops.length; _i < _len; _i++) {
|
||||||
o = ops[_i];
|
o = ops[_i];
|
||||||
consumes = null;
|
consumes = this.consumes;
|
||||||
produces = null;
|
produces = this.produces;
|
||||||
if (o.consumes != null) {
|
if (o.consumes != null) {
|
||||||
consumes = o.consumes;
|
consumes = o.consumes;
|
||||||
} else {
|
} else {
|
||||||
@@ -324,6 +326,7 @@
|
|||||||
} else {
|
} else {
|
||||||
produces = this.produces;
|
produces = this.produces;
|
||||||
}
|
}
|
||||||
|
type = o.type || o.responseClass;
|
||||||
responseMessages = o.responseMessages;
|
responseMessages = o.responseMessages;
|
||||||
method = o.method;
|
method = o.method;
|
||||||
if (o.httpMethod) {
|
if (o.httpMethod) {
|
||||||
@@ -336,7 +339,7 @@
|
|||||||
responseMessages = o.errorResponses;
|
responseMessages = o.errorResponses;
|
||||||
}
|
}
|
||||||
o.nickname = this.sanitize(o.nickname);
|
o.nickname = this.sanitize(o.nickname);
|
||||||
op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, o.responseClass, responseMessages, this, consumes, produces);
|
op = new SwaggerOperation(o.nickname, resource_path, method, o.parameters, o.summary, o.notes, type, responseMessages, this, consumes, produces);
|
||||||
this.operations[op.nickname] = op;
|
this.operations[op.nickname] = op;
|
||||||
_results.push(this.operationsArray.push(op));
|
_results.push(this.operationsArray.push(op));
|
||||||
}
|
}
|
||||||
@@ -515,8 +518,8 @@
|
|||||||
|
|
||||||
SwaggerOperation = (function() {
|
SwaggerOperation = (function() {
|
||||||
|
|
||||||
function SwaggerOperation(nickname, path, method, parameters, summary, notes, responseClass, responseMessages, resource, consumes, produces) {
|
function SwaggerOperation(nickname, path, method, parameters, summary, notes, type, responseMessages, resource, consumes, produces) {
|
||||||
var parameter, type, 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;
|
||||||
this.path = path;
|
this.path = path;
|
||||||
@@ -524,7 +527,7 @@
|
|||||||
this.parameters = parameters != null ? parameters : [];
|
this.parameters = parameters != null ? parameters : [];
|
||||||
this.summary = summary;
|
this.summary = summary;
|
||||||
this.notes = notes;
|
this.notes = notes;
|
||||||
this.responseClass = responseClass;
|
this.type = type;
|
||||||
this.responseMessages = responseMessages;
|
this.responseMessages = responseMessages;
|
||||||
this.resource = resource;
|
this.resource = resource;
|
||||||
this.consumes = consumes;
|
this.consumes = consumes;
|
||||||
@@ -544,12 +547,12 @@
|
|||||||
this.method = this.method.toLowerCase();
|
this.method = this.method.toLowerCase();
|
||||||
this.isGetMethod = this.method === "get";
|
this.isGetMethod = this.method === "get";
|
||||||
this.resourceName = this.resource.name;
|
this.resourceName = this.resource.name;
|
||||||
if (((_ref = this.responseClass) != null ? _ref.toLowerCase() : void 0) === 'void') {
|
if (((_ref = this.type) != null ? _ref.toLowerCase() : void 0) === 'void') {
|
||||||
this.responseClass = void 0;
|
this.type = void 0;
|
||||||
}
|
}
|
||||||
if (this.responseClass != null) {
|
if (this.type != null) {
|
||||||
this.responseClassSignature = this.getSignature(this.responseClass, this.resource.models);
|
this.responseClassSignature = this.getSignature(this.type, this.resource.models);
|
||||||
this.responseSampleJSON = this.getSampleJSON(this.responseClass, this.resource.models);
|
this.responseSampleJSON = this.getSampleJSON(this.type, this.resource.models);
|
||||||
}
|
}
|
||||||
this.responseMessages = this.responseMessages || [];
|
this.responseMessages = this.responseMessages || [];
|
||||||
_ref1 = this.parameters;
|
_ref1 = this.parameters;
|
||||||
@@ -880,14 +883,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
responseContentType = null;
|
responseContentType = null;
|
||||||
if (this.type === "POST" || this.type === "GET" || this.type === "PATCH" || this.type === "PUT") {
|
if (this.type === "POST" || this.type === "GET" || this.type === "PATCH") {
|
||||||
if (this.opts.responseContentType) {
|
if (this.opts.responseContentType) {
|
||||||
requestContentType = this.opts.requestContentType;
|
responseContentType = this.opts.responseContentType;
|
||||||
} else {
|
} else {
|
||||||
requestContentType = "application/json";
|
responseContentType = "application/json";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
requestContentType = null;
|
responseContentType = null;
|
||||||
}
|
}
|
||||||
if (responseContentType && this.operation.produces) {
|
if (responseContentType && this.operation.produces) {
|
||||||
if (this.operation.produces.indexOf(responseContentType) === -1) {
|
if (this.operation.produces.indexOf(responseContentType) === -1) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "swagger-ui",
|
"name": "swagger-ui",
|
||||||
"version": "2.0.0-develop",
|
"version": "2.0.0",
|
||||||
"description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API",
|
"description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "PATH=$PATH:./node_modules/.bin cake dist",
|
"build": "PATH=$PATH:./node_modules/.bin cake dist",
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class OperationView extends Backbone.View
|
|||||||
responseSignatureView = new SignatureView({model: signatureModel, tagName: 'div'})
|
responseSignatureView = new SignatureView({model: signatureModel, tagName: 'div'})
|
||||||
$('.model-signature', $(@el)).append responseSignatureView.render().el
|
$('.model-signature', $(@el)).append responseSignatureView.render().el
|
||||||
else
|
else
|
||||||
$('.model-signature', $(@el)).html(@model.responseClass)
|
$('.model-signature', $(@el)).html(@model.type)
|
||||||
|
|
||||||
contentTypeModel =
|
contentTypeModel =
|
||||||
isParam: false
|
isParam: false
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
<h4>Implementation Notes</h4>
|
<h4>Implementation Notes</h4>
|
||||||
<p>{{{notes}}}</p>
|
<p>{{{notes}}}</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if responseClass}}
|
{{#if type}}
|
||||||
<h4>Response Class</h4>
|
<h4>Response Class</h4>
|
||||||
<p><span class="model-signature" /></p>
|
<p><span class="model-signature" /></p>
|
||||||
<br/>
|
<br/>
|
||||||
|
|||||||
Reference in New Issue
Block a user