Merge branch 'JSONEditor' into JSONEditorMaster
Conflicts: dist/swagger-ui.js dist/swagger-ui.min.js src/main/less/screen.less
2
.gitignore
vendored
@@ -2,6 +2,8 @@
|
|||||||
*.ipr
|
*.ipr
|
||||||
*.iml
|
*.iml
|
||||||
*.iws
|
*.iws
|
||||||
|
*.flags.json
|
||||||
|
npm-debug.log
|
||||||
web/
|
web/
|
||||||
lib/*.zip
|
lib/*.zip
|
||||||
version.properties
|
version.properties
|
||||||
|
|||||||
12
dist/css/print.css
vendored
@@ -126,6 +126,7 @@
|
|||||||
max-width: 960px;
|
max-width: 960px;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
/* JSONEditor specific styling */
|
||||||
}
|
}
|
||||||
.swagger-section .swagger-ui-wrap b,
|
.swagger-section .swagger-ui-wrap b,
|
||||||
.swagger-section .swagger-ui-wrap strong {
|
.swagger-section .swagger-ui-wrap strong {
|
||||||
@@ -458,6 +459,17 @@
|
|||||||
.swagger-section .swagger-ui-wrap .required {
|
.swagger-section .swagger-ui-wrap .required {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.swagger-section .swagger-ui-wrap .editor_holder {
|
||||||
|
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
.swagger-section .swagger-ui-wrap .editor_holder label {
|
||||||
|
font-weight: normal!important;
|
||||||
|
/* JSONEditor uses bold by default for all labels, we revert that back to normal to not give the impression that by default fields are required */
|
||||||
|
}
|
||||||
|
.swagger-section .swagger-ui-wrap .editor_holder label.required {
|
||||||
|
font-weight: bold!important;
|
||||||
|
}
|
||||||
.swagger-section .swagger-ui-wrap input.parameter {
|
.swagger-section .swagger-ui-wrap input.parameter {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
border: 1px solid #aaa;
|
border: 1px solid #aaa;
|
||||||
|
|||||||
18
dist/css/screen.css
vendored
@@ -126,6 +126,7 @@
|
|||||||
max-width: 960px;
|
max-width: 960px;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
/* JSONEditor specific styling */
|
||||||
}
|
}
|
||||||
.swagger-section .swagger-ui-wrap b,
|
.swagger-section .swagger-ui-wrap b,
|
||||||
.swagger-section .swagger-ui-wrap strong {
|
.swagger-section .swagger-ui-wrap strong {
|
||||||
@@ -458,6 +459,17 @@
|
|||||||
.swagger-section .swagger-ui-wrap .required {
|
.swagger-section .swagger-ui-wrap .required {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.swagger-section .swagger-ui-wrap .editor_holder {
|
||||||
|
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
.swagger-section .swagger-ui-wrap .editor_holder label {
|
||||||
|
font-weight: normal!important;
|
||||||
|
/* JSONEditor uses bold by default for all labels, we revert that back to normal to not give the impression that by default fields are required */
|
||||||
|
}
|
||||||
|
.swagger-section .swagger-ui-wrap .editor_holder label.required {
|
||||||
|
font-weight: bold!important;
|
||||||
|
}
|
||||||
.swagger-section .swagger-ui-wrap input.parameter {
|
.swagger-section .swagger-ui-wrap input.parameter {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
border: 1px solid #aaa;
|
border: 1px solid #aaa;
|
||||||
@@ -1277,3 +1289,9 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
}
|
}
|
||||||
|
.swagger-section .swagger-collapse:before {
|
||||||
|
content: "-";
|
||||||
|
}
|
||||||
|
.swagger-section .swagger-expand:before {
|
||||||
|
content: "+";
|
||||||
|
}
|
||||||
|
|||||||
BIN
dist/images/collapse.gif
vendored
Normal file
|
After Width: | Height: | Size: 69 B |
BIN
dist/images/expand.gif
vendored
Normal file
|
After Width: | Height: | Size: 73 B |
BIN
dist/images/explorer_icons.png
vendored
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
BIN
dist/images/favicon-16x16.png
vendored
|
Before Width: | Height: | Size: 645 B After Width: | Height: | Size: 644 B |
BIN
dist/images/favicon-32x32.png
vendored
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
BIN
dist/images/logo_small.png
vendored
|
Before Width: | Height: | Size: 770 B After Width: | Height: | Size: 769 B |
BIN
dist/images/pet_store_api.png
vendored
|
Before Width: | Height: | Size: 824 B After Width: | Height: | Size: 823 B |
BIN
dist/images/wordnik_api.png
vendored
|
Before Width: | Height: | Size: 980 B After Width: | Height: | Size: 979 B |
3
dist/index.html
vendored
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -19,6 +20,7 @@
|
|||||||
<script src='lib/backbone-min.js' type='text/javascript'></script>
|
<script src='lib/backbone-min.js' type='text/javascript'></script>
|
||||||
<script src='swagger-ui.js' type='text/javascript'></script>
|
<script src='swagger-ui.js' type='text/javascript'></script>
|
||||||
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
||||||
|
<script src='lib/jsoneditor.min.js' type='text/javascript'></script>
|
||||||
<script src='lib/marked.js' type='text/javascript'></script>
|
<script src='lib/marked.js' type='text/javascript'></script>
|
||||||
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
|
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
|
||||||
|
|
||||||
@@ -69,6 +71,7 @@
|
|||||||
log("Unable to Load SwaggerUI");
|
log("Unable to Load SwaggerUI");
|
||||||
},
|
},
|
||||||
docExpansion: "none",
|
docExpansion: "none",
|
||||||
|
jsonEditor:true,
|
||||||
apisSorter: "alpha",
|
apisSorter: "alpha",
|
||||||
showRequestHeaders: false
|
showRequestHeaders: false
|
||||||
});
|
});
|
||||||
|
|||||||
53
dist/lang/tr.js
vendored
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
/* jshint quotmark: double */
|
||||||
|
window.SwaggerTranslator.learn({
|
||||||
|
"Warning: Deprecated":"Uyarı: Deprecated",
|
||||||
|
"Implementation Notes":"Gerçekleştirim Notları",
|
||||||
|
"Response Class":"Dönen Sınıf",
|
||||||
|
"Status":"Statü",
|
||||||
|
"Parameters":"Parametreler",
|
||||||
|
"Parameter":"Parametre",
|
||||||
|
"Value":"Değer",
|
||||||
|
"Description":"Açıklama",
|
||||||
|
"Parameter Type":"Parametre Tipi",
|
||||||
|
"Data Type":"Veri Tipi",
|
||||||
|
"Response Messages":"Dönüş Mesajı",
|
||||||
|
"HTTP Status Code":"HTTP Statü Kodu",
|
||||||
|
"Reason":"Gerekçe",
|
||||||
|
"Response Model":"Dönüş Modeli",
|
||||||
|
"Request URL":"İstek URL",
|
||||||
|
"Response Body":"Dönüş İçeriği",
|
||||||
|
"Response Code":"Dönüş Kodu",
|
||||||
|
"Response Headers":"Dönüş Üst Bilgileri",
|
||||||
|
"Hide Response":"Dönüşü Gizle",
|
||||||
|
"Headers":"Üst Bilgiler",
|
||||||
|
"Try it out!":"Dene!",
|
||||||
|
"Show/Hide":"Göster/Gizle",
|
||||||
|
"List Operations":"Operasyonları Listele",
|
||||||
|
"Expand Operations":"Operasyonları Aç",
|
||||||
|
"Raw":"Ham",
|
||||||
|
"can't parse JSON. Raw result":"JSON çözümlenemiyor. Ham sonuç",
|
||||||
|
"Model Schema":"Model Şema",
|
||||||
|
"Model":"Model",
|
||||||
|
"apply":"uygula",
|
||||||
|
"Username":"Kullanıcı Adı",
|
||||||
|
"Password":"Parola",
|
||||||
|
"Terms of service":"Servis şartları",
|
||||||
|
"Created by":"Oluşturan",
|
||||||
|
"See more at":"Daha fazlası için",
|
||||||
|
"Contact the developer":"Geliştirici ile İletişime Geçin",
|
||||||
|
"api version":"api versiyon",
|
||||||
|
"Response Content Type":"Dönüş İçerik Tipi",
|
||||||
|
"fetching resource":"kaynak getiriliyor",
|
||||||
|
"fetching resource list":"kaynak listesi getiriliyor",
|
||||||
|
"Explore":"Keşfet",
|
||||||
|
"Show Swagger Petstore Example Apis":"Swagger Petstore Örnek Api'yi Gör",
|
||||||
|
"Can't read from server. It may not have the appropriate access-control-origin settings.":"Sunucudan okuma yapılamıyor. Sunucu access-control-origin ayarlarınızı kontrol edin.",
|
||||||
|
"Please specify the protocol for":"Lütfen istenen adres için protokol belirtiniz",
|
||||||
|
"Can't read swagger JSON from":"Swagger JSON bu kaynaktan okunamıyor",
|
||||||
|
"Finished Loading Resource Information. Rendering Swagger UI":"Kaynak baglantısı tamamlandı. Swagger UI gösterime hazırlanıyor",
|
||||||
|
"Unable to read api":"api okunamadı",
|
||||||
|
"from path":"yoldan",
|
||||||
|
"server returned":"sunucuya dönüldü"
|
||||||
|
});
|
||||||
11
dist/lib/jsoneditor.min.js
vendored
Normal file
833
dist/swagger-ui.js
vendored
26
dist/swagger-ui.min.js
vendored
11
lib/jsoneditor.min.js
vendored
Normal file
@@ -126,6 +126,7 @@
|
|||||||
max-width: 960px;
|
max-width: 960px;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
/* JSONEditor specific styling */
|
||||||
}
|
}
|
||||||
.swagger-section .swagger-ui-wrap b,
|
.swagger-section .swagger-ui-wrap b,
|
||||||
.swagger-section .swagger-ui-wrap strong {
|
.swagger-section .swagger-ui-wrap strong {
|
||||||
@@ -458,6 +459,17 @@
|
|||||||
.swagger-section .swagger-ui-wrap .required {
|
.swagger-section .swagger-ui-wrap .required {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.swagger-section .swagger-ui-wrap .editor_holder {
|
||||||
|
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
.swagger-section .swagger-ui-wrap .editor_holder label {
|
||||||
|
font-weight: normal!important;
|
||||||
|
/* JSONEditor uses bold by default for all labels, we revert that back to normal to not give the impression that by default fields are required */
|
||||||
|
}
|
||||||
|
.swagger-section .swagger-ui-wrap .editor_holder label.required {
|
||||||
|
font-weight: bold!important;
|
||||||
|
}
|
||||||
.swagger-section .swagger-ui-wrap input.parameter {
|
.swagger-section .swagger-ui-wrap input.parameter {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
border: 1px solid #aaa;
|
border: 1px solid #aaa;
|
||||||
|
|||||||
@@ -126,6 +126,7 @@
|
|||||||
max-width: 960px;
|
max-width: 960px;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
|
/* JSONEditor specific styling */
|
||||||
}
|
}
|
||||||
.swagger-section .swagger-ui-wrap b,
|
.swagger-section .swagger-ui-wrap b,
|
||||||
.swagger-section .swagger-ui-wrap strong {
|
.swagger-section .swagger-ui-wrap strong {
|
||||||
@@ -458,6 +459,17 @@
|
|||||||
.swagger-section .swagger-ui-wrap .required {
|
.swagger-section .swagger-ui-wrap .required {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.swagger-section .swagger-ui-wrap .editor_holder {
|
||||||
|
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
|
||||||
|
font-size: 0.9em;
|
||||||
|
}
|
||||||
|
.swagger-section .swagger-ui-wrap .editor_holder label {
|
||||||
|
font-weight: normal!important;
|
||||||
|
/* JSONEditor uses bold by default for all labels, we revert that back to normal to not give the impression that by default fields are required */
|
||||||
|
}
|
||||||
|
.swagger-section .swagger-ui-wrap .editor_holder label.required {
|
||||||
|
font-weight: bold!important;
|
||||||
|
}
|
||||||
.swagger-section .swagger-ui-wrap input.parameter {
|
.swagger-section .swagger-ui-wrap input.parameter {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
border: 1px solid #aaa;
|
border: 1px solid #aaa;
|
||||||
@@ -1277,3 +1289,9 @@
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
}
|
}
|
||||||
|
.swagger-section .swagger-collapse:before {
|
||||||
|
content: "-";
|
||||||
|
}
|
||||||
|
.swagger-section .swagger-expand:before {
|
||||||
|
content: "+";
|
||||||
|
}
|
||||||
|
|||||||
BIN
src/main/html/images/collapse.gif
Normal file
|
After Width: | Height: | Size: 69 B |
BIN
src/main/html/images/expand.gif
Normal file
|
After Width: | Height: | Size: 73 B |
|
Before Width: | Height: | Size: 5.6 KiB After Width: | Height: | Size: 5.6 KiB |
|
Before Width: | Height: | Size: 645 B After Width: | Height: | Size: 644 B |
|
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB |
|
Before Width: | Height: | Size: 770 B After Width: | Height: | Size: 769 B |
|
Before Width: | Height: | Size: 824 B After Width: | Height: | Size: 823 B |
|
Before Width: | Height: | Size: 980 B After Width: | Height: | Size: 979 B |
@@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
@@ -19,6 +20,7 @@
|
|||||||
<script src='lib/backbone-min.js' type='text/javascript'></script>
|
<script src='lib/backbone-min.js' type='text/javascript'></script>
|
||||||
<script src='swagger-ui.js' type='text/javascript'></script>
|
<script src='swagger-ui.js' type='text/javascript'></script>
|
||||||
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
|
||||||
|
<script src='lib/jsoneditor.min.js' type='text/javascript'></script>
|
||||||
<script src='lib/marked.js' type='text/javascript'></script>
|
<script src='lib/marked.js' type='text/javascript'></script>
|
||||||
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
|
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
|
||||||
|
|
||||||
@@ -69,6 +71,7 @@
|
|||||||
log("Unable to Load SwaggerUI");
|
log("Unable to Load SwaggerUI");
|
||||||
},
|
},
|
||||||
docExpansion: "none",
|
docExpansion: "none",
|
||||||
|
jsonEditor:true,
|
||||||
apisSorter: "alpha",
|
apisSorter: "alpha",
|
||||||
showRequestHeaders: false
|
showRequestHeaders: false
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/*global JSONEditor*/
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
window.SwaggerUi = Backbone.Router.extend({
|
window.SwaggerUi = Backbone.Router.extend({
|
||||||
@@ -62,6 +63,16 @@ window.SwaggerUi = Backbone.Router.extend({
|
|||||||
this.headerView.on('update-swagger-ui', function(data) {
|
this.headerView.on('update-swagger-ui', function(data) {
|
||||||
return that.updateSwaggerUi(data);
|
return that.updateSwaggerUi(data);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// JSon Editor custom theming
|
||||||
|
JSONEditor.defaults.iconlibs.swagger = JSONEditor.AbstractIconLib.extend({
|
||||||
|
mapping: {
|
||||||
|
collapse: 'collapse',
|
||||||
|
expand: 'expand'
|
||||||
|
},
|
||||||
|
icon_prefix: 'swagger-'
|
||||||
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// Set an option after initializing
|
// Set an option after initializing
|
||||||
|
|||||||
@@ -69,6 +69,16 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
|
|||||||
this.model.validatorUrl = 'http://online.swagger.io/validator';
|
this.model.validatorUrl = 'http://online.swagger.io/validator';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// JSonEditor requires type='object' to be present on defined types, we add it if it's missing
|
||||||
|
// is there any valid case were it should not be added ?
|
||||||
|
var def;
|
||||||
|
for(def in this.model.definitions){
|
||||||
|
if (this.model.definitions[def].type === null){
|
||||||
|
this.model.definitions[def].type = 'object';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function(){
|
render: function(){
|
||||||
@@ -119,6 +129,11 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
|
|||||||
addResource: function(resource, auths){
|
addResource: function(resource, auths){
|
||||||
// Render a resource and add it to resources li
|
// Render a resource and add it to resources li
|
||||||
resource.id = resource.id.replace(/\s/g, '_');
|
resource.id = resource.id.replace(/\s/g, '_');
|
||||||
|
|
||||||
|
// Make all definitions available at the root of the resource so that they can
|
||||||
|
// be loaded by the JSonEditor
|
||||||
|
resource.definitions = this.model.definitions;
|
||||||
|
|
||||||
var resourceView = new SwaggerUi.Views.ResourceView({
|
var resourceView = new SwaggerUi.Views.ResourceView({
|
||||||
model: resource,
|
model: resource,
|
||||||
router: this.router,
|
router: this.router,
|
||||||
|
|||||||
@@ -238,10 +238,27 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
addParameter: function(param, consumes) {
|
addParameter: function(param, consumes) {
|
||||||
// Render a parameter
|
// Render a parameter
|
||||||
param.consumes = consumes;
|
param.consumes = consumes;
|
||||||
|
|
||||||
|
|
||||||
|
// Copy this param JSON spec so that it will be available for JsonEditor
|
||||||
|
if(param.schema){
|
||||||
|
$.extend(true, param.schema, this.model.definitions[param.type]);
|
||||||
|
param.schema.definitions = this.model.definitions;
|
||||||
|
// This is required for JsonEditor to display the root properly
|
||||||
|
param.schema.type = 'object';
|
||||||
|
// This is the title that will be used by JsonEditor for the root
|
||||||
|
// Since we already display the parameter's name in the Parameter column
|
||||||
|
// We set this to space, we can't set it to null or space otherwise JsonEditor
|
||||||
|
// will replace it with the text "root" which won't look good on screen
|
||||||
|
param.schema.title = ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var paramView = new SwaggerUi.Views.ParameterView({
|
var paramView = new SwaggerUi.Views.ParameterView({
|
||||||
model: param,
|
model: param,
|
||||||
tagName: 'tr',
|
tagName: 'tr',
|
||||||
readOnly: this.model.isReadOnly
|
readOnly: this.model.isReadOnly,
|
||||||
|
swaggerOptions: this.options.swaggerOptions
|
||||||
});
|
});
|
||||||
$('.operation-params', $(this.el)).append(paramView.render().el);
|
$('.operation-params', $(this.el)).append(paramView.render().el);
|
||||||
},
|
},
|
||||||
@@ -318,6 +335,16 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
|
|||||||
opts[key] = this.options.swaggerOptions[key];
|
opts[key] = this.options.swaggerOptions[key];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var pi;
|
||||||
|
for(pi = 0; pi < this.model.parameters.length; pi++){
|
||||||
|
var p = this.model.parameters[pi];
|
||||||
|
if( p.jsonEditor && p.jsonEditor.isEnabled()){
|
||||||
|
var json = p.jsonEditor.getValue();
|
||||||
|
map[p.name] = JSON.stringify(json);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
opts.responseContentType = $('div select[name=responseContentType]', $(this.el)).val();
|
opts.responseContentType = $('div select[name=responseContentType]', $(this.el)).val();
|
||||||
opts.requestContentType = $('div select[name=parameterContentType]', $(this.el)).val();
|
opts.requestContentType = $('div select[name=parameterContentType]', $(this.el)).val();
|
||||||
$('.response_throbber', $(this.el)).show();
|
$('.response_throbber', $(this.el)).show();
|
||||||
|
|||||||
@@ -62,6 +62,37 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
|
|||||||
|
|
||||||
var isParam = false;
|
var isParam = false;
|
||||||
|
|
||||||
|
if( this.options.swaggerOptions.jsonEditor && this.model.isBody && this.model.schema){
|
||||||
|
var $self = $(this.el);
|
||||||
|
this.model.jsonEditor =
|
||||||
|
/* global JSONEditor */
|
||||||
|
new JSONEditor($('.editor_holder', $self)[0],
|
||||||
|
{schema: this.model.schema, startval : this.model.default,
|
||||||
|
ajax:true,
|
||||||
|
disable_properties:true,
|
||||||
|
disable_edit_json:true,
|
||||||
|
iconlib: 'swagger' });
|
||||||
|
// 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 = 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();
|
||||||
|
$('.editor_holder', $self).hide();
|
||||||
|
this.model.jsonEditor.disable();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$('.body-textarea', $self).hide();
|
||||||
|
$('.editor_holder', $self).show();
|
||||||
|
this.model.jsonEditor.enable();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (this.model.isBody) {
|
if (this.model.isBody) {
|
||||||
isParam = true;
|
isParam = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ SwaggerUi.Views.ResourceView = Backbone.View.extend({
|
|||||||
|
|
||||||
operation.nickname = id;
|
operation.nickname = id;
|
||||||
operation.parentId = this.model.id;
|
operation.parentId = this.model.id;
|
||||||
|
operation.definitions = this.model.definitions; // make Json Schema available for JSonEditor in this operation
|
||||||
this.addOperation(operation);
|
this.addOperation(operation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,10 @@ SwaggerUi.Views.SignatureView = Backbone.View.extend({
|
|||||||
// Fix for bug in IE 10/11 which causes placeholder text to be copied to "value"
|
// Fix for bug in IE 10/11 which causes placeholder text to be copied to "value"
|
||||||
if ($.trim(textArea.val()) === '' || textArea.prop('placeholder') === textArea.val()) {
|
if ($.trim(textArea.val()) === '' || textArea.prop('placeholder') === textArea.val()) {
|
||||||
textArea.val(this.model.sampleJSON);
|
textArea.val(this.model.sampleJSON);
|
||||||
|
// TODO move this code outside of the view and expose an event instead
|
||||||
|
if( this.model.jsonEditor && this.model.jsonEditor.isEnabled()){
|
||||||
|
this.model.jsonEditor.setValue(JSON.parse(this.model.sampleJSON));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,4 +144,14 @@
|
|||||||
padding-top: 10px;
|
padding-top: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.swagger-collapse:before {
|
||||||
|
content: "-";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.swagger-expand:before {
|
||||||
|
content: "+";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -360,6 +360,19 @@
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* JSONEditor specific styling */
|
||||||
|
.editor_holder {
|
||||||
|
font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace;
|
||||||
|
font-size: 0.9em;
|
||||||
|
label {
|
||||||
|
font-weight:normal!important; /* JSONEditor uses bold by default for all labels, we revert that back to normal to not give the impression that by default fields are required */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.editor_holder label.required {
|
||||||
|
font-weight:bold!important;
|
||||||
|
}
|
||||||
|
|
||||||
input.parameter {
|
input.parameter {
|
||||||
width: 300px;
|
width: 300px;
|
||||||
border: 1px solid #aaa;
|
border: 1px solid #aaa;
|
||||||
|
|||||||
@@ -7,11 +7,13 @@
|
|||||||
<div class="parameter-content-type" />
|
<div class="parameter-content-type" />
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if default}}
|
{{#if default}}
|
||||||
|
<div class="editor_holder"></div>
|
||||||
<textarea class='body-textarea' name='{{name}}' id='{{valueId}}'>{{default}}</textarea>
|
<textarea class='body-textarea' name='{{name}}' id='{{valueId}}'>{{default}}</textarea>
|
||||||
<br />
|
<br />
|
||||||
<div class="parameter-content-type" />
|
<div class="parameter-content-type" />
|
||||||
{{else}}
|
{{else}}
|
||||||
<textarea class='body-textarea' name='{{name}}' id='{{valueId}}'></textarea>
|
<textarea class='body-textarea' name='{{name}}' id='{{valueId}}'></textarea>
|
||||||
|
<div class="editor_holder"></div>
|
||||||
<br />
|
<br />
|
||||||
<div class="parameter-content-type" />
|
<div class="parameter-content-type" />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|||||||
@@ -5,11 +5,13 @@
|
|||||||
<input type="file" name='{{name}}' id='{{valueId}}'/>
|
<input type="file" name='{{name}}' id='{{valueId}}'/>
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if default}}
|
{{#if default}}
|
||||||
|
<div class="editor_holder"></div>
|
||||||
<textarea class='body-textarea required' placeholder='(required)' name='{{name}}' id="{{valueId}}">{{default}}</textarea>
|
<textarea class='body-textarea required' placeholder='(required)' name='{{name}}' id="{{valueId}}">{{default}}</textarea>
|
||||||
<br />
|
<br />
|
||||||
<div class="parameter-content-type" />
|
<div class="parameter-content-type" />
|
||||||
{{else}}
|
{{else}}
|
||||||
<textarea class='body-textarea required' placeholder='(required)' name='{{name}}' id='{{valueId}}'></textarea>
|
<textarea class='body-textarea required' placeholder='(required)' name='{{name}}' id='{{valueId}}'></textarea>
|
||||||
|
<div class="editor_holder"></div>
|
||||||
<br />
|
<br />
|
||||||
<div class="parameter-content-type" />
|
<div class="parameter-content-type" />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|||||||
@@ -110,6 +110,18 @@ describe('swagger 2.0 spec tests', function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
['root.id','root.username','root.firstName','root.lastName', 'root.email', 'root.password', 'root.phone', 'root.userStatus']
|
||||||
|
.forEach(function (id) {
|
||||||
|
it('should find a jsoneditor for user post with field: ' + id, function (done) {
|
||||||
|
var locator = webdriver.By.xpath('//*[@id=\'user_createUser\']//*[@data-schemapath=\''+id+'\']');
|
||||||
|
driver
|
||||||
|
.wait(webdriver.until.elementLocated(locator),2000)
|
||||||
|
.then(function() { done(); });
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO JSonEditor Tests for POST/PUT
|
||||||
|
|
||||||
after(function() {
|
after(function() {
|
||||||
servers.close();
|
servers.close();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -843,7 +843,7 @@
|
|||||||
"xml": {
|
"xml": {
|
||||||
"name": "category"
|
"name": "category"
|
||||||
},
|
},
|
||||||
"$ref": "Category"
|
"$ref": "#/definitions/Category"
|
||||||
},
|
},
|
||||||
"name": {
|
"name": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@@ -869,7 +869,7 @@
|
|||||||
"wrapped": true
|
"wrapped": true
|
||||||
},
|
},
|
||||||
"items": {
|
"items": {
|
||||||
"$ref": "Tag"
|
"$ref": "#/definitions/Tag"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"status": {
|
"status": {
|
||||||
|
|||||||