Merge remote-tracking branch 'upstream/master' into JSONEditorMaster

Conflicts:
	dist/swagger-ui.js
	dist/swagger-ui.min.js
	src/main/javascript/view/OperationView.js
	src/main/less/screen.less
This commit is contained in:
Laurent Lepinay
2015-12-16 10:25:38 +01:00
32 changed files with 436 additions and 367 deletions

View File

@@ -1136,14 +1136,14 @@
font-size: 24px;
padding: 10px 0;
}
.swagger-section .api-popup-dialog p.error-msg {
.swagger-section .api-popup-dialog .error-msg {
padding-left: 5px;
padding-bottom: 5px;
}
.swagger-section .api-popup-dialog button.api-popup-authbtn {
.swagger-section .api-popup-dialog .api-popup-authbtn {
height: 30px;
}
.swagger-section .api-popup-dialog button.api-popup-cancel {
.swagger-section .api-popup-dialog .api-popup-cancel {
height: 30px;
}
.swagger-section .api-popup-scopes {
@@ -1153,14 +1153,14 @@
padding: 5px 0;
line-height: 20px;
}
.swagger-section .api-popup-scopes .api-scope-desc {
padding-left: 20px;
font-style: italic;
}
.swagger-section .api-popup-scopes li input {
position: relative;
top: 2px;
}
.swagger-section .api-popup-scopes .api-scope-desc {
padding-left: 20px;
font-style: italic;
}
.swagger-section .api-popup-actions {
padding-top: 10px;
}

View File

@@ -1136,14 +1136,14 @@
font-size: 24px;
padding: 10px 0;
}
.swagger-section .api-popup-dialog p.error-msg {
.swagger-section .api-popup-dialog .error-msg {
padding-left: 5px;
padding-bottom: 5px;
}
.swagger-section .api-popup-dialog button.api-popup-authbtn {
.swagger-section .api-popup-dialog .api-popup-authbtn {
height: 30px;
}
.swagger-section .api-popup-dialog button.api-popup-cancel {
.swagger-section .api-popup-dialog .api-popup-cancel {
height: 30px;
}
.swagger-section .api-popup-scopes {
@@ -1153,14 +1153,14 @@
padding: 5px 0;
line-height: 20px;
}
.swagger-section .api-popup-scopes .api-scope-desc {
padding-left: 20px;
font-style: italic;
}
.swagger-section .api-popup-scopes li input {
position: relative;
top: 2px;
}
.swagger-section .api-popup-scopes .api-scope-desc {
padding-left: 20px;
font-style: italic;
}
.swagger-section .api-popup-actions {
padding-top: 10px;
}
@@ -1234,32 +1234,29 @@
background-color: #89bf04;
padding: 14px;
}
.swagger-section #header a#logo {
font-size: 1.5em;
font-weight: bold;
text-decoration: none;
background: transparent url(../images/logo_small.png) no-repeat left center;
padding: 20px 0 20px 40px;
color: white;
.swagger-section #input_baseUrl {
width: 400px;
}
.swagger-section #header form#api_selector {
.swagger-section #api_selector {
display: block;
clear: none;
float: right;
}
.swagger-section #header form#api_selector .input {
.swagger-section #api_selector .input {
display: block;
clear: none;
float: left;
margin: 0 10px 0 0;
}
.swagger-section #header form#api_selector .input input#input_apiKey {
.swagger-section #api_selector input {
font-size: 0.9em;
padding: 3px;
margin: 0;
}
.swagger-section #input_apiKey {
width: 200px;
}
.swagger-section #header form#api_selector .input input#input_baseUrl {
width: 400px;
}
.swagger-section #header form#api_selector .input a#explore {
.swagger-section #explore {
display: block;
text-decoration: none;
font-weight: bold;
@@ -1274,13 +1271,16 @@
-khtml-border-radius: 4px;
border-radius: 4px;
}
.swagger-section #header form#api_selector .input a#explore:hover {
.swagger-section #explore:hover {
background-color: #547f00;
}
.swagger-section #header form#api_selector .input input {
font-size: 0.9em;
padding: 3px;
margin: 0;
.swagger-section #header #logo {
font-size: 1.5em;
font-weight: bold;
text-decoration: none;
background: transparent url(../images/logo_small.png) no-repeat left center;
padding: 20px 0 20px 40px;
color: white;
}
.swagger-section #content_message {
margin: 10px 15px;

