Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
4764d33
Pass swagger options to swagger-js Operation#execute method
aurelian Apr 1, 2015
c84202c
Pass empty object to guard the case when options.swaggerOptions is un…
aurelian Apr 2, 2015
af39ae0
Multiple values for array type parameters as separated lines in the t…
valdemon Apr 3, 2015
ad56131
Corrected for Travis build.
valdemon Apr 3, 2015
6a1707e
Prevent the OperationView to display an error in case the response co…
Apr 16, 2015
569830b
Use jQuery for trimming
BjRo Apr 16, 2015
82a89a7
updated version
fehguy Apr 16, 2015
29b9f48
Fix for #1113
mgttlinger Apr 17, 2015
5b72632
created files in dist
mgttlinger Apr 17, 2015
d76a62c
Merge pull request #1180 from mgttlinger/develop_2.0
fehguy Apr 21, 2015
f4b2c49
fix #1191, forgot to put returns on handlebar helper
ponelat Apr 22, 2015
69bf18a
Merge pull request #1192 from ponelat/fix/issue-1191
fehguy Apr 28, 2015
558cc92
add jshint to gulp..lint and dist
ponelat Apr 29, 2015
ec86ee2
uncomment swagger-oauth and add script
ponelat Apr 29, 2015
37f4850
fixes #1205, remove dead line
ponelat May 5, 2015
9666eae
updated swagger-client version
fehguy May 8, 2015
ccfc4aa
manually added #1086, #1089
fehguy May 8, 2015
6d5f6de
Fix for #1252, check for http protocol before setting validator url
fehguy May 8, 2015
ba855e3
Merge pull request #1112 from 3scale/op-execute
fehguy May 8, 2015
1696a1b
added fix from outdated PR #1122
fehguy May 8, 2015
9c58ed7
Merge branch 'multi-value-params' of ssh://github.com/valdemon/swagge…
fehguy May 8, 2015
d7bc0c6
Merge branch 'valdemon-multi-value-params' into develop_2.0
fehguy May 8, 2015
cdd8082
fix for #1253
fehguy May 8, 2015
17dca9e
Merge pull request #1173 from BjRo/handle_whitespace_in_response
fehguy May 8, 2015
b1efe88
merged logic from #1177
fehguy May 8, 2015
99bec82
Merge branch 'develop_2.0' of github.com:swagger-api/swagger-ui into …
fehguy May 8, 2015
5abd281
merged
fehguy May 8, 2015
4f31169
merged
fehguy May 8, 2015
e0d17d0
Merge pull request #1224 from ponelat/fix/1221
fehguy May 8, 2015
8661a0f
Merge pull request #1225 from ponelat/fix/1194
fehguy May 8, 2015
a02cea1
merged #1238
fehguy May 8, 2015
97ed093
Merge pull request #1239 from ponelat/develop_2.0
fehguy May 8, 2015
4365d34
rebuilt
fehguy May 8, 2015
9e70c95
updated per #931
fehguy May 8, 2015
261e189
set highlight threshold per #1184
fehguy May 8, 2015
5640bf7
updated swagger-client version
fehguy May 8, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ dist/**/*.woff binary
dist/**/*.woff2 binary
dist/**/*.png binary
dist/*.html text

src/main/html/images/*.png binary
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions dist/css/print.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions dist/css/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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) {
Expand Down Expand Up @@ -71,7 +70,6 @@
/*
var apiKey = "myApiKeyXXXX123456789";
$('#input_apiKey').val(apiKey);
addApiKeyAuthorization();
*/

window.swaggerUi.load();
Expand Down
2 changes: 1 addition & 1 deletion dist/lib/swagger-oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,4 @@ window.onOAuthComplete = function onOAuthComplete(token) {
}
}
}
}
}
630 changes: 431 additions & 199 deletions dist/swagger-ui.js

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions dist/swagger-ui.min.js

Large diffs are not rendered by default.

12 changes: 11 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>',
Expand Down Expand Up @@ -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([
Expand Down
53 changes: 53 additions & 0 deletions lang/en.js
Original file line number Diff line number Diff line change
@@ -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 changes: 53 additions & 0 deletions lang/ru.js
Original file line number Diff line number Diff line change
@@ -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 changes: 38 additions & 0 deletions lang/translator.js
Original file line number Diff line number Diff line change
@@ -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;
}
};
2 changes: 1 addition & 1 deletion lib/swagger-oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,4 @@ window.onOAuthComplete = function onOAuthComplete(token) {
}
}
}
}
}
17 changes: 11 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -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.2-M2",
"homepage": "http://swagger.io",
"license": "Apache 2.0",
"main": "dist/swagger-ui.js",
"scripts": {
"build": "gulp",
"serve": "gulp serve",
Expand All @@ -35,16 +38,18 @@
"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",
"gulp-uglify": "^1.1.0",
"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.4-M2"
}
}
3 changes: 3 additions & 0 deletions src/main/html/css/print.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/main/html/css/screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/main/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand All @@ -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) {
Expand Down Expand Up @@ -71,7 +70,6 @@
/*
var apiKey = "myApiKeyXXXX123456789";
$('#input_apiKey').val(apiKey);
addApiKeyAuthorization();
*/

window.swaggerUi.load();
Expand Down
3 changes: 3 additions & 0 deletions src/main/javascript/SwaggerUi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
27 changes: 26 additions & 1 deletion src/main/javascript/helpers/handlebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,29 @@ 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 {
result = '<input class=\'parameter\'' + (param.required ? ' class=\'required\'' : '') + ' minlength=\'' + (param.required ? 1 : 0) + '\'';
result += ' name=\'' + param.name +'\' placeholder=\'' + (param.required ? '(required)' : '') + '\'';
result += ' type=\'' + type + '\' value=\'' + defaultValue + '\'/>';
}
return new Handlebars.SafeString(result);
});
Loading