JSONEditor enable/disable flag

This commit is contained in:
laurent lepinay
2015-03-12 07:12:07 -07:00
parent bfca6020d2
commit 447b905132
12 changed files with 1181 additions and 20 deletions

1
dist/css/print.css vendored
View File

@@ -433,7 +433,6 @@
width: 300px;
height: 100px;
border: 1px solid #aaa;
display: none;
}
.swagger-section .swagger-ui-wrap .markdown p code,
.swagger-section .swagger-ui-wrap .markdown li code {

1
dist/css/screen.css vendored
View File

@@ -433,7 +433,6 @@
width: 300px;
height: 100px;
border: 1px solid #aaa;
display: none;
}
.swagger-section .swagger-ui-wrap .markdown p code,
.swagger-section .swagger-ui-wrap .markdown li code {

3
dist/index.html vendored
View File

@@ -53,7 +53,8 @@
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
sorter : "alpha"
sorter : "alpha",
jsonEditor:true
});
function addApiKeyAuthorization() {

15
dist/swagger-ui.js vendored
View File

@@ -627,7 +627,12 @@ this["Handlebars"]["templates"]["param"] = Handlebars.template({"1":function(dep
if (stack1 != null) { buffer += stack1; }
return buffer;
},"5":function(depth0,helpers,partials,data) {
return " <div class=\"editor_holder\"></div>\n <br />\n <div class=\"parameter-content-type\" />\n";
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return " <div class=\"editor_holder\"></div>\n <textarea class='body-textarea' name='"
+ escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"name","hash":{},"data":data}) : helper)))
+ "'>"
+ escapeExpression(((helper = (helper = helpers['default'] || (depth0 != null ? depth0['default'] : depth0)) != null ? helper : helperMissing),(typeof helper === functionType ? helper.call(depth0, {"name":"default","hash":{},"data":data}) : helper)))
+ "</textarea>\n <br />\n <div class=\"parameter-content-type\" />\n";
},"7":function(depth0,helpers,partials,data) {
var helper, functionType="function", helperMissing=helpers.helperMissing, escapeExpression=this.escapeExpression;
return " <textarea class='body-textarea' name='"
@@ -1527,7 +1532,8 @@ OperationView = (function(superClass) {
paramView = new ParameterView({
model: param,
tagName: 'tr',
readOnly: this.model.isReadOnly
readOnly: this.model.isReadOnly,
swaggerOptions: this.options.swaggerOptions
});
return $('.operation-params', $(this.el)).append(paramView.render().el);
};
@@ -2021,7 +2027,7 @@ ParameterView = (function(superClass) {
$('.model-signature', $(this.el)).html(this.model.signature);
}
isParam = false;
if (this.model.isBody && this.model.schema) {
if (this.options.swaggerOptions.jsonEditor && this.model.isBody && this.model.schema) {
$self = $(this.el);
this.model.jsonEditor = new JSONEditor($('.editor_holder', $self)[0], {
schema: this.model.schema,
@@ -2029,6 +2035,8 @@ ParameterView = (function(superClass) {
ajax: true
});
signatureModel.jsonEditor = this.model.jsonEditor;
$('.body-textarea', $self).hide();
$('.editor_holder', $self).show();
$('.parameter-content-type', $self).change(function(e) {
if (e.target.value === "application/xml") {
$('.body-textarea', $self).show();
@@ -2040,7 +2048,6 @@ ParameterView = (function(superClass) {
return this.model.jsonEditor.enable();
}
});
isParam = true;
}
if (this.model.isBody) {
isParam = true;

File diff suppressed because one or more lines are too long

View File

@@ -175,7 +175,7 @@ class OperationView extends Backbone.View
# will replace it with the text "root" which won't look good on screen
param.schema.title = " "
paramView = new ParameterView({model: param, tagName: 'tr', readOnly: @model.isReadOnly})
paramView = new ParameterView({model: param, tagName: 'tr', readOnly: @model.isReadOnly, swaggerOptions: @options.swaggerOptions})
$('.operation-params', $(@el)).append paramView.render().el
addStatusCode: (statusCode) ->

View File

@@ -44,7 +44,7 @@ class ParameterView extends Backbone.View
isParam = false
if @model.isBody && @model.schema
if @options.swaggerOptions.jsonEditor && @model.isBody && @model.schema
$self = $(@el)
@model.jsonEditor =
new JSONEditor($('.editor_holder', $self)[0],
@@ -52,6 +52,8 @@ class ParameterView extends Backbone.View
# This is so that the signature can send back the sample to the json editor
# TODO: SignatureView should expose an event "onSampleClicked" instead
signatureModel.jsonEditor = @model.jsonEditor
$('.body-textarea', $self).hide()
$('.editor_holder', $self).show()
$('.parameter-content-type', $self)
.change(
(e) ->
@@ -63,8 +65,6 @@ class ParameterView extends Backbone.View
$('.body-textarea', $self).hide()
$('.editor_holder', $self).show()
@model.jsonEditor.enable())
isParam = true
if @model.isBody
isParam = true

1155
src/main/html/css/print.css Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -433,7 +433,6 @@
width: 300px;
height: 100px;
border: 1px solid #aaa;
display: none;
}
.swagger-section .swagger-ui-wrap .markdown p code,
.swagger-section .swagger-ui-wrap .markdown li code {

View File

@@ -53,7 +53,8 @@
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
sorter : "alpha"
sorter : "alpha",
jsonEditor:true
});
function addApiKeyAuthorization() {

View File

@@ -330,7 +330,6 @@
width: 300px;
height: 100px;
border: 1px solid #aaa;
display: none;
}
.markdown p code, .markdown li code {

View File

@@ -8,6 +8,7 @@
{{else}}
{{#if default}}
<div class="editor_holder"></div>
<textarea class='body-textarea' name='{{name}}'>{{default}}</textarea>
<br />
<div class="parameter-content-type" />
{{else}}