View File

@@ -53,7 +53,8 @@
clientSecret: "your-client-secret-if-required",
realm: "your-realms",
appName: "your-app-name",
scopeSeparator: ","
scopeSeparator: ",",
additionalQueryStringParams: {}
});
}
@@ -73,6 +74,7 @@
docExpansion: "none",
jsonEditor:true,
apisSorter: "alpha",
defaultModelRendering: 'schema',
showRequestHeaders: false
});

View File

@@ -14,7 +14,12 @@ window.SwaggerUi = Backbone.Router.extend({
// SwaggerUi accepts all the same options as SwaggerApi
initialize: function(options) {
options = options || {};
if(!options.highlightSizeThreshold) {
if (options.defaultModelRendering !== 'model') {
options.defaultModelRendering = 'schema';
}
if (!options.highlightSizeThreshold) {
options.highlightSizeThreshold = 100000;
}
@@ -187,7 +192,7 @@ window.SwaggerUi = Backbone.Router.extend({
var $msgbar = $('#message-bar');
$msgbar.removeClass('message-fail');
$msgbar.addClass('message-success');
$msgbar.html(data);
$msgbar.text(data);
if(window.SwaggerTranslator) {
window.SwaggerTranslator.translate($msgbar);
}

View File

@@ -108,23 +108,24 @@ window.Docs = {
Docs.expandEndpointListForResource(fragments[0]);
$("#"+dom_id).slideto({highlight: false});
// Expand operation
var li_dom_id = fragments.join('_');
var li_content_dom_id = li_dom_id + "_content";
// Expand operation
var li_dom_id = fragments.join('_');
var li_content_dom_id = li_dom_id + "_content";
Docs.expandOperation($('#'+li_content_dom_id));
$('#'+li_dom_id).slideto({highlight: false});
break;
Docs.expandOperation($('#'+li_content_dom_id));
$('#'+li_dom_id).slideto({highlight: false});
break;
}
},
toggleEndpointListForResource: function(resource) {
var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints');
if (elem.is(':visible')) {
$.bbq.pushState('#/', 2);
Docs.collapseEndpointListForResource(resource);
} else {
$.bbq.pushState('#/' + resource, 2);
Docs.expandEndpointListForResource(resource);
}
},

View File

@@ -8,7 +8,8 @@ Handlebars.registerHelper('sanitize', function(html) {
Handlebars.registerHelper('renderTextParam', function(param) {
var result, type = 'text', idAtt = '';
var isArray = param.type.toLowerCase() === 'array' || param.allowMultiple;
var paramType = param.type || param.schema.type || '';
var isArray = paramType.toLowerCase() === 'array' || param.allowMultiple;
var defaultValue = isArray && Array.isArray(param.default) ? param.default.join('\n') : param.default;
var dataVendorExtensions = Object.keys(param).filter(function(property) {
@@ -31,6 +32,8 @@ Handlebars.registerHelper('renderTextParam', function(param) {
idAtt = ' id=\'' + param.valueId + '\'';
}
defaultValue = defaultValue.replace(/'/g,''');
if(isArray) {
result = '<textarea class=\'body-textarea' + (param.required ? ' required' : '') + '\' name=\'' + param.name + '\'' + idAtt + dataVendorExtensions;
result += ' placeholder=\'Provide multiple values in new lines' + (param.required ? ' (at least one required).' : '.') + '\'>';

View File

@@ -20,9 +20,10 @@ SwaggerUi.Views.BasicAuthButton = Backbone.View.extend({
'click #apply_basic_auth' : 'applyPassword'
},
applyPassword: function(){
var username = $('.input_username').val();
var password = $('.input_password').val();
applyPassword: function(event){
event.preventDefault();
var username = $('#input_username').val();
var password = $('#input_password').val();
var basicAuth = new SwaggerClient.PasswordAuthorization('basic', username, password);
this.router.api.clientAuthorizations.add(this.model.type, basicAuth);
this.router.load();

View File

@@ -19,6 +19,14 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
this.parentId = this.model.parentId;
this.nickname = this.model.nickname;
this.model.encodedParentId = encodeURIComponent(this.parentId);
if (opts.swaggerOptions) {
this.model.defaultRendering = opts.swaggerOptions.defaultModelRendering;
if (opts.swaggerOptions.showRequestHeaders) {
this.model.showRequestHeaders = true;
}
}
return this;
},
@@ -160,6 +168,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
value = successResponse[key];
this.model.successCode = key;
if (typeof value === 'object' && typeof value.createJSONSample === 'function') {
this.model.successDescription = value.description;
signatureModel = {
sampleJSON: JSON.stringify(value.createJSONSample(), void 0, 2),
isParam: false,
@@ -174,12 +183,9 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
signature: this.model.responseClassSignature
};
}
var opts = this.options.swaggerOptions;
if (opts.showRequestHeaders) {
this.model.showRequestHeaders = true;
}
$(this.el).html(Handlebars.templates.operation(this.model));
if (signatureModel) {
signatureModel.defaultRendering = this.model.defaultRendering;
responseSignatureView = new SwaggerUi.Views.SignatureView({
model: signatureModel,
router: this.router,
@@ -238,7 +244,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
addParameter: function(param, consumes) {
// Render a parameter
param.consumes = consumes;
param.defaultRendering = this.model.defaultRendering;
// Copy this param JSON spec so that it will be available for JsonEditor
if(param.schema){
@@ -256,7 +262,6 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
param.schema.title = ' ';
}
}
var paramView = new SwaggerUi.Views.ParameterView({
model: param,
@@ -269,6 +274,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
addStatusCode: function(statusCode) {
// Render status codes
statusCode.defaultRendering = this.model.defaultRendering;
var statusCodeView = new SwaggerUi.Views.StatusCodeView({
model: statusCode,
tagName: 'tr',
@@ -673,8 +679,8 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
$('.response_throbber', $(this.el)).hide();
//adds curl output
var curlCommand = this.model.asCurl(this.map);
// adds curl output
var curlCommand = this.model.asCurl(this.map, {responseContentType: contentType});
curlCommand = curlCommand.replace('!', '&#33;');
$( 'div.curl', $(this.el)).html('<pre>' + curlCommand + '</pre>');
@@ -701,11 +707,10 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
toggleOperationContent: function (event) {
var elem = $('#' + Docs.escapeResourceName(this.parentId + '_' + this.nickname + '_content'));
if (elem.is(':visible')){
event.preventDefault();
$.bbq.pushState('#/', 2);
event.preventDefault();
Docs.collapseOperation(elem);
} else {
event.preventDefault();
Docs.expandOperation(elem);
}
},

View File

@@ -49,7 +49,8 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
var signatureModel = {
sampleJSON: this.model.sampleJSON,
isParam: true,
signature: this.model.signature
signature: this.model.signature,
defaultRendering: this.model.defaultRendering
};
if (this.model.sampleJSON) {

View File

@@ -15,8 +15,12 @@ SwaggerUi.Views.SignatureView = Backbone.View.extend({
$(this.el).html(Handlebars.templates.signature(this.model));
this.switchToSnippet();
if (this.model.defaultRendering === 'model') {
this.switchToDescription();
} else {
this.switchToSnippet();
}
this.isParam = this.model.isParam;
if (this.isParam) {

View File

@@ -14,6 +14,7 @@ SwaggerUi.Views.StatusCodeView = Backbone.View.extend({
sampleJSON: JSON.stringify(this.router.api.models[this.model.responseModel].createJSONSample(), null, 2),
isParam: false,
signature: this.router.api.models[this.model.responseModel].getMockSignature(),
defaultRendering: this.model.defaultRendering
};
var responseModelView = new SwaggerUi.Views.SignatureView({model: responseModel, tagName: 'div'});

View File

@@ -1,83 +1,72 @@
.swagger-section {
.title {
font-style: bold;
}
.title { font-style: bold; }
.secondary_form {
display: none;
}
.secondary_form { display: none; }
.main_image {
display: block;
margin-left: auto;
margin-right: auto;
}
.main_image {
display: block;
margin-left: auto;
margin-right: auto;
}
.oauth_body {
margin-left: 100px;
margin-right: 100px;
}
.oauth_body {
margin-left: 100px;
margin-right: 100px;
}
.oauth_submit {
text-align: center;
}
.oauth_submit { text-align: center; }
.api-popup-dialog {
z-index: 10000;
position: absolute;
width: 500px;
background: #FFF;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
display: none;
font-size: 13px;
color: #777;
.api-popup-dialog {
z-index: 10000;
position: absolute;
width: 500px;
background: #FFF;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
display: none;
font-size: 13px;
color: #777;
}
.api-popup-title{
.api-popup-dialog .api-popup-title {
font-size: 24px;
padding: 10px 0;
}
.api-popup-title{
.api-popup-dialog .api-popup-title {
font-size: 24px;
padding: 10px 0;
}
p.error-msg {
.api-popup-dialog .error-msg {
padding-left: 5px;
padding-bottom: 5px;
}
button.api-popup-authbtn {
height: 30px;
}
button.api-popup-cancel {
height: 30px;
}
}
.api-popup-dialog .api-popup-authbtn { height: 30px; }
.api-popup-scopes {
padding: 10px 20px;
.api-popup-dialog .api-popup-cancel { height: 30px; }
li {
.api-popup-scopes { padding: 10px 20px; }
.api-popup-scopes li {
padding: 5px 0;
line-height: 20px;
}
.api-scope-desc {
padding-left: 20px;
font-style: italic;
}
li input {
.api-popup-scopes li input {
position: relative;
top: 2px;
}
}
.api-popup-actions {
padding-top: 10px;
}
.api-popup-scopes .api-scope-desc {
padding-left: 20px;
font-style: italic;
}
.api-popup-actions { padding-top: 10px; }
}

View File

@@ -1,157 +1,159 @@
@import 'src/main/less/highlight_default.less';
@import 'src/main/less/specs.less';
@import 'src/main/less/auth.less';
.swagger-section {
.access {
float: right;
}
.access { float: right; }
.auth {
float: right;
}
.auth { float: right; }
.api-ic {
.api-ic {
height: 18px;
vertical-align: middle;
display: inline-block;
background: url(../images/explorer_icons.png) no-repeat;
.api_information_panel {
position: relative;
margin-top: 20px;
margin-left: -5px;
background: #FFF;
border: 1px solid #ccc;
border-radius: 5px;
display: none;
font-size: 13px;
max-width: 300px;
line-height: 30px;
color: black;
padding: 5px;
p {
.api-msg-enabled {
color: green;
}
.api-msg-disabled {
color: red;
}
}
}
}
}
.api-ic:hover {
.api_information_panel {
position: absolute;
display: block;
}
}
.api-ic .api_information_panel {
position: relative;
margin-top: 20px;
margin-left: -5px;
background: #FFF;
border: 1px solid #ccc;
border-radius: 5px;
display: none;
font-size: 13px;
max-width: 300px;
line-height: 30px;
color: black;
padding: 5px;
}
.ic-info {
.api-ic .api_information_panel p .api-msg-enabled { color: green; }
.api-ic .api_information_panel p .api-msg-disabled { color: red; }
.api-ic:hover .api_information_panel {
position: absolute;
display: block;
}
.ic-info {
background-position: 0 0;
width: 18px;
margin-top: -6px;
margin-left: 4px;
}
.ic-warning {
}
.ic-warning {
background-position: -60px 0;
width: 18px;
margin-top: -6px;
margin-left: 4px;
}
.ic-error {
}
.ic-error {
background-position: -30px 0;
width: 18px;
margin-top: -6px;
margin-left: 4px;
}
.ic-off {
}
.ic-off {
background-position: -90px 0;
width: 58px;
margin-top: -4px;
cursor: pointer;
}
.ic-on {
}
.ic-on {
background-position: -160px 0;
width: 58px;
margin-top: -4px;
cursor: pointer;
}
}
#header {
#header {
background-color: #89bf04;
padding: 14px;
a#logo {
font-size: 1.5em;
font-weight: bold;
text-decoration: none;
background: transparent url(../images/logo_small.png) no-repeat left center;
padding: 20px 0 20px 40px;
color: white;
}
form#api_selector {
display: block;
clear: none;
float: right;
.input {
display: block;
clear: none;
float: left;
margin: 0 10px 0 0;
input#input_apiKey {
width: 200px;
}
input#input_baseUrl {
width: 400px;
}
a#explore {
display: block;
text-decoration: none;
font-weight: bold;
padding: 6px 8px;
font-size: 0.9em;
color: white;
background-color: #547f00;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
-o-border-radius: 4px;
-ms-border-radius: 4px;
-khtml-border-radius: 4px;
border-radius: 4px;
}
a#explore:hover {
background-color: #547f00;
}
input {
font-size: 0.9em;
padding: 3px;
margin: 0;
}
}
}
}
}
#content_message {
#input_baseUrl { width: 400px; }
#api_selector {
display: block;
clear: none;
float: right;
}
#api_selector .input {
display: block;
clear: none;
float: left;
margin: 0 10px 0 0;
}
#api_selector input {
font-size: 0.9em;
padding: 3px;
margin: 0;
}
#input_apiKey { width: 200px; }
#explore {
display: block;
text-decoration: none;
font-weight: bold;
padding: 6px 8px;
font-size: 0.9em;
color: white;
background-color: #547f00;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
-o-border-radius: 4px;
-ms-border-radius: 4px;
-khtml-border-radius: 4px;
border-radius: 4px;
&:hover { background-color: #547f00; }
}
#header #logo {
font-size: 1.5em;
font-weight: bold;
text-decoration: none;
background: transparent url(../images/logo_small.png) no-repeat left center;
padding: 20px 0 20px 40px;
color: white;
}
#content_message {
margin: 10px 15px;
font-style: italic;
color: #999999;
}
}
#message-bar {
#message-bar {
min-height: 30px;
text-align: center;
padding-top: 10px;
}
.swagger-collapse:before {
content: "-";
}
.swagger-expand:before {
content: "+";
}
}
.swagger-collapse:before {
content: "-";
}
.swagger-expand:before {
content: "+";
}
}

View File

@@ -2,7 +2,7 @@
<select name="contentType" id="{{contentTypeId}}">
{{#if produces}}
{{#each produces}}
<option value="{{{this}}}">{{{this}}}</option>
<option value="{{this}}">{{{this}}}</option>
{{/each}}
{{else}}
<option value="application/json">application/json</option>

View File

@@ -18,10 +18,10 @@
</div>
<div class='content' id='{{parentId}}_{{nickname}}_content' style='display:none'>
{{#if deprecated}}
<h4>Warning: Deprecated</h4>
<h4><span data-sw-translate>Warning: Deprecated</span></h4>
{{/if}}
{{#if description}}
<h4>Implementation Notes</h4>
<h4><span data-sw-translate>Implementation Notes</span></h4>
<div class="markdown">{{{description}}}</div>
{{/if}}
{{#oauth}}
@@ -42,9 +42,11 @@
{{/oauth}}
{{#if type}}
<h4><span data-sw-translate>Response Class</span> (<span data-sw-translate>Status</span> {{successCode}})</h4>
{{#if successDescription}}<div class="markdown">{{{successDescription}}}</div>{{/if}}
<p><span class="model-signature" /></p>
<br/>
<div class="response-content-type" />
{{/if}}
<form accept-charset='UTF-8' class='sandbox'>
<div style='margin:0;padding:0;display:inline'></div>
@@ -78,7 +80,6 @@
</tr>
</thead>
<tbody class="operation-status">
</tbody>
</table>
{{/if}}

View File

@@ -2,6 +2,7 @@
<td>
{{#if isBody}}
<textarea class='body-textarea' readonly='readonly' name='{{name}}' id='{{valueId}}'>{{default}}</textarea>
<div class="parameter-content-type" />
{{else}}
{{#if default}}
{{default}}

View File

@@ -2,7 +2,7 @@
<select name="parameterContentType" id="{{parameterContentTypeId}}">
{{#if consumes}}
{{#each consumes}}
<option value="{{{this}}}">{{{this}}}</option>
<option value="{{this}}">{{{this}}}</option>
{{/each}}
{{else}}
<option value="application/json">application/json</option>

View File

@@ -2,7 +2,7 @@
<select name="responseContentType" id="{{responseContentTypeId}}">
{{#if produces}}
{{#each produces}}
<option value="{{{this}}}">{{{this}}}</option>
<option value="{{this}}">{{{this}}}</option>
{{/each}}
{{else}}
<option value="application/json">application/json</option>