Merge pull request #295 from tomrac87/hal_json

Proper formatting for "application/hal+json" Content-Type
This commit is contained in:
Tony Tam
2013-09-24 06:38:16 -07:00
2 changed files with 3 additions and 3 deletions

2
dist/swagger-ui.js vendored
View File

@@ -1735,7 +1735,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
if (content === void 0) { if (content === void 0) {
code = $('<code />').text("no content"); code = $('<code />').text("no content");
pre = $('<pre class="json" />').append(code); pre = $('<pre class="json" />').append(code);
} else if (contentType.indexOf("application/json") === 0) { } else if (contentType.indexOf("application/json") === 0 || contentType.indexOf("application/hal+json") === 0) {
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, 2)); code = $('<code />').text(JSON.stringify(JSON.parse(content), null, 2));
pre = $('<pre class="json" />').append(code); pre = $('<pre class="json" />').append(code);
} else if (contentType.indexOf("application/xml") === 0) { } else if (contentType.indexOf("application/xml") === 0) {

View File

@@ -205,7 +205,7 @@ class OperationView extends Backbone.View
if content == undefined if content == undefined
code = $('<code />').text("no content") code = $('<code />').text("no content")
pre = $('<pre class="json" />').append(code) pre = $('<pre class="json" />').append(code)
else if contentType.indexOf("application/json") == 0 else if contentType.indexOf("application/json") == 0 || contentType.indexOf("application/hal+json") == 0
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, 2)) code = $('<code />').text(JSON.stringify(JSON.parse(content), null, 2))
pre = $('<pre class="json" />').append(code) pre = $('<pre class="json" />').append(code)
else if contentType.indexOf("application/xml") == 0 else if contentType.indexOf("application/xml") == 0
@@ -231,4 +231,4 @@ class OperationView extends Backbone.View
toggleOperationContent: -> toggleOperationContent: ->
elem = $('#' + Docs.escapeResourceName(@model.resourceName) + "_" + @model.nickname + "_" + @model.method + "_" + @model.number + "_content") elem = $('#' + Docs.escapeResourceName(@model.resourceName) + "_" + @model.nickname + "_" + @model.method + "_" + @model.number + "_content")
if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem) if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem)