Compare commits

...
58 Commits
Author SHA1 Message Date
Tony Tam 198dd641b4 Merge pull request #1285 from swagger-api/develop_2.0
Merged from develop_2.0
2015-05-14 09:00:23 -04:00
Tony Tam b5039b28b0 rebuilt 2015-05-14 08:56:49 -04:00
Tony Tam d5c79f84f6 added authorizations 2015-05-14 08:56:42 -04:00
Tony Tam eb70c736df Merge pull request #1282 from nprdm/develop_2.0
Fixes #1233
2015-05-13 17:41:34 -04:00
Nara Kasbergen 831a7ae604 Just realized this adds some extra horizontal padding which may not be desirable, so this fixes that 2015-05-13 17:31:47 -04:00
Nara Kasbergen c2dee786e4 Fixes #1233 2015-05-13 16:39:01 -04:00
Tony Tam 688244f190 Merge pull request #1281 from nprdm/develop_2.0
Fixes #1268
2015-05-13 16:31:24 -04:00
Nara Kasbergen 41eb5237ef Fixes #1268 2015-05-13 16:26:11 -04:00
Tony Tam 693b4d97ed Merge pull request #1280 from nprdm/develop_2.0
Use the correct new sorting parameter name
2015-05-13 14:53:33 -04:00
Nara Kasbergen 9923b3cf8a Use the correct new sorting parameter name 2015-05-13 11:47:25 -04:00
Tony Tam 49754457d8 Merge pull request #1278 from swagger-api/develop_2.0
Merged from develop_2.0
2015-05-13 08:53:39 -04:00
Tony Tam 666246c14c rebuilt 2015-05-13 08:50:40 -04:00
Tony Tam 28c63cc3ab merged 2015-05-13 08:49:50 -04:00
Tony Tam 96e73d07e6 updated versions for patch release 2015-05-13 08:49:06 -04:00
Tony Tam 0aa3ff343e Merge pull request #1277 from bloodyowl/fix.es5
fixed MainView for ES5 browser.
2015-05-13 08:43:52 -04:00
Matthias Le Brun 082dc476e6 fixed MainView for ES5 browser.
calling ES6 String.prototype.startWith doesn't work in all browsers
yet.
2015-05-13 14:41:08 +02:00
Tony Tam d3bc023302 Merge pull request #1275 from swagger-api/develop_2.0
Merged from develop_2.0
2015-05-13 07:31:32 -04:00
Tony Tam bf7164119b updated swagger-js, rebuilt 2015-05-13 07:24:57 -04:00
Tony Tam 95bf95e91f fix for #1257 2015-05-10 17:59:25 -07:00
Tony Tam 9d8ccc40dc Merge pull request #1254 from swagger-api/develop_2.0
Merged from develop_2.0
2015-05-08 15:42:49 -07:00
Tony Tam 5640bf782f updated swagger-client version 2015-05-08 15:30:21 -07:00
Tony Tam 261e1894e0 set highlight threshold per #1184 2015-05-08 14:45:19 -07:00
Tony Tam 9e70c95499 updated per #931 2015-05-08 13:56:20 -07:00
Tony Tam 4365d34ee1 rebuilt 2015-05-08 13:29:47 -07:00
Tony Tam 97ed093e6e Merge pull request #1239 from ponelat/develop_2.0
fixes #1205, remove dead line
2015-05-08 13:29:02 -07:00
Tony Tam a02cea119d merged #1238 2015-05-08 13:28:12 -07:00
Tony Tam 8661a0f2f6 Merge pull request #1225 from ponelat/fix/1194
fix oauth switch
2015-05-08 12:52:05 -07:00
Tony Tam e0d17d0755 Merge pull request #1224 from ponelat/fix/1221
add jshint to gulp..lint and dist
2015-05-08 12:51:27 -07:00
Tony Tam 4f3116930b merged 2015-05-08 12:50:45 -07:00
Tony Tam 5abd2819f9 merged 2015-05-08 12:48:16 -07:00
Tony Tam 99bec82087 Merge branch 'develop_2.0' of github.com:swagger-api/swagger-ui into develop_2.0 2015-05-08 12:45:12 -07:00
Tony Tam b1efe883db merged logic from #1177 2015-05-08 12:45:00 -07:00
Tony Tam 17dca9e256 Merge pull request #1173 from BjRo/handle_whitespace_in_response
Prevent the OperationView to display an error in case the response contains a whitespace only body with content type application/json
2015-05-08 12:30:01 -07:00
Tony Tam cdd80820cf fix for #1253 2015-05-08 12:23:18 -07:00
Tony Tam d7bc0c6cbe Merge branch 'valdemon-multi-value-params' into develop_2.0 2015-05-08 12:21:02 -07:00
Tony Tam 9c58ed7018 Merge branch 'multi-value-params' of ssh://github.com/valdemon/swagger-ui into valdemon-multi-value-params 2015-05-08 12:10:01 -07:00
Tony Tam 1696a1ba34 added fix from outdated PR #1122 2015-05-08 12:06:56 -07:00
Tony Tam ba855e3d04 Merge pull request #1112 from 3scale/op-execute
Pass swagger options to swagger-js Operation#execute method
2015-05-08 12:03:56 -07:00
Tony Tam 6d5f6de537 Fix for #1252, check for http protocol before setting validator url 2015-05-08 12:02:30 -07:00
Tony Tam ccfc4aa4ba manually added #1086, #1089 2015-05-08 12:01:06 -07:00
Tony Tam 9666eaeb96 updated swagger-client version 2015-05-08 06:26:07 -07:00
Josh Ponelat 37f4850ce2 fixes #1205, remove dead line 2015-05-05 19:36:23 +02:00
Josh Ponelat ec86ee2df9 uncomment swagger-oauth and add script 2015-04-29 12:41:08 +02:00
Josh Ponelat 558cc92dd6 add jshint to gulp..lint and dist 2015-04-29 11:29:19 +02:00
Tony Tam 69bf18a222 Merge pull request #1192 from ponelat/fix/issue-1191
fix #1191, forgot to put returns on handlebar helper
2015-04-28 07:00:23 -07:00
Josh Ponelat f4b2c49eb5 fix #1191, forgot to put returns on handlebar helper 2015-04-22 09:00:50 +02:00
Tony Tam d76a62caf7 Merge pull request #1180 from mgttlinger/develop_2.0
Fix for #1113
2015-04-20 22:09:00 -07:00
Mohsen Azimi 6f1b9b6394 Merge pull request #1182 from delphian/master
Forcing old images to not be CRLF conformed due to new gitattributes file
2015-04-18 15:59:49 -07:00
Bryan Hazelbaker 52cf2ed337 Forcing old images to not be CRLF conformed due to new gitattributes file. 2015-04-17 14:15:40 -07:00
Merlin Göttlinger 5b72632cb6 created files in dist 2015-04-17 19:09:46 +02:00
mgttlinger 29b9f48e5c Fix for #1113 2015-04-17 15:49:03 +02:00
Tony Tam 82a89a7952 updated version 2015-04-16 12:34:25 -07:00
Björn Rochel 569830b4ac Use jQuery for trimming 2015-04-16 20:37:19 +02:00
Bjoern Rochel 6a1707e3ba Prevent the OperationView to display an error in case the response contains a whitespace only body with content type application/json 2015-04-16 11:59:27 +02:00
Waldek Kozba ad56131a6d Corrected for Travis build. 2015-04-03 19:02:19 +00:00
Waldek Kozba af39ae0603 Multiple values for array type parameters as separated lines in the textarea.
Improved required parameter handling for the array type.
Improved default value handling for the array type.
2015-04-03 14:31:23 +00:00
aurelian c84202c1d7 Pass empty object to guard the case when options.swaggerOptions is undefined 2015-04-02 11:27:28 +02:00
aurelian 4764d33fe5 Pass swagger options to swagger-js Operation#execute method 2015-04-01 23:54:14 +02:00
32 changed files with 886 additions and 311 deletions
+2
View File
@@ -9,3 +9,5 @@ dist/**/*.woff binary
dist/**/*.woff2 binary
dist/**/*.png binary
dist/*.html text
src/main/html/images/*.png binary
+1 -1
View File
@@ -131,7 +131,7 @@ swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorizat
Note! You can pass multiple header params on a single request, just use unique names for them (`key` is used in the above example).
### Localization and translation
The localization files are in the dist/lang directory.
The localization files are in the [lang](/lang) directory. Note that language files and translator is not included in SwaggerUI by default. You need to add them manually.
To enable translation you should append next two lines in your Swagger's index.html (or another entry point you use)
```html
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "swagger-ui",
"main": "dist/index.html",
"version": "2.1.8-M1",
"version": "2.1.5-M2",
"authors": [
"Mohsen Azimi <me@azimi.me>"
],
+6
View File
@@ -274,6 +274,9 @@
font-weight: bold;
font-size: 25px;
}
.swagger-section .swagger-ui-wrap .footer {
margin-top: 20px;
}
.swagger-section .swagger-ui-wrap p.big,
.swagger-section .swagger-ui-wrap div.big p {
font-size: 1em;
@@ -1066,6 +1069,9 @@
.swagger-section .swagger-ui-wrap form.form_box p strong {
color: black;
}
.swagger-section .swagger-ui-wrap .operation-status td.markdown > p:last-child {
padding-bottom: 0;
}
.swagger-section .title {
font-style: bold;
}
+6
View File
@@ -274,6 +274,9 @@
font-weight: bold;
font-size: 25px;
}
.swagger-section .swagger-ui-wrap .footer {
margin-top: 20px;
}
.swagger-section .swagger-ui-wrap p.big,
.swagger-section .swagger-ui-wrap div.big p {
font-size: 1em;
@@ -1066,6 +1069,9 @@
.swagger-section .swagger-ui-wrap form.form_box p strong {
color: black;
}
.swagger-section .swagger-ui-wrap .operation-status td.markdown > p:last-child {
padding-bottom: 0;
}
.swagger-section .title {
font-style: bold;
}
+2 -4
View File
@@ -19,6 +19,7 @@
<script src='swagger-ui.js' type='text/javascript'></script>
<script src='lib/highlight.7.3.pack.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 type="text/javascript">
$(function () {
@@ -34,13 +35,11 @@
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
onComplete: function(swaggerApi, swaggerUi){
if(typeof initOAuth == "function") {
/*
initOAuth({
clientId: "your-client-id",
realm: "your-realms",
appName: "your-app-name"
});
*/
}
$('pre code').each(function(i, e) {
@@ -53,7 +52,7 @@
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
sorter : "alpha"
apisSorter: "alpha"
});
function addApiKeyAuthorization(){
@@ -71,7 +70,6 @@
/*
var apiKey = "myApiKeyXXXX123456789";
$('#input_apiKey').val(apiKey);
addApiKeyAuthorization();
*/
window.swaggerUi.load();
+1 -1
View File
@@ -281,4 +281,4 @@ window.onOAuthComplete = function onOAuthComplete(token) {
}
}
}
}
}
+551 -250
View File
File diff suppressed because one or more lines are too long
+9 -8
View File
File diff suppressed because one or more lines are too long
+11 -1
View File
@@ -15,6 +15,7 @@ var connect = require('gulp-connect');
var header = require('gulp-header');
var pkg = require('./package.json');
var order = require('gulp-order');
var jshint = require('gulp-jshint');
var banner = ['/**',
' * <%= pkg.name %> - <%= pkg.description %>',
' * @version v<%= pkg.version %>',
@@ -48,10 +49,19 @@ function templates() {
.on('error', log);
}
/**
* JShint all *.js files
*/
gulp.task('lint', function () {
return gulp.src('./src/main/javascript/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
/**
* Build a distribution
*/
gulp.task('dist', ['clean'], function() {
gulp.task('dist', ['clean','lint'], function() {
return es.merge(
gulp.src([
+53
View File
@@ -0,0 +1,53 @@
'use strict';
/* jshint quotmark: double */
window.SwaggerTranslator.learn({
"Warning: Deprecated":"Warning: Deprecated",
"Implementation Notes":"Implementation Notes",
"Response Class":"Response Class",
"Status":"Status",
"Parameters":"Parameters",
"Parameter":"Parameter",
"Value":"Value",
"Description":"Description",
"Parameter Type":"Parameter Type",
"Data Type":"Data Type",
"Response Messages":"Response Messages",
"HTTP Status Code":"HTTP Status Code",
"Reason":"Reason",
"Response Model":"Response Model",
"Request URL":"Request URL",
"Response Body":"Response Body",
"Response Code":"Response Code",
"Response Headers":"Response Headers",
"Hide Response":"Hide Response",
"Try it out!":"Try it out!",
"Show/Hide":"Show/Hide",
"List Operations":"List Operations",
"Expand Operations":"Expand Operations",
"Raw":"Raw",
"can't parse JSON. Raw result":"can't parse JSON. Raw result",
"Model Schema":"Model Schema",
"Model":"Model",
"apply":"apply",
"Username":"Username",
"Password":"Password",
"Terms of service":"Terms of service",
"Created by":"Created by",
"See more at":"See more at",
"Contact the developer":"Contact the developer",
"api version":"api version",
"Response Content Type":"Response Content Type",
"fetching resource":"fetching resource",
"fetching resource list":"fetching resource list",
"Explore":"Explore",
"Show Swagger Petstore Example Apis":"Show Swagger Petstore Example Apis",
"Show Wordnik Developer Apis":"Show Wordnik Developer Apis",
"Can't read from server. It may not have the appropriate access-control-origin settings.":"Can't read from server. It may not have the appropriate access-control-origin settings.",
"Please specify the protocol for":"Please specify the protocol for",
"Can't read swagger JSON from":"Can't read swagger JSON from",
"Finished Loading Resource Information. Rendering Swagger UI":"Finished Loading Resource Information. Rendering Swagger UI",
"Unable to read api":"Unable to read api",
"from path":"from path",
"server returned":"server returned"
});
+53
View File
@@ -0,0 +1,53 @@
'use strict';
/* jshint quotmark: double */
window.SwaggerTranslator.learn({
"Warning: Deprecated":"Ворнинг: Депрекейтед",
"Implementation Notes":"Заметки",
"Response Class":"Пример ответа",
"Status":"Статус",
"Parameters":"Параметры",
"Parameter":"Параметр",
"Value":"Значение",
"Description":"Описание",
"Parameter Type":"Тип параметра",
"Data Type":"Тип данных",
"HTTP Status Code":"HTTP код",
"Reason":"Причина",
"Response Model":"Структура ответа",
"Request URL":"URL запроса",
"Response Body":"Тело ответа",
"Response Code":"HTTP код ответа",
"Response Headers":"Заголовки ответа",
"Hide Response":"Спрятать ответ",
"Response Messages":"Что может прийти в ответ",
"Try it out!":"Попробовать!",
"Show/Hide":"Показать/Скрыть",
"List Operations":"Операции кратко",
"Expand Operations":"Операции подробно",
"Raw":"В сыром виде",
"can't parse JSON. Raw result":"Не удается распарсить ответ:",
"Model Schema":"Структура",
"Model":"Описание",
"apply":"применить",
"Username":"Имя пользователя",
"Password":"Пароль",
"Terms of service":"Условия использования",
"Created by":"Разработано",
"See more at":"Еще тут",
"Contact the developer":"Связаться с разработчиком",
"api version":"Версия API",
"Response Content Type":"Content Type ответа",
"fetching resource":"Получение ресурса",
"fetching resource list":"Получение ресурсов",
"Explore":"Поехали",
"Show Swagger Petstore Example Apis":"Показать примеры АПИ",
"Show Wordnik Developer Apis":"Показать АПИ Wordnik Developer",
"Can't read from server. It may not have the appropriate access-control-origin settings.":"Не удается получить ответ от сервера. Возможно, какая-то лажа с настройками доступа",
"Please specify the protocol for":"Пожалуйста, укажите протогол для",
"Can't read swagger JSON from":"Не получается прочитать swagger json из",
"Finished Loading Resource Information. Rendering Swagger UI":"Загрузка информации о ресурсах завершена. Рендерим",
"Unable to read api":"Не удалось прочитать api",
"from path":"по адресу",
"server returned":"сервер сказал"
});
+38
View File
@@ -0,0 +1,38 @@
'use strict';
/**
* Translator for documentation pages.
*
* To enable translation you should include one of language-files in your index.html
* after <script src='lang/translator.js' type='text/javascript'></script>.
* For example - <script src='lang/ru.js' type='text/javascript'></script>
*
* If you wish to translate some new texsts you should do two things:
* 1. Add a new phrase pair ("New Phrase": "New Translation") into your language file (for example lang/ru.js). It will be great if you add it in other language files too.
* 2. Mark that text it templates this way <anyHtmlTag data-sw-translate>New Phrase</anyHtmlTag> or <anyHtmlTag data-sw-translate value='New Phrase'/>.
* The main thing here is attribute data-sw-translate. Only inner html, title-attribute and value-attribute are going to translate.
*
*/
window.SwaggerTranslator = {
_words:[],
translate: function() {
var $this = this;
$('[data-sw-translate]').each(function() {
$(this).html($this._tryTranslate($(this).html()));
$(this).val($this._tryTranslate($(this).val()));
$(this).attr('title', $this._tryTranslate($(this).attr('title')));
});
},
_tryTranslate: function(word) {
return this._words[word] !== undefined ? this._words[word] : word;
},
learn: function(wordsMap) {
this._words = wordsMap;
}
};
+1 -1
View File
@@ -281,4 +281,4 @@ window.onOAuthComplete = function onOAuthComplete(token) {
}
}
}
}
}
+11 -6
View File
@@ -1,14 +1,17 @@
{
"name": "swagger-ui",
"author": "Tony Tam <fehguy@gmail.com>",
"contributors": [{
"name": "Mohsen Azimi",
"email": "me@azimi.me"
}],
"contributors": [
{
"name": "Mohsen Azimi",
"email": "me@azimi.me"
}
],
"description": "Swagger UI is a dependency-free collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API",
"version": "2.1.1-M2",
"version": "2.1.5-M2",
"homepage": "http://swagger.io",
"license": "Apache 2.0",
"main": "dist/swagger-ui.js",
"scripts": {
"build": "gulp",
"serve": "gulp serve",
@@ -35,6 +38,7 @@
"gulp-declare": "^0.3.0",
"gulp-handlebars": "^3.0.1",
"gulp-header": "^1.2.2",
"gulp-jshint": "^1.10.0",
"gulp-less": "^3.0.1",
"gulp-order": "^1.1.1",
"gulp-rename": "^1.2.0",
@@ -42,9 +46,10 @@
"gulp-watch": "^4.1.1",
"gulp-wrap": "^0.11.0",
"http-server": "git+https://github.com/nodeapps/http-server.git",
"jshint-stylish": "^1.0.1",
"less": "^2.4.0",
"mocha": "^2.1.0",
"selenium-webdriver": "^2.45.0",
"swagger-client": "2.1.2-M2"
"swagger-client": "2.1.6-M2"
}
}
+6
View File
@@ -274,6 +274,9 @@
font-weight: bold;
font-size: 25px;
}
.swagger-section .swagger-ui-wrap .footer {
margin-top: 20px;
}
.swagger-section .swagger-ui-wrap p.big,
.swagger-section .swagger-ui-wrap div.big p {
font-size: 1em;
@@ -1066,6 +1069,9 @@
.swagger-section .swagger-ui-wrap form.form_box p strong {
color: black;
}
.swagger-section .swagger-ui-wrap .operation-status td.markdown > p:last-child {
padding-bottom: 0;
}
.swagger-section .title {
font-style: bold;
}
+6
View File
@@ -274,6 +274,9 @@
font-weight: bold;
font-size: 25px;
}
.swagger-section .swagger-ui-wrap .footer {
margin-top: 20px;
}
.swagger-section .swagger-ui-wrap p.big,
.swagger-section .swagger-ui-wrap div.big p {
font-size: 1em;
@@ -1066,6 +1069,9 @@
.swagger-section .swagger-ui-wrap form.form_box p strong {
color: black;
}
.swagger-section .swagger-ui-wrap .operation-status td.markdown > p:last-child {
padding-bottom: 0;
}
.swagger-section .title {
font-style: bold;
}
+2 -4
View File
@@ -19,6 +19,7 @@
<script src='swagger-ui.js' type='text/javascript'></script>
<script src='lib/highlight.7.3.pack.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 type="text/javascript">
$(function () {
@@ -34,13 +35,11 @@
supportedSubmitMethods: ['get', 'post', 'put', 'delete', 'patch'],
onComplete: function(swaggerApi, swaggerUi){
if(typeof initOAuth == "function") {
/*
initOAuth({
clientId: "your-client-id",
realm: "your-realms",
appName: "your-app-name"
});
*/
}
$('pre code').each(function(i, e) {
@@ -53,7 +52,7 @@
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
sorter : "alpha"
apisSorter: "alpha"
});
function addApiKeyAuthorization(){
@@ -71,7 +70,6 @@
/*
var apiKey = "myApiKeyXXXX123456789";
$('#input_apiKey').val(apiKey);
addApiKeyAuthorization();
*/
window.swaggerUi.load();
+6 -1
View File
@@ -13,6 +13,9 @@ window.SwaggerUi = Backbone.Router.extend({
// SwaggerUi accepts all the same options as SwaggerApi
initialize: function(options) {
options = options || {};
if(!options.highlightSizeThreshold) {
options.highlightSizeThreshold = 100000;
}
// Allow dom_id to be overridden
if (options.dom_id) {
@@ -87,7 +90,9 @@ window.SwaggerUi = Backbone.Router.extend({
if (url && url.indexOf('http') !== 0) {
url = this.buildUrl(window.location.href.toString(), url);
}
if(this.api) {
this.options.authorizations = this.api.clientAuthorizations;
}
this.options.url = url;
this.headerView.update(url);
+30 -1
View File
@@ -4,4 +4,33 @@ Handlebars.registerHelper('sanitize', function(html) {
// Strip the script tags from the html, and return it as a Handlebars.SafeString
html = html.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '');
return new Handlebars.SafeString(html);
});
});
Handlebars.registerHelper('renderTextParam', function(param) {
var result, type = 'text';
var isArray = param.type.toLowerCase() === 'array' || param.allowMultiple;
var defaultValue = isArray && Array.isArray(param.default) ? param.default.join('\n') : param.default;
if (typeof defaultValue === 'undefined') {
defaultValue = '';
}
if(param.format && param.format === 'password') {
type = 'password';
}
if(isArray) {
result = '<textarea class=\'body-textarea' + (param.required ? ' required' : '') + '\' name=\'' + param.name + '\'';
result += ' placeholder=\'Provide multiple values in new lines' + (param.required ? ' (at least one required).' : '.') + '\'>';
result += defaultValue + '</textarea>';
} else {
var parameterClass = 'parameter';
if(param.required) {
parameterClass += ' required';
}
result = '<input class=\'' + parameterClass + '\' minlength=\'' + (param.required ? 1 : 0) + '\'';
result += ' name=\'' + param.name +'\' placeholder=\'' + (param.required ? '(required)' : '') + '\'';
result += ' type=\'' + type + '\' value=\'' + defaultValue + '\'/>';
}
return new Handlebars.SafeString(result);
});
+4 -2
View File
@@ -68,7 +68,9 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
} else {
// Default validator
this.model.validatorUrl = window.location.protocol + '//online.swagger.io/validator';
if(window.location.protocol.indexOf('http') === 0) {
this.model.validatorUrl = window.location.protocol + '//online.swagger.io/validator';
}
}
}
},
@@ -130,7 +132,7 @@ SwaggerUi.Views.MainView = Backbone.View.extend({
auths: auths,
swaggerOptions: this.options.swaggerOptions
});
$('#resources').append(resourceView.render().el);
$('#resources', this.el).append(resourceView.render().el);
},
clear: function(){
+61 -7
View File
@@ -275,11 +275,30 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
error_free = false;
}
});
form.find('select.required').each(function() {
$(this).removeClass('error');
if (this.selectedIndex === -1) {
$(this).addClass('error');
$(this).wiggle({
callback: (function(_this) {
return function() {
$(_this).focus();
};
})(this)
});
error_free = false;
}
});
if (error_free) {
map = {};
opts = {
parent: this
};
if(this.options.swaggerOptions) {
for(var key in this.options.swaggerOptions) {
opts[key] = this.options.swaggerOptions[key];
}
}
isFileUpload = false;
ref1 = form.find('input');
for (l = 0, len = ref1.length; l < len; l++) {
@@ -295,8 +314,9 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
ref2 = form.find('textarea');
for (m = 0, len1 = ref2.length; m < len1; m++) {
o = ref2[m];
if ((o.value !== null) && jQuery.trim(o.value).length > 0) {
map[o.name] = o.value;
val = this.getTextAreaValue(o);
if ((val !== null) && jQuery.trim(val).length > 0) {
map[o.name] = val;
}
}
ref3 = form.find('select');
@@ -313,7 +333,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
if (isFileUpload) {
return this.handleFileUpload(map, form);
} else {
return this.model['do'](map, opts, this.showCompleteStatus, this.showErrorStatus, this);
return this.model.execute(map, opts, this.showCompleteStatus, this.showErrorStatus, this);
}
}
},
@@ -549,6 +569,7 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
url = response.request.url;
}
var headers = response.headers;
content = jQuery.trim(content);
// if server is nice, and sends content-type back, we can use it
var contentType = null;
@@ -608,10 +629,10 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
pre = $('<audio controls>').append($('<source>').attr('src', url).attr('type', contentType));
// Download
} else if (headers['Content-Disposition'].test(/attachment/) ||
headers['content-disposition'].test(/attachment/) ||
headers['Content-Description'].test(/File Transfer/) ||
headers['content-description'].test(/File Transfer/)) {
} else if (headers['Content-Disposition'] && (/attachment/).test(headers['Content-Disposition']) ||
headers['content-disposition'] && (/attachment/).test(headers['content-disposition']) ||
headers['Content-Description'] && (/File Transfer/).test(headers['Content-Description']) ||
headers['content-description'] && (/File Transfer/).test(headers['content-description'])) {
if ('Blob' in window) {
var type = contentType || 'text/html';
@@ -666,5 +687,38 @@ SwaggerUi.Views.OperationView = Backbone.View.extend({
} else {
Docs.expandOperation(elem);
}
},
getTextAreaValue: function(textArea) {
var param, parsed, result, i;
if (textArea.value === null || jQuery.trim(textArea.value).length === 0) {
return null;
}
param = this.getParamByName(textArea.name);
if (param && param.type && param.type.toLowerCase() === 'array') {
parsed = textArea.value.split('\n');
result = [];
for (i = 0; i < parsed.length; i++) {
if (parsed[i] !== null && jQuery.trim(parsed[i]).length > 0) {
result.push(parsed[i]);
}
}
return result.length > 0 ? result : null;
} else {
return textArea.value;
}
},
getParamByName: function(name) {
var i;
if (this.model.parameters) {
for(i = 0; i < this.model.parameters.length; i++) {
if (this.model.parameters[i].name === name) {
return this.model.parameters[i];
}
}
}
return null;
}
});
+3 -3
View File
@@ -4,9 +4,9 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
initialize: function(){
Handlebars.registerHelper('isArray', function(param, opts) {
if (param.type.toLowerCase() === 'array' || param.allowMultiple) {
opts.fn(this);
return opts.fn(this);
} else {
opts.inverse(this);
return opts.inverse(this);
}
});
},
@@ -98,4 +98,4 @@ SwaggerUi.Views.ParameterView = Backbone.View.extend({
}
}
}
});
});
+8
View File
@@ -153,6 +153,10 @@
font-size: 25px;
}
.footer {
margin-top: 20px;
}
p.big, div.big p {
font-size: 1em;
margin-bottom: 10px;
@@ -1081,6 +1085,10 @@
}
}
}
.operation-status td.markdown > p:last-child {
padding-bottom: 0;
}
}
}
-2
View File
@@ -18,8 +18,6 @@
<ul id='resources'></ul>
<div class="footer">
<br>
<br>
<h4 style="color: #999">[ <span style="font-variant: small-caps">base url</span>: {{basePath}}
{{#if info.version}}
, <span style="font-variant: small-caps">api version</span>: {{info.version}}
+1 -1
View File
@@ -85,7 +85,7 @@
{{#if isReadOnly}}
{{else}}
<div class='sandbox_header'>
<input class='submit' name='commit' type='button' value='Try it out!' />
<input class='submit' type='button' value='Try it out!' />
<a href='#' class='response_hider' style='display:none'>Hide Response</a>
<span class='response_throbber' style='display:none'></span>
</div>
+2 -5
View File
@@ -21,11 +21,8 @@
<input type="file" name='{{name}}'/>
<div class="parameter-content-type" />
{{else}}
{{#if default}}
<input class='parameter' minlength='0' name='{{name}}' placeholder='' type='text' value='{{default}}'/>
{{else}}
<input class='parameter' minlength='0' name='{{name}}' placeholder='' type='text' value=''/>
{{/if}}
{{#renderTextParam this}}
{{/renderTextParam}}
{{/if}}
{{/if}}
+5 -4
View File
@@ -1,9 +1,10 @@
{{#if required}}
<td class='code required'>{{name}}</td>
{{/if}}
{{else}}
<td class='code'>{{name}}</td>
{{/if}}
<td>
<select {{#isArray this}} multiple='multiple'{{/isArray}} class='parameter' name='{{name}}'>
<select {{#isArray this}} multiple='multiple'{{/isArray}} class={{#if required}}'parameter required'{{else}}'parameter'{{/if}} name='{{name}}'>
{{#if required}}
{{else}}
{{#if default}}
@@ -23,6 +24,6 @@
{{/each}}
</select>
</td>
<td class="markdown">{{{description}}}</td>
<td class="markdown">{{#if required}}<strong>{{/if}}{{{description}}}{{#if required}}</strong>{{/if}}</td>
<td>{{{paramType}}}</td>
<td><span class="model-signature"></span></td>
<td><span class="model-signature"></span></td>
@@ -1,7 +1,7 @@
<td class='code required'>{{name}}</td>
<td>
{{#if isBody}}
<textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='{{name}}'>{{default}}</textarea>
<textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='{{name}}'>{{default}}</textarea>
{{else}}
{{#if default}}
{{default}}
+2 -5
View File
@@ -18,11 +18,8 @@
{{#if isFile}}
<input class='parameter' class='required' type='file' name='{{name}}'/>
{{else}}
{{#if default}}
<input class='parameter required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value='{{default}}'/>
{{else}}
<input class='parameter required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value=''/>
{{/if}}
{{#renderTextParam this}}
{{/renderTextParam}}
{{/if}}
{{/if}}
</td>
+1 -1
View File
@@ -1,5 +1,5 @@
<td width='15%' class='code'>{{code}}</td>
<td>{{{message}}}</td>
<td class="markdown">{{{message}}}</td>
<td width='50%'><span class="model-signature" /></td>
<td class="headers">
<table>
+2 -1
View File
@@ -594,7 +594,8 @@
"name": "password",
"description": "The password for login in clear text",
"required": false,
"type": "string"
"type": "string",
"format": "password"
}
],
"responses": {