├── test ├── mocha.opts ├── .jshintrc ├── e2e │ ├── driver.js │ ├── servers.js │ ├── v1.js │ └── v2.js └── specs │ └── v1.2 │ └── petstore │ ├── api-docs.json │ ├── store.json │ └── user.json ├── .dockerignore ├── .jshintignore ├── dist ├── images │ ├── favicon.ico │ ├── logo_small.png │ ├── throbber.gif │ ├── wordnik_api.png │ ├── explorer_icons.png │ ├── favicon-16x16.png │ ├── favicon-32x32.png │ └── pet_store_api.png ├── fonts │ ├── DroidSans.ttf │ └── DroidSans-Bold.ttf ├── lib │ ├── jquery.slideto.min.js │ ├── jquery.wiggle.min.js │ ├── jquery.ba-bbq.min.js │ └── highlight.7.3.pack.js ├── css │ ├── typography.css │ ├── reset.css │ └── style.css ├── o2c.html ├── lang │ ├── translator.js │ ├── zh-cn.js │ ├── ja.js │ ├── ru.js │ ├── en.js │ ├── tr.js │ ├── pt.js │ ├── es.js │ ├── fr.js │ └── it.js └── index.html ├── src └── main │ ├── html │ ├── fonts │ │ ├── DroidSans.ttf │ │ └── DroidSans-Bold.ttf │ ├── images │ │ ├── favicon.ico │ │ ├── throbber.gif │ │ ├── logo_small.png │ │ ├── wordnik_api.png │ │ ├── favicon-16x16.png │ │ ├── favicon-32x32.png │ │ ├── pet_store_api.png │ │ └── explorer_icons.png │ ├── css │ │ ├── typography.css │ │ ├── reset.css │ │ └── style.css │ ├── o2c.html │ └── index.html │ ├── javascript │ ├── view │ │ ├── ContentTypeView.js │ │ ├── ResponseContentTypeView.js │ │ ├── ParameterContentTypeView.js │ │ ├── StatusCodeView.js │ │ ├── HeaderView.js │ │ ├── ApiKeyButton.js │ │ ├── BasicAuthButton.js │ │ ├── SignatureView.js │ │ ├── ResourceView.js │ │ ├── ParameterView.js │ │ └── MainView.js │ ├── helpers │ │ └── handlebars.js │ ├── doc.js │ └── SwaggerUi.js │ ├── template │ ├── content_type.handlebars │ ├── parameter_content_type.handlebars │ ├── response_content_type.handlebars │ ├── status_code.handlebars │ ├── signature.handlebars │ ├── param_readonly.handlebars │ ├── apikey_button_view.handlebars │ ├── param_readonly_required.handlebars │ ├── basic_auth_button_view.handlebars │ ├── param_list.handlebars │ ├── resource.handlebars │ ├── param.handlebars │ ├── param_required.handlebars │ ├── main.handlebars │ └── operation.handlebars │ └── less │ ├── print.less │ ├── reset.less │ ├── auth.less │ ├── highlight_default.less │ ├── screen.less │ └── style.less ├── .npmignore ├── index.js ├── .gitignore ├── .travis.yml ├── .gitattributes ├── lib ├── jquery.slideto.min.js ├── jquery.wiggle.min.js ├── jquery.ba-bbq.min.js ├── highlight.7.3.pack.js └── swagger-oauth.js ├── CONTRIBUTING.md ├── bower.json ├── LICENSE ├── Dockerfile ├── .jshintrc ├── lang ├── translator.js ├── zh-cn.js ├── ja.js ├── ru.js ├── en.js ├── tr.js ├── pt.js ├── es.js ├── fr.js └── it.js ├── package.json └── gulpfile.js /test/mocha.opts: -------------------------------------------------------------------------------- 1 | --recursive --timeout 5000 -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | .git 2 | node_modules 3 | bower_components 4 | *.swp 5 | -------------------------------------------------------------------------------- /.jshintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | src/main/javascript/doc.js 3 | dist 4 | lib 5 | .log -------------------------------------------------------------------------------- /dist/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/dist/images/favicon.ico -------------------------------------------------------------------------------- /dist/fonts/DroidSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/dist/fonts/DroidSans.ttf -------------------------------------------------------------------------------- /dist/images/logo_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/dist/images/logo_small.png -------------------------------------------------------------------------------- /dist/images/throbber.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/dist/images/throbber.gif -------------------------------------------------------------------------------- /dist/images/wordnik_api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/dist/images/wordnik_api.png -------------------------------------------------------------------------------- /dist/fonts/DroidSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/dist/fonts/DroidSans-Bold.ttf -------------------------------------------------------------------------------- /dist/images/explorer_icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/dist/images/explorer_icons.png -------------------------------------------------------------------------------- /dist/images/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/dist/images/favicon-16x16.png -------------------------------------------------------------------------------- /dist/images/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/dist/images/favicon-32x32.png -------------------------------------------------------------------------------- /dist/images/pet_store_api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/dist/images/pet_store_api.png -------------------------------------------------------------------------------- /src/main/html/fonts/DroidSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/src/main/html/fonts/DroidSans.ttf -------------------------------------------------------------------------------- /src/main/html/images/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/src/main/html/images/favicon.ico -------------------------------------------------------------------------------- /src/main/html/images/throbber.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/src/main/html/images/throbber.gif -------------------------------------------------------------------------------- /src/main/html/images/logo_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/src/main/html/images/logo_small.png -------------------------------------------------------------------------------- /src/main/html/images/wordnik_api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/src/main/html/images/wordnik_api.png -------------------------------------------------------------------------------- /src/main/html/fonts/DroidSans-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/src/main/html/fonts/DroidSans-Bold.ttf -------------------------------------------------------------------------------- /src/main/html/images/favicon-16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/src/main/html/images/favicon-16x16.png -------------------------------------------------------------------------------- /src/main/html/images/favicon-32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/src/main/html/images/favicon-32x32.png -------------------------------------------------------------------------------- /src/main/html/images/pet_store_api.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/src/main/html/images/pet_store_api.png -------------------------------------------------------------------------------- /src/main/html/images/explorer_icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/raphael/swagger-ui/master/src/main/html/images/explorer_icons.png -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | *.sublime-* 2 | example.html 3 | *.tgz 4 | .classpath 5 | .project 6 | .npmignore 7 | dist/sample.html 8 | dist/spec.js 9 | node_modules 10 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var pack = require('./package'); 2 | var path = require('path'); 3 | 4 | module.exports = { 5 | version: pack.version, 6 | dist: path.resolve(__dirname, 'dist') 7 | }; -------------------------------------------------------------------------------- /test/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../.jshintrc", 3 | "expr": true, 4 | "jasmine": true, 5 | "globals": { 6 | "before": false, 7 | "after": false, 8 | "expect": true 9 | } 10 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_STORE 2 | *.ipr 3 | *.iml 4 | *.iws 5 | web/ 6 | lib/*.zip 7 | version.properties 8 | .sass-cache 9 | swagger-ui.sublime-workspace 10 | .idea 11 | .project 12 | node_modules/* 13 | /nbproject/private/ -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: node_js 3 | node_js: 4 | - '0.10' 5 | - '0.12' 6 | install: 7 | - export DISPLAY=:99.0 8 | - sh -e /etc/init.d/xvfb start 9 | - npm i -g jshint 10 | - npm install 11 | -------------------------------------------------------------------------------- /test/e2e/driver.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Web driver manager 3 | */ 4 | 'use strict'; 5 | 6 | var webdriver = require('selenium-webdriver'); 7 | 8 | var driver = new webdriver.Builder().withCapabilities(webdriver.Capabilities.firefox()).build(); 9 | 10 | module.exports = driver; -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text eol=lf 2 | 3 | dist/**/*.js binary 4 | dist/**/*.map binary 5 | dist/**/*.eot binary 6 | dist/**/*.svg binary 7 | dist/**/*.ttf binary 8 | dist/**/*.woff binary 9 | dist/**/*.woff2 binary 10 | dist/**/*.png binary 11 | dist/*.html text 12 | 13 | src/main/html/images/*.png binary 14 | -------------------------------------------------------------------------------- /src/main/javascript/view/ContentTypeView.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | SwaggerUi.Views.ContentTypeView = Backbone.View.extend({ 4 | initialize: function() {}, 5 | 6 | render: function(){ 7 | this.model.contentTypeId = 'ct' + Math.random(); 8 | $(this.el).html(Handlebars.templates.content_type(this.model)); 9 | return this; 10 | } 11 | }); -------------------------------------------------------------------------------- /lib/jquery.slideto.min.js: -------------------------------------------------------------------------------- 1 | (function(b){b.fn.slideto=function(a){a=b.extend({slide_duration:"slow",highlight_duration:3E3,highlight:true,highlight_color:"#FFFF99"},a);return this.each(function(){obj=b(this);b("body").animate({scrollTop:obj.offset().top},a.slide_duration,function(){a.highlight&&b.ui.version&&obj.effect("highlight",{color:a.highlight_color},a.highlight_duration)})})}})(jQuery); 2 | -------------------------------------------------------------------------------- /src/main/javascript/view/ResponseContentTypeView.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | SwaggerUi.Views.ResponseContentTypeView = Backbone.View.extend({ 4 | initialize: function(){}, 5 | 6 | render: function(){ 7 | this.model.responseContentTypeId = 'rct' + Math.random(); 8 | $(this.el).html(Handlebars.templates.response_content_type(this.model)); 9 | return this; 10 | } 11 | }); -------------------------------------------------------------------------------- /dist/lib/jquery.slideto.min.js: -------------------------------------------------------------------------------- 1 | (function(b){b.fn.slideto=function(a){a=b.extend({slide_duration:"slow",highlight_duration:3E3,highlight:true,highlight_color:"#FFFF99"},a);return this.each(function(){obj=b(this);b("body").animate({scrollTop:obj.offset().top},a.slide_duration,function(){a.highlight&&b.ui.version&&obj.effect("highlight",{color:a.highlight_color},a.highlight_duration)})})}})(jQuery); 2 | -------------------------------------------------------------------------------- /src/main/template/content_type.handlebars: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /src/main/javascript/view/ParameterContentTypeView.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | SwaggerUi.Views.ParameterContentTypeView = Backbone.View.extend({ 4 | initialize: function () {}, 5 | 6 | render: function(){ 7 | this.model.parameterContentTypeId = 'pct' + Math.random(); 8 | $(this.el).html(Handlebars.templates.parameter_content_type(this.model)); 9 | return this; 10 | } 11 | 12 | }); -------------------------------------------------------------------------------- /src/main/template/parameter_content_type.handlebars: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /src/main/template/response_content_type.handlebars: -------------------------------------------------------------------------------- 1 | 2 | 11 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | SwaggerUI uses [SwaggerJS](https://github.com/swagger-api/swagger-js) library for many internal operations. If you see errors in 2 | [`swagger-client.js`](lib/swagger-client.js) file, you should probably open the issue in [SwaggerJS](https://github.com/swagger-api/swagger-js) repository. 3 | 4 | Please open issues related to Swagger specifications in [Swagger Specs](https://github.com/swagger-api/swagger-spec) repository. 5 | -------------------------------------------------------------------------------- /src/main/template/status_code.handlebars: -------------------------------------------------------------------------------- 1 | {{code}} 2 | {{{message}}} 3 | 4 | 5 | 6 | 7 | {{#each headers}} 8 | 9 | 10 | 11 | 12 | 13 | {{/each}} 14 | 15 |
{{@key}}{{this.description}}{{this.type}}
16 | -------------------------------------------------------------------------------- /src/main/template/signature.handlebars: -------------------------------------------------------------------------------- 1 |
2 | 6 |
7 | 8 |
9 |
10 | {{{signature}}} 11 |
12 | 13 |
14 |
{{sampleJSON}}
15 | 16 |
17 |
18 | 19 | -------------------------------------------------------------------------------- /dist/css/typography.css: -------------------------------------------------------------------------------- 1 | /* Google Font's Droid Sans */ 2 | @font-face { 3 | font-family: 'Droid Sans'; 4 | font-style: normal; 5 | font-weight: 400; 6 | src: local('Droid Sans'), local('DroidSans'), url('../fonts/DroidSans.ttf') format('truetype'); 7 | } 8 | /* Google Font's Droid Sans Bold */ 9 | @font-face { 10 | font-family: 'Droid Sans'; 11 | font-style: normal; 12 | font-weight: 700; 13 | src: local('Droid Sans Bold'), local('DroidSans-Bold'), url('../fonts/DroidSans-Bold.ttf') format('truetype'); 14 | } 15 | -------------------------------------------------------------------------------- /src/main/html/css/typography.css: -------------------------------------------------------------------------------- 1 | /* Google Font's Droid Sans */ 2 | @font-face { 3 | font-family: 'Droid Sans'; 4 | font-style: normal; 5 | font-weight: 400; 6 | src: local('Droid Sans'), local('DroidSans'), url('../fonts/DroidSans.ttf') format('truetype'); 7 | } 8 | /* Google Font's Droid Sans Bold */ 9 | @font-face { 10 | font-family: 'Droid Sans'; 11 | font-style: normal; 12 | font-weight: 700; 13 | src: local('Droid Sans Bold'), local('DroidSans-Bold'), url('../fonts/DroidSans-Bold.ttf') format('truetype'); 14 | } 15 | -------------------------------------------------------------------------------- /dist/o2c.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "swagger-ui", 3 | "main": "dist/index.html", 4 | "authors": [ 5 | "Mohsen Azimi " 6 | ], 7 | "description": "Swagger UI", 8 | "moduleType": [ 9 | "globals" 10 | ], 11 | "keywords": [ 12 | "Swagger", 13 | "API" 14 | ], 15 | "license": "Copyright 2015 SmartBear Software", 16 | "homepage": "http://swagger.io", 17 | "private": true, 18 | "ignore": [ 19 | "**/.*", 20 | "node_modules", 21 | "bower_components", 22 | "test", 23 | "tests" 24 | ] 25 | } 26 | -------------------------------------------------------------------------------- /src/main/html/o2c.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/main/template/param_readonly.handlebars: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{#if isBody}} 4 | 5 | {{else}} 6 | {{#if default}} 7 | {{default}} 8 | {{else}} 9 | (empty) 10 | {{/if}} 11 | {{/if}} 12 | 13 | {{{description}}} 14 | {{{paramType}}} 15 | 16 | -------------------------------------------------------------------------------- /src/main/template/apikey_button_view.handlebars: -------------------------------------------------------------------------------- 1 | 2 |
3 |
4 |
5 | 6 | 7 |
8 |
9 | -------------------------------------------------------------------------------- /src/main/template/param_readonly_required.handlebars: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{#if isBody}} 4 | 5 | {{else}} 6 | {{#if default}} 7 | {{default}} 8 | {{else}} 9 | (empty) 10 | {{/if}} 11 | {{/if}} 12 | 13 | {{{description}}} 14 | {{{paramType}}} 15 | 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2015 SmartBear Software 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at [apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0) 6 | 7 | Unless required by applicable law or agreed to in writing, software 8 | distributed under the License is distributed on an "AS IS" BASIS, 9 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 10 | See the License for the specific language governing permissions and 11 | limitations under the License. 12 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | ### 2 | # swagger-ui-builder - https://github.com/swagger-api/swagger-ui/ 3 | # Container for building the swagger-ui static site 4 | # 5 | # Build: docker build -t swagger-ui-builder . 6 | # Run: docker run -v $PWD/dist:/build/dist swagger-ui-builder 7 | # 8 | ### 9 | 10 | FROM ubuntu:14.04 11 | MAINTAINER dnephin@gmail.com 12 | 13 | ENV DEBIAN_FRONTEND noninteractive 14 | 15 | RUN apt-get update && apt-get install -y git npm nodejs openjdk-7-jre 16 | RUN ln -s /usr/bin/nodejs /usr/local/bin/node 17 | 18 | WORKDIR /build 19 | ADD package.json /build/package.json 20 | RUN npm install 21 | ADD . /build 22 | CMD ./node_modules/gulp/bin/gulp.js serve 23 | -------------------------------------------------------------------------------- /lib/jquery.wiggle.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | jQuery Wiggle 3 | Author: WonderGroup, Jordan Thomas 4 | URL: http://labs.wondergroup.com/demos/mini-ui/index.html 5 | License: MIT (http://en.wikipedia.org/wiki/MIT_License) 6 | */ 7 | jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('
').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"-="+o.travel},o.speed).animate({left:"+="+o.travel*2},o.speed*2).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);} 8 | if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});}; -------------------------------------------------------------------------------- /dist/lib/jquery.wiggle.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | jQuery Wiggle 3 | Author: WonderGroup, Jordan Thomas 4 | URL: http://labs.wondergroup.com/demos/mini-ui/index.html 5 | License: MIT (http://en.wikipedia.org/wiki/MIT_License) 6 | */ 7 | jQuery.fn.wiggle=function(o){var d={speed:50,wiggles:3,travel:5,callback:null};var o=jQuery.extend(d,o);return this.each(function(){var cache=this;var wrap=jQuery(this).wrap('
').css("position","relative");var calls=0;for(i=1;i<=o.wiggles;i++){jQuery(this).animate({left:"-="+o.travel},o.speed).animate({left:"+="+o.travel*2},o.speed*2).animate({left:"-="+o.travel},o.speed,function(){calls++;if(jQuery(cache).parent().hasClass('wiggle-wrap')){jQuery(cache).parent().replaceWith(cache);} 8 | if(calls==o.wiggles&&jQuery.isFunction(o.callback)){o.callback();}});}});}; -------------------------------------------------------------------------------- /src/main/template/basic_auth_button_view.handlebars: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 | 6 |
7 | 8 | 9 |
10 |
11 | 12 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "browser": true, 4 | "esnext": true, 5 | "bitwise": true, 6 | "curly": true, 7 | "eqeqeq": true, 8 | "immed": true, 9 | "indent": 2, 10 | "latedef": false, 11 | "newcap": true, 12 | "noarg": true, 13 | "quotmark": "single", 14 | "regexp": true, 15 | "undef": true, 16 | "unused": true, 17 | "strict": true, 18 | "trailing": true, 19 | "smarttabs": true, 20 | "validthis": true, 21 | "globals": { 22 | 23 | // Libraries 24 | "_": false, 25 | "$": false, 26 | "Backbone": false, 27 | "Handlebars": false, 28 | "jQuery": false, 29 | "marked": false, 30 | "SwaggerClient": false, 31 | "hljs": false, 32 | "SwaggerUi": false, 33 | "define": false, 34 | 35 | // Global object 36 | // TODO: remove these 37 | "Docs": false 38 | } 39 | } -------------------------------------------------------------------------------- /src/main/template/param_list.handlebars: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | {{#if required}}{{/if}}{{{description}}}{{#if required}}{{/if}} 18 | {{{paramType}}} 19 | 20 | -------------------------------------------------------------------------------- /src/main/less/print.less: -------------------------------------------------------------------------------- 1 | @import 'src/main/less/highlight_default.less'; 2 | @import 'src/main/less/specs.less'; 3 | @import 'src/main/less/auth.less'; 4 | 5 | #header { 6 | display: none; 7 | } 8 | 9 | .swagger-section { 10 | 11 | .swagger-ui-wrap { 12 | 13 | .model-signature pre { 14 | max-height: none; 15 | } 16 | 17 | .body-textarea { 18 | width: 100px; 19 | } 20 | 21 | input.parameter { 22 | width: 100px; 23 | } 24 | 25 | ul#resources { 26 | li.resource { 27 | div.heading ul.options { 28 | display: none; 29 | } 30 | ul.endpoints { 31 | display: block !important; 32 | li.endpoint ul.operations li.operation div.content { 33 | display: block !important; 34 | } 35 | } 36 | } 37 | } 38 | 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /src/main/template/resource.handlebars: -------------------------------------------------------------------------------- 1 |
2 |

3 | {{name}} {{#summary}} : {{/summary}}{{{summary}}} 4 |

5 | 25 |
26 | 29 | -------------------------------------------------------------------------------- /src/main/javascript/view/StatusCodeView.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | SwaggerUi.Views.StatusCodeView = Backbone.View.extend({ 4 | initialize: function (opts) { 5 | this.options = opts || {}; 6 | this.router = this.options.router; 7 | }, 8 | 9 | render: function(){ 10 | $(this.el).html(Handlebars.templates.status_code(this.model)); 11 | 12 | if (this.router.api.models.hasOwnProperty(this.model.responseModel)) { 13 | var responseModel = { 14 | sampleJSON: JSON.stringify(this.router.api.models[this.model.responseModel].createJSONSample(), null, 2), 15 | isParam: false, 16 | signature: this.router.api.models[this.model.responseModel].getMockSignature(), 17 | }; 18 | 19 | var responseModelView = new SwaggerUi.Views.SignatureView({model: responseModel, tagName: 'div'}); 20 | $('.model-signature', this.$el).append(responseModelView.render().el); 21 | } else { 22 | $('.model-signature', this.$el).html(''); 23 | } 24 | return this; 25 | } 26 | }); -------------------------------------------------------------------------------- /src/main/template/param.handlebars: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{#if isBody}} 5 | {{#if isFile}} 6 | 7 |
8 | {{else}} 9 | {{#if default}} 10 | 11 |
12 |
13 | {{else}} 14 | 15 |
16 |
17 | {{/if}} 18 | {{/if}} 19 | {{else}} 20 | {{#if isFile}} 21 | 22 |
23 | {{else}} 24 | {{#renderTextParam this}} 25 | {{/renderTextParam}} 26 | {{/if}} 27 | {{/if}} 28 | 29 | 30 | {{{description}}} 31 | {{{paramType}}} 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /src/main/template/param_required.handlebars: -------------------------------------------------------------------------------- 1 | 2 | 3 | {{#if isBody}} 4 | {{#if isFile}} 5 | 6 | {{else}} 7 | {{#if default}} 8 | 9 |
10 |
11 | {{else}} 12 | 13 |
14 |
15 | {{/if}} 16 | {{/if}} 17 | {{else}} 18 | {{#if isFile}} 19 | 20 | {{else}} 21 | {{#renderTextParam this}} 22 | {{/renderTextParam}} 23 | {{/if}} 24 | {{/if}} 25 | 26 | 27 | {{{description}}} 28 | 29 | {{{paramType}}} 30 | 31 | -------------------------------------------------------------------------------- /src/main/javascript/view/HeaderView.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | SwaggerUi.Views.HeaderView = Backbone.View.extend({ 4 | events: { 5 | 'click #show-pet-store-icon' : 'showPetStore', 6 | 'click #explore' : 'showCustom', 7 | 'keyup #input_baseUrl' : 'showCustomOnKeyup', 8 | 'keyup #input_apiKey' : 'showCustomOnKeyup' 9 | }, 10 | 11 | initialize: function(){}, 12 | 13 | showPetStore: function(){ 14 | this.trigger('update-swagger-ui', { 15 | url:'http://petstore.swagger.io/v2/swagger.json' 16 | }); 17 | }, 18 | 19 | showCustomOnKeyup: function(e){ 20 | if (e.keyCode === 13) { 21 | this.showCustom(); 22 | } 23 | }, 24 | 25 | showCustom: function(e){ 26 | if (e) { 27 | e.preventDefault(); 28 | } 29 | 30 | this.trigger('update-swagger-ui', { 31 | url: $('#input_baseUrl').val(), 32 | apiKey: $('#input_apiKey').val() 33 | }); 34 | }, 35 | 36 | update: function(url, apiKey, trigger){ 37 | if (trigger === undefined) { 38 | trigger = false; 39 | } 40 | 41 | $('#input_baseUrl').val(url); 42 | 43 | //$('#input_apiKey').val(apiKey); 44 | if (trigger) { 45 | this.trigger('update-swagger-ui', {url:url}); 46 | } 47 | } 48 | }); 49 | -------------------------------------------------------------------------------- /test/e2e/servers.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Swagger UI and Specs Servers 3 | */ 4 | 'use strict'; 5 | 6 | var path = require('path'); 7 | var createServer = require('http-server').createServer; 8 | 9 | var dist = path.join(__dirname, '..', '..', 'dist'); 10 | var specs = path.join(__dirname, '..', '..', 'test', 'specs'); 11 | var DOCS_PORT = 8080; 12 | var SPEC_SERVER_PORT = 8081; 13 | 14 | var driver = require('./driver'); 15 | 16 | var swaggerUI; 17 | var specServer; 18 | 19 | module.exports.start = function (specsLocation, done) { 20 | swaggerUI = createServer({ root: dist, cors: true }); 21 | specServer = createServer({ root: specs, cors: true }); 22 | 23 | swaggerUI.listen(DOCS_PORT); 24 | specServer.listen(SPEC_SERVER_PORT); 25 | 26 | var swaggerSpecLocation = encodeURIComponent('http://localhost:' + SPEC_SERVER_PORT + specsLocation); 27 | var url = 'http://localhost:' + DOCS_PORT + '/index.html?url=' + swaggerSpecLocation; 28 | 29 | setTimeout(function(){ 30 | driver.get(url); 31 | setTimeout(function() { 32 | done(); 33 | }, 2000); 34 | console.log('waiting for UI to load'); 35 | }, process.env.TRAVIS ? 20000 : 5000); 36 | console.log('waiting for server to start'); 37 | }; 38 | 39 | module.exports.close = function() { 40 | swaggerUI.close(); 41 | specServer.close(); 42 | }; 43 | -------------------------------------------------------------------------------- /src/main/less/reset.less: -------------------------------------------------------------------------------- 1 | /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */ 2 | 3 | html, body, div, span, applet, object, iframe, 4 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 5 | a, abbr, acronym, address, big, cite, code, 6 | del, dfn, em, img, ins, kbd, q, s, samp, 7 | small, strike, strong, sub, sup, tt, var, 8 | b, u, i, center, 9 | dl, dt, dd, ol, ul, li, 10 | fieldset, form, label, legend, 11 | table, caption, tbody, tfoot, thead, tr, th, td, 12 | article, aside, canvas, details, embed, 13 | figure, figcaption, footer, header, hgroup, 14 | menu, nav, output, ruby, section, summary, 15 | time, mark, audio, video { 16 | margin: 0; 17 | padding: 0; 18 | border: 0; 19 | font-size: 100%; 20 | font: inherit; 21 | vertical-align: baseline; 22 | } 23 | 24 | /* HTML5 display-role reset for older browsers */ 25 | article, aside, details, figcaption, figure, 26 | footer, header, hgroup, menu, nav, section { 27 | display: block; 28 | } 29 | 30 | body { 31 | line-height: 1; 32 | } 33 | 34 | ol, ul { 35 | list-style: none; 36 | } 37 | 38 | blockquote, q { 39 | quotes: none; 40 | } 41 | 42 | blockquote:before, blockquote:after, 43 | q:before, q:after { 44 | content: ''; 45 | content: none; 46 | } 47 | 48 | table { 49 | border-collapse: collapse; 50 | border-spacing: 0; 51 | } 52 | -------------------------------------------------------------------------------- /src/main/javascript/view/ApiKeyButton.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | SwaggerUi.Views.ApiKeyButton = Backbone.View.extend({ // TODO: append this to global SwaggerUi 4 | 5 | events:{ 6 | 'click #apikey_button' : 'toggleApiKeyContainer', 7 | 'click #apply_api_key' : 'applyApiKey' 8 | }, 9 | 10 | initialize: function(opts){ 11 | this.options = opts || {}; 12 | this.router = this.options.router; 13 | }, 14 | 15 | render: function(){ 16 | var template = this.template(); 17 | $(this.el).html(template(this.model)); 18 | 19 | return this; 20 | }, 21 | 22 | 23 | applyApiKey: function(){ 24 | var keyAuth = new SwaggerClient.ApiKeyAuthorization( 25 | this.model.name, 26 | $('#input_apiKey_entry').val(), 27 | this.model.in 28 | ); 29 | this.router.api.clientAuthorizations.add(this.model.name, keyAuth); 30 | this.router.load(); 31 | $('#apikey_container').show(); 32 | }, 33 | 34 | toggleApiKeyContainer: function(){ 35 | if ($('#apikey_container').length) { 36 | 37 | var elem = $('#apikey_container').first(); 38 | 39 | if (elem.is(':visible')){ 40 | elem.hide(); 41 | } else { 42 | 43 | // hide others 44 | $('.auth_container').hide(); 45 | elem.show(); 46 | } 47 | } 48 | }, 49 | 50 | template: function(){ 51 | return Handlebars.templates.apikey_button_view; 52 | } 53 | 54 | }); -------------------------------------------------------------------------------- /src/main/javascript/view/BasicAuthButton.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | SwaggerUi.Views.BasicAuthButton = Backbone.View.extend({ 4 | 5 | 6 | initialize: function (opts) { 7 | this.options = opts || {}; 8 | this.router = this.options.router; 9 | }, 10 | 11 | render: function(){ 12 | var template = this.template(); 13 | $(this.el).html(template(this.model)); 14 | 15 | return this; 16 | }, 17 | 18 | events: { 19 | 'click #basic_auth_button' : 'togglePasswordContainer', 20 | 'click #apply_basic_auth' : 'applyPassword' 21 | }, 22 | 23 | applyPassword: function(){ 24 | var username = $('.input_username').val(); 25 | var password = $('.input_password').val(); 26 | var basicAuth = new SwaggerClient.PasswordAuthorization('basic', username, password); 27 | this.router.api.clientAuthorizations.add(this.model.type, basicAuth); 28 | this.router.load(); 29 | $('#basic_auth_container').hide(); 30 | }, 31 | 32 | togglePasswordContainer: function(){ 33 | if ($('#basic_auth_container').length) { 34 | var elem = $('#basic_auth_container').show(); 35 | if (elem.is(':visible')){ 36 | elem.slideUp(); 37 | } else { 38 | // hide others 39 | $('.auth_container').hide(); 40 | elem.show(); 41 | } 42 | } 43 | }, 44 | 45 | template: function(){ 46 | return Handlebars.templates.basic_auth_button_view; 47 | } 48 | 49 | }); -------------------------------------------------------------------------------- /src/main/less/auth.less: -------------------------------------------------------------------------------- 1 | .swagger-section { 2 | 3 | .title { 4 | font-style: bold; 5 | } 6 | 7 | .secondary_form { 8 | display: none; 9 | } 10 | 11 | .main_image { 12 | display: block; 13 | margin-left: auto; 14 | margin-right: auto; 15 | } 16 | 17 | .oauth_body { 18 | margin-left: 100px; 19 | margin-right: 100px; 20 | } 21 | 22 | .oauth_submit { 23 | text-align: center; 24 | } 25 | 26 | .api-popup-dialog { 27 | z-index: 10000; 28 | position: absolute; 29 | width: 500px; 30 | background: #FFF; 31 | padding: 20px; 32 | border: 1px solid #ccc; 33 | border-radius: 5px; 34 | display: none; 35 | font-size: 13px; 36 | color: #777; 37 | 38 | .api-popup-title{ 39 | font-size: 24px; 40 | padding: 10px 0; 41 | } 42 | 43 | .api-popup-title{ 44 | font-size: 24px; 45 | padding: 10px 0; 46 | } 47 | 48 | 49 | p.error-msg { 50 | padding-left: 5px; 51 | padding-bottom: 5px; 52 | } 53 | 54 | button.api-popup-authbtn { 55 | height: 30px; 56 | } 57 | button.api-popup-cancel { 58 | height: 30px; 59 | } 60 | } 61 | 62 | .api-popup-scopes { 63 | padding: 10px 20px; 64 | 65 | li { 66 | padding: 5px 0; 67 | line-height: 20px; 68 | } 69 | 70 | .api-scope-desc { 71 | padding-left: 20px; 72 | font-style: italic; 73 | } 74 | li input { 75 | position: relative; 76 | top: 2px; 77 | } 78 | } 79 | .api-popup-actions { 80 | padding-top: 10px; 81 | } 82 | 83 | } 84 | -------------------------------------------------------------------------------- /lang/translator.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Translator for documentation pages. 5 | * 6 | * To enable translation you should include one of language-files in your index.html 7 | * after . 8 | * For example - 9 | * 10 | * If you wish to translate some new texsts you should do two things: 11 | * 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. 12 | * 2. Mark that text it templates this way New Phrase or . 13 | * The main thing here is attribute data-sw-translate. Only inner html, title-attribute and value-attribute are going to translate. 14 | * 15 | */ 16 | window.SwaggerTranslator = { 17 | 18 | _words:[], 19 | 20 | translate: function(sel) { 21 | var $this = this; 22 | sel = sel || '[data-sw-translate]'; 23 | 24 | $(sel).each(function() { 25 | $(this).html($this._tryTranslate($(this).html())); 26 | 27 | $(this).val($this._tryTranslate($(this).val())); 28 | $(this).attr('title', $this._tryTranslate($(this).attr('title'))); 29 | }); 30 | }, 31 | 32 | _tryTranslate: function(word) { 33 | return this._words[$.trim(word)] !== undefined ? this._words[$.trim(word)] : word; 34 | }, 35 | 36 | learn: function(wordsMap) { 37 | this._words = wordsMap; 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /dist/lang/translator.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /** 4 | * Translator for documentation pages. 5 | * 6 | * To enable translation you should include one of language-files in your index.html 7 | * after . 8 | * For example - 9 | * 10 | * If you wish to translate some new texsts you should do two things: 11 | * 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. 12 | * 2. Mark that text it templates this way New Phrase or . 13 | * The main thing here is attribute data-sw-translate. Only inner html, title-attribute and value-attribute are going to translate. 14 | * 15 | */ 16 | window.SwaggerTranslator = { 17 | 18 | _words:[], 19 | 20 | translate: function(sel) { 21 | var $this = this; 22 | sel = sel || '[data-sw-translate]'; 23 | 24 | $(sel).each(function() { 25 | $(this).html($this._tryTranslate($(this).html())); 26 | 27 | $(this).val($this._tryTranslate($(this).val())); 28 | $(this).attr('title', $this._tryTranslate($(this).attr('title'))); 29 | }); 30 | }, 31 | 32 | _tryTranslate: function(word) { 33 | return this._words[$.trim(word)] !== undefined ? this._words[$.trim(word)] : word; 34 | }, 35 | 36 | learn: function(wordsMap) { 37 | this._words = wordsMap; 38 | } 39 | }; 40 | -------------------------------------------------------------------------------- /src/main/template/main.handlebars: -------------------------------------------------------------------------------- 1 |
2 | {{#if info}} 3 |
{{info.title}}
4 |
{{{info.description}}}
5 | {{#if externalDocs}} 6 |

{{externalDocs.description}}

7 | {{externalDocs.url}} 8 | {{/if}} 9 | {{#if info.termsOfServiceUrl}}{{/if}} 10 | {{#if info.contact.name}}
Created by {{info.contact.name}}
{{/if}} 11 | {{#if info.contact.url}}{{/if}} 12 | {{#if info.contact.email}}{{/if}} 13 | {{#if info.license}}{{/if}} 14 | {{/if}} 15 |
16 |
17 |
    18 | 19 | 30 |
    31 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "swagger-ui", 3 | "author": "Tony Tam ", 4 | "contributors": [ 5 | { 6 | "name": "Mohsen Azimi", 7 | "email": "me@azimi.me" 8 | } 9 | ], 10 | "description": "Swagger UI is a dependency-free collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API", 11 | "version": "2.1.4", 12 | "homepage": "http://swagger.io", 13 | "license": "Apache-2.0", 14 | "main": "dist/swagger-ui.js", 15 | "scripts": { 16 | "build": "gulp", 17 | "serve": "gulp serve", 18 | "prejshint": "gulp", 19 | "jshint": "jshint .", 20 | "pretest": "npm run jshint", 21 | "test": "mocha" 22 | }, 23 | "repository": { 24 | "type": "git", 25 | "url": "https://github.com/swagger-api/swagger-ui.git" 26 | }, 27 | "readmeFilename": "README.md", 28 | "devDependencies": { 29 | "chai": "^2.1.0", 30 | "cors": "^2.5.3", 31 | "docco": "^0.7.0", 32 | "event-stream": "^3.2.2", 33 | "express": "^4.12.0", 34 | "gulp": "^3.8.11", 35 | "gulp-clean": "^0.3.1", 36 | "gulp-concat": "^2.5.2", 37 | "gulp-connect": "^2.2.0", 38 | "gulp-declare": "^0.3.0", 39 | "gulp-handlebars": "^3.0.1", 40 | "gulp-header": "^1.2.2", 41 | "gulp-jshint": "^1.10.0", 42 | "gulp-less": "^3.0.1", 43 | "gulp-order": "^1.1.1", 44 | "gulp-rename": "^1.2.0", 45 | "gulp-uglify": "^1.1.0", 46 | "gulp-watch": "^4.1.1", 47 | "gulp-wrap": "^0.11.0", 48 | "http-server": "git+https://github.com/nodeapps/http-server.git", 49 | "jshint-stylish": "^1.0.1", 50 | "less": "^2.4.0", 51 | "mocha": "^2.1.0", 52 | "selenium-webdriver": "^2.45.0", 53 | "swagger-client": "2.1.6" 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /dist/css/reset.css: -------------------------------------------------------------------------------- 1 | /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */ 2 | html, 3 | body, 4 | div, 5 | span, 6 | applet, 7 | object, 8 | iframe, 9 | h1, 10 | h2, 11 | h3, 12 | h4, 13 | h5, 14 | h6, 15 | p, 16 | blockquote, 17 | pre, 18 | a, 19 | abbr, 20 | acronym, 21 | address, 22 | big, 23 | cite, 24 | code, 25 | del, 26 | dfn, 27 | em, 28 | img, 29 | ins, 30 | kbd, 31 | q, 32 | s, 33 | samp, 34 | small, 35 | strike, 36 | strong, 37 | sub, 38 | sup, 39 | tt, 40 | var, 41 | b, 42 | u, 43 | i, 44 | center, 45 | dl, 46 | dt, 47 | dd, 48 | ol, 49 | ul, 50 | li, 51 | fieldset, 52 | form, 53 | label, 54 | legend, 55 | table, 56 | caption, 57 | tbody, 58 | tfoot, 59 | thead, 60 | tr, 61 | th, 62 | td, 63 | article, 64 | aside, 65 | canvas, 66 | details, 67 | embed, 68 | figure, 69 | figcaption, 70 | footer, 71 | header, 72 | hgroup, 73 | menu, 74 | nav, 75 | output, 76 | ruby, 77 | section, 78 | summary, 79 | time, 80 | mark, 81 | audio, 82 | video { 83 | margin: 0; 84 | padding: 0; 85 | border: 0; 86 | font-size: 100%; 87 | font: inherit; 88 | vertical-align: baseline; 89 | } 90 | /* HTML5 display-role reset for older browsers */ 91 | article, 92 | aside, 93 | details, 94 | figcaption, 95 | figure, 96 | footer, 97 | header, 98 | hgroup, 99 | menu, 100 | nav, 101 | section { 102 | display: block; 103 | } 104 | body { 105 | line-height: 1; 106 | } 107 | ol, 108 | ul { 109 | list-style: none; 110 | } 111 | blockquote, 112 | q { 113 | quotes: none; 114 | } 115 | blockquote:before, 116 | blockquote:after, 117 | q:before, 118 | q:after { 119 | content: ''; 120 | content: none; 121 | } 122 | table { 123 | border-collapse: collapse; 124 | border-spacing: 0; 125 | } 126 | -------------------------------------------------------------------------------- /src/main/html/css/reset.css: -------------------------------------------------------------------------------- 1 | /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */ 2 | html, 3 | body, 4 | div, 5 | span, 6 | applet, 7 | object, 8 | iframe, 9 | h1, 10 | h2, 11 | h3, 12 | h4, 13 | h5, 14 | h6, 15 | p, 16 | blockquote, 17 | pre, 18 | a, 19 | abbr, 20 | acronym, 21 | address, 22 | big, 23 | cite, 24 | code, 25 | del, 26 | dfn, 27 | em, 28 | img, 29 | ins, 30 | kbd, 31 | q, 32 | s, 33 | samp, 34 | small, 35 | strike, 36 | strong, 37 | sub, 38 | sup, 39 | tt, 40 | var, 41 | b, 42 | u, 43 | i, 44 | center, 45 | dl, 46 | dt, 47 | dd, 48 | ol, 49 | ul, 50 | li, 51 | fieldset, 52 | form, 53 | label, 54 | legend, 55 | table, 56 | caption, 57 | tbody, 58 | tfoot, 59 | thead, 60 | tr, 61 | th, 62 | td, 63 | article, 64 | aside, 65 | canvas, 66 | details, 67 | embed, 68 | figure, 69 | figcaption, 70 | footer, 71 | header, 72 | hgroup, 73 | menu, 74 | nav, 75 | output, 76 | ruby, 77 | section, 78 | summary, 79 | time, 80 | mark, 81 | audio, 82 | video { 83 | margin: 0; 84 | padding: 0; 85 | border: 0; 86 | font-size: 100%; 87 | font: inherit; 88 | vertical-align: baseline; 89 | } 90 | /* HTML5 display-role reset for older browsers */ 91 | article, 92 | aside, 93 | details, 94 | figcaption, 95 | figure, 96 | footer, 97 | header, 98 | hgroup, 99 | menu, 100 | nav, 101 | section { 102 | display: block; 103 | } 104 | body { 105 | line-height: 1; 106 | } 107 | ol, 108 | ul { 109 | list-style: none; 110 | } 111 | blockquote, 112 | q { 113 | quotes: none; 114 | } 115 | blockquote:before, 116 | blockquote:after, 117 | q:before, 118 | q:after { 119 | content: ''; 120 | content: none; 121 | } 122 | table { 123 | border-collapse: collapse; 124 | border-spacing: 0; 125 | } 126 | -------------------------------------------------------------------------------- /lang/zh-cn.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"警告:已过时", 6 | "Implementation Notes":"实现备注", 7 | "Response Class":"响应类", 8 | "Status":"状态", 9 | "Parameters":"参数", 10 | "Parameter":"参数", 11 | "Value":"值", 12 | "Description":"描述", 13 | "Parameter Type":"参数类型", 14 | "Data Type":"数据类型", 15 | "Response Messages":"响应消息", 16 | "HTTP Status Code":"HTTP状态码", 17 | "Reason":"原因", 18 | "Response Model":"响应模型", 19 | "Request URL":"请求URL", 20 | "Response Body":"响应体", 21 | "Response Code":"响应码", 22 | "Response Headers":"响应头", 23 | "Hide Response":"隐藏响应", 24 | "Headers":"头", 25 | "Try it out!":"试一下!", 26 | "Show/Hide":"显示/隐藏", 27 | "List Operations":"显示操作", 28 | "Expand Operations":"展开操作", 29 | "Raw":"原始", 30 | "can't parse JSON. Raw result":"无法解析JSON. 原始结果", 31 | "Model Schema":"模型架构", 32 | "Model":"模型", 33 | "apply":"应用", 34 | "Username":"用户名", 35 | "Password":"密码", 36 | "Terms of service":"服务条款", 37 | "Created by":"创建者", 38 | "See more at":"查看更多:", 39 | "Contact the developer":"联系开发者", 40 | "api version":"api版本", 41 | "Response Content Type":"响应Content Type", 42 | "fetching resource":"正在获取资源", 43 | "fetching resource list":"正在获取资源列表", 44 | "Explore":"浏览", 45 | "Show Swagger Petstore Example Apis":"显示 Swagger Petstore 示例 Apis", 46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"无法从服务器读取。可能没有正确设置access-control-origin。", 47 | "Please specify the protocol for":"请指定协议:", 48 | "Can't read swagger JSON from":"无法读取swagger JSON于", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"已加载资源信息。正在渲染Swagger UI", 50 | "Unable to read api":"无法读取api", 51 | "from path":"从路径", 52 | "server returned":"服务器返回" 53 | }); 54 | -------------------------------------------------------------------------------- /dist/lang/zh-cn.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"警告:已过时", 6 | "Implementation Notes":"实现备注", 7 | "Response Class":"响应类", 8 | "Status":"状态", 9 | "Parameters":"参数", 10 | "Parameter":"参数", 11 | "Value":"值", 12 | "Description":"描述", 13 | "Parameter Type":"参数类型", 14 | "Data Type":"数据类型", 15 | "Response Messages":"响应消息", 16 | "HTTP Status Code":"HTTP状态码", 17 | "Reason":"原因", 18 | "Response Model":"响应模型", 19 | "Request URL":"请求URL", 20 | "Response Body":"响应体", 21 | "Response Code":"响应码", 22 | "Response Headers":"响应头", 23 | "Hide Response":"隐藏响应", 24 | "Headers":"头", 25 | "Try it out!":"试一下!", 26 | "Show/Hide":"显示/隐藏", 27 | "List Operations":"显示操作", 28 | "Expand Operations":"展开操作", 29 | "Raw":"原始", 30 | "can't parse JSON. Raw result":"无法解析JSON. 原始结果", 31 | "Model Schema":"模型架构", 32 | "Model":"模型", 33 | "apply":"应用", 34 | "Username":"用户名", 35 | "Password":"密码", 36 | "Terms of service":"服务条款", 37 | "Created by":"创建者", 38 | "See more at":"查看更多:", 39 | "Contact the developer":"联系开发者", 40 | "api version":"api版本", 41 | "Response Content Type":"响应Content Type", 42 | "fetching resource":"正在获取资源", 43 | "fetching resource list":"正在获取资源列表", 44 | "Explore":"浏览", 45 | "Show Swagger Petstore Example Apis":"显示 Swagger Petstore 示例 Apis", 46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"无法从服务器读取。可能没有正确设置access-control-origin。", 47 | "Please specify the protocol for":"请指定协议:", 48 | "Can't read swagger JSON from":"无法读取swagger JSON于", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"已加载资源信息。正在渲染Swagger UI", 50 | "Unable to read api":"无法读取api", 51 | "from path":"从路径", 52 | "server returned":"服务器返回" 53 | }); 54 | -------------------------------------------------------------------------------- /src/main/javascript/view/SignatureView.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | SwaggerUi.Views.SignatureView = Backbone.View.extend({ 4 | events: { 5 | 'click a.description-link' : 'switchToDescription', 6 | 'click a.snippet-link' : 'switchToSnippet', 7 | 'mousedown .snippet' : 'snippetToTextArea' 8 | }, 9 | 10 | initialize: function () { 11 | 12 | }, 13 | 14 | render: function(){ 15 | 16 | $(this.el).html(Handlebars.templates.signature(this.model)); 17 | 18 | this.switchToSnippet(); 19 | 20 | this.isParam = this.model.isParam; 21 | 22 | if (this.isParam) { 23 | $('.notice', $(this.el)).text('Click to set as parameter value'); 24 | } 25 | 26 | return this; 27 | }, 28 | 29 | // handler for show signature 30 | switchToDescription: function(e){ 31 | if (e) { e.preventDefault(); } 32 | 33 | $('.snippet', $(this.el)).hide(); 34 | $('.description', $(this.el)).show(); 35 | $('.description-link', $(this.el)).addClass('selected'); 36 | $('.snippet-link', $(this.el)).removeClass('selected'); 37 | }, 38 | 39 | // handler for show sample 40 | switchToSnippet: function(e){ 41 | if (e) { e.preventDefault(); } 42 | 43 | $('.description', $(this.el)).hide(); 44 | $('.snippet', $(this.el)).show(); 45 | $('.snippet-link', $(this.el)).addClass('selected'); 46 | $('.description-link', $(this.el)).removeClass('selected'); 47 | }, 48 | 49 | // handler for snippet to text area 50 | snippetToTextArea: function(e) { 51 | if (this.isParam) { 52 | if (e) { e.preventDefault(); } 53 | 54 | var textArea = $('textarea', $(this.el.parentNode.parentNode.parentNode)); 55 | 56 | // Fix for bug in IE 10/11 which causes placeholder text to be copied to "value" 57 | if ($.trim(textArea.val()) === '' || textArea.prop('placeholder') === textArea.val()) { 58 | textArea.val(this.model.sampleJSON); 59 | } 60 | } 61 | } 62 | }); -------------------------------------------------------------------------------- /lang/ja.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"警告: 廃止予定", 6 | "Implementation Notes":"実装メモ", 7 | "Response Class":"レスポンスクラス", 8 | "Status":"ステータス", 9 | "Parameters":"パラメータ群", 10 | "Parameter":"パラメータ", 11 | "Value":"値", 12 | "Description":"説明", 13 | "Parameter Type":"パラメータタイプ", 14 | "Data Type":"データタイプ", 15 | "Response Messages":"レスポンスメッセージ", 16 | "HTTP Status Code":"HTTPステータスコード", 17 | "Reason":"理由", 18 | "Response Model":"レスポンスモデル", 19 | "Request URL":"リクエストURL", 20 | "Response Body":"レスポンスボディ", 21 | "Response Code":"レスポンスコード", 22 | "Response Headers":"レスポンスヘッダ", 23 | "Hide Response":"レスポンスを隠す", 24 | "Headers":"ヘッダ", 25 | "Try it out!":"実際に実行!", 26 | "Show/Hide":"表示/非表示", 27 | "List Operations":"操作一覧", 28 | "Expand Operations":"操作の展開", 29 | "Raw":"Raw", 30 | "can't parse JSON. Raw result":"JSONへ解釈できません. 未加工の結果", 31 | "Model Schema":"モデルスキーマ", 32 | "Model":"モデル", 33 | "apply":"実行", 34 | "Username":"ユーザ名", 35 | "Password":"パスワード", 36 | "Terms of service":"サービス利用規約", 37 | "Created by":"Created by", 38 | "See more at":"See more at", 39 | "Contact the developer":"開発者に連絡", 40 | "api version":"APIバージョン", 41 | "Response Content Type":"レスポンス コンテンツタイプ", 42 | "fetching resource":"リソースの取得", 43 | "fetching resource list":"リソース一覧の取得", 44 | "Explore":"Explore", 45 | "Show Swagger Petstore Example Apis":"SwaggerペットストアAPIの表示", 46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"サーバから読み込めません. 適切なaccess-control-origin設定を持っていない可能性があります.", 47 | "Please specify the protocol for":"プロトコルを指定してください", 48 | "Can't read swagger JSON from":"次からswagger JSONを読み込めません", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"リソース情報の読み込みが完了しました. Swagger UIを描画しています", 50 | "Unable to read api":"APIを読み込めません", 51 | "from path":"次のパスから", 52 | "server returned":"サーバからの返答" 53 | }); 54 | -------------------------------------------------------------------------------- /dist/lang/ja.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"警告: 廃止予定", 6 | "Implementation Notes":"実装メモ", 7 | "Response Class":"レスポンスクラス", 8 | "Status":"ステータス", 9 | "Parameters":"パラメータ群", 10 | "Parameter":"パラメータ", 11 | "Value":"値", 12 | "Description":"説明", 13 | "Parameter Type":"パラメータタイプ", 14 | "Data Type":"データタイプ", 15 | "Response Messages":"レスポンスメッセージ", 16 | "HTTP Status Code":"HTTPステータスコード", 17 | "Reason":"理由", 18 | "Response Model":"レスポンスモデル", 19 | "Request URL":"リクエストURL", 20 | "Response Body":"レスポンスボディ", 21 | "Response Code":"レスポンスコード", 22 | "Response Headers":"レスポンスヘッダ", 23 | "Hide Response":"レスポンスを隠す", 24 | "Headers":"ヘッダ", 25 | "Try it out!":"実際に実行!", 26 | "Show/Hide":"表示/非表示", 27 | "List Operations":"操作一覧", 28 | "Expand Operations":"操作の展開", 29 | "Raw":"Raw", 30 | "can't parse JSON. Raw result":"JSONへ解釈できません. 未加工の結果", 31 | "Model Schema":"モデルスキーマ", 32 | "Model":"モデル", 33 | "apply":"実行", 34 | "Username":"ユーザ名", 35 | "Password":"パスワード", 36 | "Terms of service":"サービス利用規約", 37 | "Created by":"Created by", 38 | "See more at":"See more at", 39 | "Contact the developer":"開発者に連絡", 40 | "api version":"APIバージョン", 41 | "Response Content Type":"レスポンス コンテンツタイプ", 42 | "fetching resource":"リソースの取得", 43 | "fetching resource list":"リソース一覧の取得", 44 | "Explore":"Explore", 45 | "Show Swagger Petstore Example Apis":"SwaggerペットストアAPIの表示", 46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"サーバから読み込めません. 適切なaccess-control-origin設定を持っていない可能性があります.", 47 | "Please specify the protocol for":"プロトコルを指定してください", 48 | "Can't read swagger JSON from":"次からswagger JSONを読み込めません", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"リソース情報の読み込みが完了しました. Swagger UIを描画しています", 50 | "Unable to read api":"APIを読み込めません", 51 | "from path":"次のパスから", 52 | "server returned":"サーバからの返答" 53 | }); 54 | -------------------------------------------------------------------------------- /test/specs/v1.2/petstore/api-docs.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiVersion": "1.0.0", 3 | "swaggerVersion": "1.2", 4 | "apis": [ 5 | { 6 | "path": "http://localhost:8081/v1.2/petstore/pet.json", 7 | "description": "Operations about pets" 8 | }, 9 | { 10 | "path": "http://localhost:8081/v1.2/petstore/user.json", 11 | "description": "Operations about user" 12 | }, 13 | { 14 | "path": "http://localhost:8081/v1.2/petstore/store.json", 15 | "description": "Operations about store" 16 | } 17 | ], 18 | "authorizations": { 19 | "oauth2": { 20 | "type": "oauth2", 21 | "scopes": [ 22 | { 23 | "scope": "email", 24 | "description": "Access to your email address" 25 | }, 26 | { 27 | "scope": "pets", 28 | "description": "Access to your pets" 29 | } 30 | ], 31 | "grantTypes": { 32 | "implicit": { 33 | "loginEndpoint": { 34 | "url": "http://petstore.swagger.io/oauth/dialog" 35 | }, 36 | "tokenName": "access_token" 37 | }, 38 | "authorization_code": { 39 | "tokenRequestEndpoint": { 40 | "url": "http://petstore.swagger.io/oauth/requestToken", 41 | "clientIdName": "client_id", 42 | "clientSecretName": "client_secret" 43 | }, 44 | "tokenEndpoint": { 45 | "url": "http://petstore.swagger.io/oauth/token", 46 | "tokenName": "access_code" 47 | } 48 | } 49 | } 50 | } 51 | }, 52 | "info": { 53 | "title": "Swagger Sample App", 54 | "description": "This is a sample server Petstore server. You can find out more about Swagger \n at http://swagger.io or on irc.freenode.net, #swagger. For this sample,\n you can use the api key \"special-key\" to test the authorization filters", 55 | "termsOfServiceUrl": "http://swagger.io/terms/", 56 | "contact": "apiteam@swagger.io", 57 | "license": "Apache 2.0", 58 | "licenseUrl": "http://www.apache.org/licenses/LICENSE-2.0.html" 59 | } 60 | } -------------------------------------------------------------------------------- /src/main/javascript/view/ResourceView.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | SwaggerUi.Views.ResourceView = Backbone.View.extend({ 4 | initialize: function(opts) { 5 | opts = opts || {}; 6 | this.router = opts.router; 7 | this.auths = opts.auths; 8 | if ('' === this.model.description) { 9 | this.model.description = null; 10 | } 11 | if (this.model.description) { 12 | this.model.summary = this.model.description; 13 | } 14 | }, 15 | 16 | render: function(){ 17 | var methods = {}; 18 | 19 | 20 | $(this.el).html(Handlebars.templates.resource(this.model)); 21 | 22 | // Render each operation 23 | for (var i = 0; i < this.model.operationsArray.length; i++) { 24 | var operation = this.model.operationsArray[i]; 25 | var counter = 0; 26 | var id = operation.nickname; 27 | 28 | while (typeof methods[id] !== 'undefined') { 29 | id = id + '_' + counter; 30 | counter += 1; 31 | } 32 | 33 | methods[id] = operation; 34 | 35 | operation.nickname = id; 36 | operation.parentId = this.model.id; 37 | this.addOperation(operation); 38 | } 39 | 40 | $('.toggleEndpointList', this.el).click(this.callDocs.bind(this, 'toggleEndpointListForResource')); 41 | $('.collapseResource', this.el).click(this.callDocs.bind(this, 'collapseOperationsForResource')); 42 | $('.expandResource', this.el).click(this.callDocs.bind(this, 'expandOperationsForResource')); 43 | 44 | return this; 45 | }, 46 | 47 | addOperation: function(operation) { 48 | 49 | operation.number = this.number; 50 | 51 | // Render an operation and add it to operations li 52 | var operationView = new SwaggerUi.Views.OperationView({ 53 | model: operation, 54 | router: this.router, 55 | tagName: 'li', 56 | className: 'endpoint', 57 | swaggerOptions: this.options.swaggerOptions, 58 | auths: this.auths 59 | }); 60 | 61 | $('.endpoints', $(this.el)).append(operationView.render().el); 62 | 63 | this.number++; 64 | 65 | }, 66 | // Generic Event handler (`Docs` is global) 67 | 68 | 69 | callDocs: function(fnName, e) { 70 | e.preventDefault(); 71 | Docs[fnName](e.currentTarget.getAttribute('data-id')); 72 | } 73 | }); -------------------------------------------------------------------------------- /src/main/javascript/helpers/handlebars.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Handlebars.registerHelper('sanitize', function(html) { 4 | // Strip the script tags from the html, and return it as a Handlebars.SafeString 5 | html = html.replace(/)<[^<]*)*<\/script>/gi, ''); 6 | return new Handlebars.SafeString(html); 7 | }); 8 | 9 | Handlebars.registerHelper('renderTextParam', function(param) { 10 | var result, type = 'text', idAtt = ''; 11 | var isArray = param.type.toLowerCase() === 'array' || param.allowMultiple; 12 | var defaultValue = isArray && Array.isArray(param.default) ? param.default.join('\n') : param.default; 13 | 14 | var dataVendorExtensions = Object.keys(param).filter(function(property) { 15 | // filter X-data- properties 16 | return property.match(/^X-data-/i) !== null; 17 | }).reduce(function(result, property) { 18 | // remove X- from property name, so it results in html attributes like data-foo='bar' 19 | return result += ' ' + property.substring(2, property.length) + '=\'' + param[property] + '\''; 20 | }, ''); 21 | 22 | if (typeof defaultValue === 'undefined') { 23 | defaultValue = ''; 24 | } 25 | 26 | if(param.format && param.format === 'password') { 27 | type = 'password'; 28 | } 29 | 30 | if(param.valueId) { 31 | idAtt = ' id=\'' + param.valueId + '\''; 32 | } 33 | 34 | if(isArray) { 35 | result = ''; 38 | } else { 39 | var parameterClass = 'parameter'; 40 | if(param.required) { 41 | parameterClass += ' required'; 42 | } 43 | result = ''; 46 | } 47 | return new Handlebars.SafeString(result); 48 | }); 49 | -------------------------------------------------------------------------------- /lang/ru.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Ворнинг: Депрекейтед", 6 | "Implementation Notes":"Заметки", 7 | "Response Class":"Пример ответа", 8 | "Status":"Статус", 9 | "Parameters":"Параметры", 10 | "Parameter":"Параметр", 11 | "Value":"Значение", 12 | "Description":"Описание", 13 | "Parameter Type":"Тип параметра", 14 | "Data Type":"Тип данных", 15 | "HTTP Status Code":"HTTP код", 16 | "Reason":"Причина", 17 | "Response Model":"Структура ответа", 18 | "Request URL":"URL запроса", 19 | "Response Body":"Тело ответа", 20 | "Response Code":"HTTP код ответа", 21 | "Response Headers":"Заголовки ответа", 22 | "Hide Response":"Спрятать ответ", 23 | "Response Messages":"Что может прийти в ответ", 24 | "Try it out!":"Попробовать!", 25 | "Show/Hide":"Показать/Скрыть", 26 | "List Operations":"Операции кратко", 27 | "Expand Operations":"Операции подробно", 28 | "Raw":"В сыром виде", 29 | "can't parse JSON. Raw result":"Не удается распарсить ответ:", 30 | "Model Schema":"Структура", 31 | "Model":"Описание", 32 | "apply":"применить", 33 | "Username":"Имя пользователя", 34 | "Password":"Пароль", 35 | "Terms of service":"Условия использования", 36 | "Created by":"Разработано", 37 | "See more at":"Еще тут", 38 | "Contact the developer":"Связаться с разработчиком", 39 | "api version":"Версия API", 40 | "Response Content Type":"Content Type ответа", 41 | "fetching resource":"Получение ресурса", 42 | "fetching resource list":"Получение ресурсов", 43 | "Explore":"Поехали", 44 | "Show Swagger Petstore Example Apis":"Показать примеры АПИ", 45 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Не удается получить ответ от сервера. Возможно, какая-то лажа с настройками доступа", 46 | "Please specify the protocol for":"Пожалуйста, укажите протогол для", 47 | "Can't read swagger JSON from":"Не получается прочитать swagger json из", 48 | "Finished Loading Resource Information. Rendering Swagger UI":"Загрузка информации о ресурсах завершена. Рендерим", 49 | "Unable to read api":"Не удалось прочитать api", 50 | "from path":"по адресу", 51 | "server returned":"сервер сказал" 52 | }); 53 | -------------------------------------------------------------------------------- /dist/lang/ru.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Ворнинг: Депрекейтед", 6 | "Implementation Notes":"Заметки", 7 | "Response Class":"Пример ответа", 8 | "Status":"Статус", 9 | "Parameters":"Параметры", 10 | "Parameter":"Параметр", 11 | "Value":"Значение", 12 | "Description":"Описание", 13 | "Parameter Type":"Тип параметра", 14 | "Data Type":"Тип данных", 15 | "HTTP Status Code":"HTTP код", 16 | "Reason":"Причина", 17 | "Response Model":"Структура ответа", 18 | "Request URL":"URL запроса", 19 | "Response Body":"Тело ответа", 20 | "Response Code":"HTTP код ответа", 21 | "Response Headers":"Заголовки ответа", 22 | "Hide Response":"Спрятать ответ", 23 | "Response Messages":"Что может прийти в ответ", 24 | "Try it out!":"Попробовать!", 25 | "Show/Hide":"Показать/Скрыть", 26 | "List Operations":"Операции кратко", 27 | "Expand Operations":"Операции подробно", 28 | "Raw":"В сыром виде", 29 | "can't parse JSON. Raw result":"Не удается распарсить ответ:", 30 | "Model Schema":"Структура", 31 | "Model":"Описание", 32 | "apply":"применить", 33 | "Username":"Имя пользователя", 34 | "Password":"Пароль", 35 | "Terms of service":"Условия использования", 36 | "Created by":"Разработано", 37 | "See more at":"Еще тут", 38 | "Contact the developer":"Связаться с разработчиком", 39 | "api version":"Версия API", 40 | "Response Content Type":"Content Type ответа", 41 | "fetching resource":"Получение ресурса", 42 | "fetching resource list":"Получение ресурсов", 43 | "Explore":"Поехали", 44 | "Show Swagger Petstore Example Apis":"Показать примеры АПИ", 45 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Не удается получить ответ от сервера. Возможно, какая-то лажа с настройками доступа", 46 | "Please specify the protocol for":"Пожалуйста, укажите протогол для", 47 | "Can't read swagger JSON from":"Не получается прочитать swagger json из", 48 | "Finished Loading Resource Information. Rendering Swagger UI":"Загрузка информации о ресурсах завершена. Рендерим", 49 | "Unable to read api":"Не удалось прочитать api", 50 | "from path":"по адресу", 51 | "server returned":"сервер сказал" 52 | }); 53 | -------------------------------------------------------------------------------- /lang/en.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Warning: Deprecated", 6 | "Implementation Notes":"Implementation Notes", 7 | "Response Class":"Response Class", 8 | "Status":"Status", 9 | "Parameters":"Parameters", 10 | "Parameter":"Parameter", 11 | "Value":"Value", 12 | "Description":"Description", 13 | "Parameter Type":"Parameter Type", 14 | "Data Type":"Data Type", 15 | "Response Messages":"Response Messages", 16 | "HTTP Status Code":"HTTP Status Code", 17 | "Reason":"Reason", 18 | "Response Model":"Response Model", 19 | "Request URL":"Request URL", 20 | "Response Body":"Response Body", 21 | "Response Code":"Response Code", 22 | "Response Headers":"Response Headers", 23 | "Hide Response":"Hide Response", 24 | "Headers":"Headers", 25 | "Try it out!":"Try it out!", 26 | "Show/Hide":"Show/Hide", 27 | "List Operations":"List Operations", 28 | "Expand Operations":"Expand Operations", 29 | "Raw":"Raw", 30 | "can't parse JSON. Raw result":"can't parse JSON. Raw result", 31 | "Model Schema":"Model Schema", 32 | "Model":"Model", 33 | "apply":"apply", 34 | "Username":"Username", 35 | "Password":"Password", 36 | "Terms of service":"Terms of service", 37 | "Created by":"Created by", 38 | "See more at":"See more at", 39 | "Contact the developer":"Contact the developer", 40 | "api version":"api version", 41 | "Response Content Type":"Response Content Type", 42 | "fetching resource":"fetching resource", 43 | "fetching resource list":"fetching resource list", 44 | "Explore":"Explore", 45 | "Show Swagger Petstore Example Apis":"Show Swagger Petstore Example Apis", 46 | "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.", 47 | "Please specify the protocol for":"Please specify the protocol for", 48 | "Can't read swagger JSON from":"Can't read swagger JSON from", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"Finished Loading Resource Information. Rendering Swagger UI", 50 | "Unable to read api":"Unable to read api", 51 | "from path":"from path", 52 | "server returned":"server returned" 53 | }); 54 | -------------------------------------------------------------------------------- /dist/lang/en.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Warning: Deprecated", 6 | "Implementation Notes":"Implementation Notes", 7 | "Response Class":"Response Class", 8 | "Status":"Status", 9 | "Parameters":"Parameters", 10 | "Parameter":"Parameter", 11 | "Value":"Value", 12 | "Description":"Description", 13 | "Parameter Type":"Parameter Type", 14 | "Data Type":"Data Type", 15 | "Response Messages":"Response Messages", 16 | "HTTP Status Code":"HTTP Status Code", 17 | "Reason":"Reason", 18 | "Response Model":"Response Model", 19 | "Request URL":"Request URL", 20 | "Response Body":"Response Body", 21 | "Response Code":"Response Code", 22 | "Response Headers":"Response Headers", 23 | "Hide Response":"Hide Response", 24 | "Headers":"Headers", 25 | "Try it out!":"Try it out!", 26 | "Show/Hide":"Show/Hide", 27 | "List Operations":"List Operations", 28 | "Expand Operations":"Expand Operations", 29 | "Raw":"Raw", 30 | "can't parse JSON. Raw result":"can't parse JSON. Raw result", 31 | "Model Schema":"Model Schema", 32 | "Model":"Model", 33 | "apply":"apply", 34 | "Username":"Username", 35 | "Password":"Password", 36 | "Terms of service":"Terms of service", 37 | "Created by":"Created by", 38 | "See more at":"See more at", 39 | "Contact the developer":"Contact the developer", 40 | "api version":"api version", 41 | "Response Content Type":"Response Content Type", 42 | "fetching resource":"fetching resource", 43 | "fetching resource list":"fetching resource list", 44 | "Explore":"Explore", 45 | "Show Swagger Petstore Example Apis":"Show Swagger Petstore Example Apis", 46 | "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.", 47 | "Please specify the protocol for":"Please specify the protocol for", 48 | "Can't read swagger JSON from":"Can't read swagger JSON from", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"Finished Loading Resource Information. Rendering Swagger UI", 50 | "Unable to read api":"Unable to read api", 51 | "from path":"from path", 52 | "server returned":"server returned" 53 | }); 54 | -------------------------------------------------------------------------------- /lang/tr.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Uyarı: Deprecated", 6 | "Implementation Notes":"Gerçekleştirim Notları", 7 | "Response Class":"Dönen Sınıf", 8 | "Status":"Statü", 9 | "Parameters":"Parametreler", 10 | "Parameter":"Parametre", 11 | "Value":"Değer", 12 | "Description":"Açıklama", 13 | "Parameter Type":"Parametre Tipi", 14 | "Data Type":"Veri Tipi", 15 | "Response Messages":"Dönüş Mesajı", 16 | "HTTP Status Code":"HTTP Statü Kodu", 17 | "Reason":"Gerekçe", 18 | "Response Model":"Dönüş Modeli", 19 | "Request URL":"İstek URL", 20 | "Response Body":"Dönüş İçeriği", 21 | "Response Code":"Dönüş Kodu", 22 | "Response Headers":"Dönüş Üst Bilgileri", 23 | "Hide Response":"Dönüşü Gizle", 24 | "Headers":"Üst Bilgiler", 25 | "Try it out!":"Dene!", 26 | "Show/Hide":"Göster/Gizle", 27 | "List Operations":"Operasyonları Listele", 28 | "Expand Operations":"Operasyonları Aç", 29 | "Raw":"Ham", 30 | "can't parse JSON. Raw result":"JSON çözümlenemiyor. Ham sonuç", 31 | "Model Schema":"Model Şema", 32 | "Model":"Model", 33 | "apply":"uygula", 34 | "Username":"Kullanıcı Adı", 35 | "Password":"Parola", 36 | "Terms of service":"Servis şartları", 37 | "Created by":"Oluşturan", 38 | "See more at":"Daha fazlası için", 39 | "Contact the developer":"Geliştirici ile İletişime Geçin", 40 | "api version":"api versiyon", 41 | "Response Content Type":"Dönüş İçerik Tipi", 42 | "fetching resource":"kaynak getiriliyor", 43 | "fetching resource list":"kaynak listesi getiriliyor", 44 | "Explore":"Keşfet", 45 | "Show Swagger Petstore Example Apis":"Swagger Petstore Örnek Api'yi Gör", 46 | "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.", 47 | "Please specify the protocol for":"Lütfen istenen adres için protokol belirtiniz", 48 | "Can't read swagger JSON from":"Swagger JSON bu kaynaktan okunamıyor", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"Kaynak baglantısı tamamlandı. Swagger UI gösterime hazırlanıyor", 50 | "Unable to read api":"api okunamadı", 51 | "from path":"yoldan", 52 | "server returned":"sunucuya dönüldü" 53 | }); 54 | -------------------------------------------------------------------------------- /dist/lang/tr.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Uyarı: Deprecated", 6 | "Implementation Notes":"Gerçekleştirim Notları", 7 | "Response Class":"Dönen Sınıf", 8 | "Status":"Statü", 9 | "Parameters":"Parametreler", 10 | "Parameter":"Parametre", 11 | "Value":"Değer", 12 | "Description":"Açıklama", 13 | "Parameter Type":"Parametre Tipi", 14 | "Data Type":"Veri Tipi", 15 | "Response Messages":"Dönüş Mesajı", 16 | "HTTP Status Code":"HTTP Statü Kodu", 17 | "Reason":"Gerekçe", 18 | "Response Model":"Dönüş Modeli", 19 | "Request URL":"İstek URL", 20 | "Response Body":"Dönüş İçeriği", 21 | "Response Code":"Dönüş Kodu", 22 | "Response Headers":"Dönüş Üst Bilgileri", 23 | "Hide Response":"Dönüşü Gizle", 24 | "Headers":"Üst Bilgiler", 25 | "Try it out!":"Dene!", 26 | "Show/Hide":"Göster/Gizle", 27 | "List Operations":"Operasyonları Listele", 28 | "Expand Operations":"Operasyonları Aç", 29 | "Raw":"Ham", 30 | "can't parse JSON. Raw result":"JSON çözümlenemiyor. Ham sonuç", 31 | "Model Schema":"Model Şema", 32 | "Model":"Model", 33 | "apply":"uygula", 34 | "Username":"Kullanıcı Adı", 35 | "Password":"Parola", 36 | "Terms of service":"Servis şartları", 37 | "Created by":"Oluşturan", 38 | "See more at":"Daha fazlası için", 39 | "Contact the developer":"Geliştirici ile İletişime Geçin", 40 | "api version":"api versiyon", 41 | "Response Content Type":"Dönüş İçerik Tipi", 42 | "fetching resource":"kaynak getiriliyor", 43 | "fetching resource list":"kaynak listesi getiriliyor", 44 | "Explore":"Keşfet", 45 | "Show Swagger Petstore Example Apis":"Swagger Petstore Örnek Api'yi Gör", 46 | "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.", 47 | "Please specify the protocol for":"Lütfen istenen adres için protokol belirtiniz", 48 | "Can't read swagger JSON from":"Swagger JSON bu kaynaktan okunamıyor", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"Kaynak baglantısı tamamlandı. Swagger UI gösterime hazırlanıyor", 50 | "Unable to read api":"api okunamadı", 51 | "from path":"yoldan", 52 | "server returned":"sunucuya dönüldü" 53 | }); 54 | -------------------------------------------------------------------------------- /lang/pt.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Aviso: Depreciado", 6 | "Implementation Notes":"Notas de Implementação", 7 | "Response Class":"Classe de resposta", 8 | "Status":"Status", 9 | "Parameters":"Parâmetros", 10 | "Parameter":"Parâmetro", 11 | "Value":"Valor", 12 | "Description":"Descrição", 13 | "Parameter Type":"Tipo de parâmetro", 14 | "Data Type":"Tipo de dados", 15 | "Response Messages":"Mensagens de resposta", 16 | "HTTP Status Code":"Código de status HTTP", 17 | "Reason":"Razão", 18 | "Response Model":"Modelo resposta", 19 | "Request URL":"URL requisição", 20 | "Response Body":"Corpo da resposta", 21 | "Response Code":"Código da resposta", 22 | "Response Headers":"Cabeçalho da resposta", 23 | "Headers":"Cabeçalhos", 24 | "Hide Response":"Esconder resposta", 25 | "Try it out!":"Tente agora!", 26 | "Show/Hide":"Mostrar/Esconder", 27 | "List Operations":"Listar operações", 28 | "Expand Operations":"Expandir operações", 29 | "Raw":"Cru", 30 | "can't parse JSON. Raw result":"Falha ao analisar JSON. Resulto cru", 31 | "Model Schema":"Modelo esquema", 32 | "Model":"Modelo", 33 | "apply":"Aplicar", 34 | "Username":"Usuário", 35 | "Password":"Senha", 36 | "Terms of service":"Termos do serviço", 37 | "Created by":"Criado por", 38 | "See more at":"Veja mais em", 39 | "Contact the developer":"Contate o desenvolvedor", 40 | "api version":"Versão api", 41 | "Response Content Type":"Tipo de conteúdo da resposta", 42 | "fetching resource":"busca recurso", 43 | "fetching resource list":"buscando lista de recursos", 44 | "Explore":"Explorar", 45 | "Show Swagger Petstore Example Apis":"Show Swagger Petstore Example Apis", 46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Não é possível ler do servidor. Pode não ter as apropriadas configurações access-control-origin", 47 | "Please specify the protocol for":"Por favor especifique o protocolo", 48 | "Can't read swagger JSON from":"Não é possível ler o JSON Swagger de", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"Carregar informação de recurso finalizada. Renderizando Swagger UI", 50 | "Unable to read api":"Não foi possível ler api", 51 | "from path":"do caminho", 52 | "server returned":"servidor retornou" 53 | }); 54 | -------------------------------------------------------------------------------- /dist/lang/pt.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Aviso: Depreciado", 6 | "Implementation Notes":"Notas de Implementação", 7 | "Response Class":"Classe de resposta", 8 | "Status":"Status", 9 | "Parameters":"Parâmetros", 10 | "Parameter":"Parâmetro", 11 | "Value":"Valor", 12 | "Description":"Descrição", 13 | "Parameter Type":"Tipo de parâmetro", 14 | "Data Type":"Tipo de dados", 15 | "Response Messages":"Mensagens de resposta", 16 | "HTTP Status Code":"Código de status HTTP", 17 | "Reason":"Razão", 18 | "Response Model":"Modelo resposta", 19 | "Request URL":"URL requisição", 20 | "Response Body":"Corpo da resposta", 21 | "Response Code":"Código da resposta", 22 | "Response Headers":"Cabeçalho da resposta", 23 | "Headers":"Cabeçalhos", 24 | "Hide Response":"Esconder resposta", 25 | "Try it out!":"Tente agora!", 26 | "Show/Hide":"Mostrar/Esconder", 27 | "List Operations":"Listar operações", 28 | "Expand Operations":"Expandir operações", 29 | "Raw":"Cru", 30 | "can't parse JSON. Raw result":"Falha ao analisar JSON. Resulto cru", 31 | "Model Schema":"Modelo esquema", 32 | "Model":"Modelo", 33 | "apply":"Aplicar", 34 | "Username":"Usuário", 35 | "Password":"Senha", 36 | "Terms of service":"Termos do serviço", 37 | "Created by":"Criado por", 38 | "See more at":"Veja mais em", 39 | "Contact the developer":"Contate o desenvolvedor", 40 | "api version":"Versão api", 41 | "Response Content Type":"Tipo de conteúdo da resposta", 42 | "fetching resource":"busca recurso", 43 | "fetching resource list":"buscando lista de recursos", 44 | "Explore":"Explorar", 45 | "Show Swagger Petstore Example Apis":"Show Swagger Petstore Example Apis", 46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Não é possível ler do servidor. Pode não ter as apropriadas configurações access-control-origin", 47 | "Please specify the protocol for":"Por favor especifique o protocolo", 48 | "Can't read swagger JSON from":"Não é possível ler o JSON Swagger de", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"Carregar informação de recurso finalizada. Renderizando Swagger UI", 50 | "Unable to read api":"Não foi possível ler api", 51 | "from path":"do caminho", 52 | "server returned":"servidor retornou" 53 | }); 54 | -------------------------------------------------------------------------------- /lang/es.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Advertencia: Obsoleto", 6 | "Implementation Notes":"Notas de implementación", 7 | "Response Class":"Clase de la Respuesta", 8 | "Status":"Status", 9 | "Parameters":"Parámetros", 10 | "Parameter":"Parámetro", 11 | "Value":"Valor", 12 | "Description":"Descripción", 13 | "Parameter Type":"Tipo del Parámetro", 14 | "Data Type":"Tipo del Dato", 15 | "Response Messages":"Mensajes de la Respuesta", 16 | "HTTP Status Code":"Código de Status HTTP", 17 | "Reason":"Razón", 18 | "Response Model":"Modelo de la Respuesta", 19 | "Request URL":"URL de la Solicitud", 20 | "Response Body":"Cuerpo de la Respuesta", 21 | "Response Code":"Código de la Respuesta", 22 | "Response Headers":"Encabezados de la Respuesta", 23 | "Hide Response":"Ocultar Respuesta", 24 | "Try it out!":"Pruébalo!", 25 | "Show/Hide":"Mostrar/Ocultar", 26 | "List Operations":"Listar Operaciones", 27 | "Expand Operations":"Expandir Operaciones", 28 | "Raw":"Crudo", 29 | "can't parse JSON. Raw result":"no puede parsear el JSON. Resultado crudo", 30 | "Model Schema":"Esquema del Modelo", 31 | "Model":"Modelo", 32 | "apply":"aplicar", 33 | "Username":"Nombre de usuario", 34 | "Password":"Contraseña", 35 | "Terms of service":"Términos de Servicio", 36 | "Created by":"Creado por", 37 | "See more at":"Ver más en", 38 | "Contact the developer":"Contactar al desarrollador", 39 | "api version":"versión de la api", 40 | "Response Content Type":"Tipo de Contenido (Content Type) de la Respuesta", 41 | "fetching resource":"buscando recurso", 42 | "fetching resource list":"buscando lista del recurso", 43 | "Explore":"Explorar", 44 | "Show Swagger Petstore Example Apis":"Mostrar Api Ejemplo de Swagger Petstore", 45 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"No se puede leer del servidor. Tal vez no tiene la configuración de control de acceso de origen (access-control-origin) apropiado.", 46 | "Please specify the protocol for":"Por favor, especificar el protocola para", 47 | "Can't read swagger JSON from":"No se puede leer el JSON de swagger desde", 48 | "Finished Loading Resource Information. Rendering Swagger UI":"Finalizada la carga del recurso de Información. Mostrando Swagger UI", 49 | "Unable to read api":"No se puede leer la api", 50 | "from path":"desde ruta", 51 | "server returned":"el servidor retornó" 52 | }); 53 | -------------------------------------------------------------------------------- /dist/lang/es.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Advertencia: Obsoleto", 6 | "Implementation Notes":"Notas de implementación", 7 | "Response Class":"Clase de la Respuesta", 8 | "Status":"Status", 9 | "Parameters":"Parámetros", 10 | "Parameter":"Parámetro", 11 | "Value":"Valor", 12 | "Description":"Descripción", 13 | "Parameter Type":"Tipo del Parámetro", 14 | "Data Type":"Tipo del Dato", 15 | "Response Messages":"Mensajes de la Respuesta", 16 | "HTTP Status Code":"Código de Status HTTP", 17 | "Reason":"Razón", 18 | "Response Model":"Modelo de la Respuesta", 19 | "Request URL":"URL de la Solicitud", 20 | "Response Body":"Cuerpo de la Respuesta", 21 | "Response Code":"Código de la Respuesta", 22 | "Response Headers":"Encabezados de la Respuesta", 23 | "Hide Response":"Ocultar Respuesta", 24 | "Try it out!":"Pruébalo!", 25 | "Show/Hide":"Mostrar/Ocultar", 26 | "List Operations":"Listar Operaciones", 27 | "Expand Operations":"Expandir Operaciones", 28 | "Raw":"Crudo", 29 | "can't parse JSON. Raw result":"no puede parsear el JSON. Resultado crudo", 30 | "Model Schema":"Esquema del Modelo", 31 | "Model":"Modelo", 32 | "apply":"aplicar", 33 | "Username":"Nombre de usuario", 34 | "Password":"Contraseña", 35 | "Terms of service":"Términos de Servicio", 36 | "Created by":"Creado por", 37 | "See more at":"Ver más en", 38 | "Contact the developer":"Contactar al desarrollador", 39 | "api version":"versión de la api", 40 | "Response Content Type":"Tipo de Contenido (Content Type) de la Respuesta", 41 | "fetching resource":"buscando recurso", 42 | "fetching resource list":"buscando lista del recurso", 43 | "Explore":"Explorar", 44 | "Show Swagger Petstore Example Apis":"Mostrar Api Ejemplo de Swagger Petstore", 45 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"No se puede leer del servidor. Tal vez no tiene la configuración de control de acceso de origen (access-control-origin) apropiado.", 46 | "Please specify the protocol for":"Por favor, especificar el protocola para", 47 | "Can't read swagger JSON from":"No se puede leer el JSON de swagger desde", 48 | "Finished Loading Resource Information. Rendering Swagger UI":"Finalizada la carga del recurso de Información. Mostrando Swagger UI", 49 | "Unable to read api":"No se puede leer la api", 50 | "from path":"desde ruta", 51 | "server returned":"el servidor retornó" 52 | }); 53 | -------------------------------------------------------------------------------- /lang/fr.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Avertissement : Obsolète", 6 | "Implementation Notes":"Notes d'implementation", 7 | "Response Class":"Classe de la réponse", 8 | "Status":"Statut", 9 | "Parameters":"Paramètres", 10 | "Parameter":"Paramètre", 11 | "Value":"Valeur", 12 | "Description":"Description", 13 | "Parameter Type":"Type du paramètre", 14 | "Data Type":"Type de données", 15 | "Response Messages":"Messages de la réponse", 16 | "HTTP Status Code":"Code de statut HTTP", 17 | "Reason":"Raison", 18 | "Response Model":"Modèle de réponse", 19 | "Request URL":"URL appelée", 20 | "Response Body":"Corps de la réponse", 21 | "Response Code":"Code de la réponse", 22 | "Response Headers":"En-têtes de la réponse", 23 | "Hide Response":"Cacher la réponse", 24 | "Headers":"En-têtes", 25 | "Try it out!":"Testez !", 26 | "Show/Hide":"Afficher/Masquer", 27 | "List Operations":"Liste des opérations", 28 | "Expand Operations":"Développer les opérations", 29 | "Raw":"Brut", 30 | "can't parse JSON. Raw result":"impossible de décoder le JSON. Résultat brut", 31 | "Model Schema":"Définition du modèle", 32 | "Model":"Modèle", 33 | "apply":"appliquer", 34 | "Username":"Nom d'utilisateur", 35 | "Password":"Mot de passe", 36 | "Terms of service":"Conditions de service", 37 | "Created by":"Créé par", 38 | "See more at":"Voir plus sur", 39 | "Contact the developer":"Contacter le développeur", 40 | "api version":"version de l'api", 41 | "Response Content Type":"Content Type de la réponse", 42 | "fetching resource":"récupération de la ressource", 43 | "fetching resource list":"récupération de la liste de ressources", 44 | "Explore":"Explorer", 45 | "Show Swagger Petstore Example Apis":"Montrer les Apis de l'exemple Petstore de Swagger", 46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Impossible de lire à partir du serveur. Il se peut que les réglages access-control-origin ne soient pas appropriés.", 47 | "Please specify the protocol for":"Veuillez spécifier un protocole pour", 48 | "Can't read swagger JSON from":"Impossible de lire le JSON swagger à partir de", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"Chargement des informations terminé. Affichage de Swagger UI", 50 | "Unable to read api":"Impossible de lire l'api", 51 | "from path":"à partir du chemin", 52 | "server returned":"réponse du serveur" 53 | }); 54 | -------------------------------------------------------------------------------- /dist/lang/fr.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Avertissement : Obsolète", 6 | "Implementation Notes":"Notes d'implementation", 7 | "Response Class":"Classe de la réponse", 8 | "Status":"Statut", 9 | "Parameters":"Paramètres", 10 | "Parameter":"Paramètre", 11 | "Value":"Valeur", 12 | "Description":"Description", 13 | "Parameter Type":"Type du paramètre", 14 | "Data Type":"Type de données", 15 | "Response Messages":"Messages de la réponse", 16 | "HTTP Status Code":"Code de statut HTTP", 17 | "Reason":"Raison", 18 | "Response Model":"Modèle de réponse", 19 | "Request URL":"URL appelée", 20 | "Response Body":"Corps de la réponse", 21 | "Response Code":"Code de la réponse", 22 | "Response Headers":"En-têtes de la réponse", 23 | "Hide Response":"Cacher la réponse", 24 | "Headers":"En-têtes", 25 | "Try it out!":"Testez !", 26 | "Show/Hide":"Afficher/Masquer", 27 | "List Operations":"Liste des opérations", 28 | "Expand Operations":"Développer les opérations", 29 | "Raw":"Brut", 30 | "can't parse JSON. Raw result":"impossible de décoder le JSON. Résultat brut", 31 | "Model Schema":"Définition du modèle", 32 | "Model":"Modèle", 33 | "apply":"appliquer", 34 | "Username":"Nom d'utilisateur", 35 | "Password":"Mot de passe", 36 | "Terms of service":"Conditions de service", 37 | "Created by":"Créé par", 38 | "See more at":"Voir plus sur", 39 | "Contact the developer":"Contacter le développeur", 40 | "api version":"version de l'api", 41 | "Response Content Type":"Content Type de la réponse", 42 | "fetching resource":"récupération de la ressource", 43 | "fetching resource list":"récupération de la liste de ressources", 44 | "Explore":"Explorer", 45 | "Show Swagger Petstore Example Apis":"Montrer les Apis de l'exemple Petstore de Swagger", 46 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Impossible de lire à partir du serveur. Il se peut que les réglages access-control-origin ne soient pas appropriés.", 47 | "Please specify the protocol for":"Veuillez spécifier un protocole pour", 48 | "Can't read swagger JSON from":"Impossible de lire le JSON swagger à partir de", 49 | "Finished Loading Resource Information. Rendering Swagger UI":"Chargement des informations terminé. Affichage de Swagger UI", 50 | "Unable to read api":"Impossible de lire l'api", 51 | "from path":"à partir du chemin", 52 | "server returned":"réponse du serveur" 53 | }); 54 | -------------------------------------------------------------------------------- /lang/it.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Attenzione: Deprecato", 6 | "Implementation Notes":"Note di implementazione", 7 | "Response Class":"Classe della risposta", 8 | "Status":"Stato", 9 | "Parameters":"Parametri", 10 | "Parameter":"Parametro", 11 | "Value":"Valore", 12 | "Description":"Descrizione", 13 | "Parameter Type":"Tipo di parametro", 14 | "Data Type":"Tipo di dato", 15 | "Response Messages":"Messaggi della risposta", 16 | "HTTP Status Code":"Codice stato HTTP", 17 | "Reason":"Motivo", 18 | "Response Model":"Modello di risposta", 19 | "Request URL":"URL della richiesta", 20 | "Response Body":"Corpo della risposta", 21 | "Response Code":"Oggetto della risposta", 22 | "Response Headers":"Intestazioni della risposta", 23 | "Hide Response":"Nascondi risposta", 24 | "Try it out!":"Provalo!", 25 | "Show/Hide":"Mostra/Nascondi", 26 | "List Operations":"Mostra operazioni", 27 | "Expand Operations":"Espandi operazioni", 28 | "Raw":"Grezzo (raw)", 29 | "can't parse JSON. Raw result":"non è possibile parsare il JSON. Risultato grezzo (raw).", 30 | "Model Schema":"Schema del modello", 31 | "Model":"Modello", 32 | "apply":"applica", 33 | "Username":"Nome utente", 34 | "Password":"Password", 35 | "Terms of service":"Condizioni del servizio", 36 | "Created by":"Creato da", 37 | "See more at":"Informazioni aggiuntive:", 38 | "Contact the developer":"Contatta lo sviluppatore", 39 | "api version":"versione api", 40 | "Response Content Type":"Tipo di contenuto (content type) della risposta", 41 | "fetching resource":"recuperando la risorsa", 42 | "fetching resource list":"recuperando lista risorse", 43 | "Explore":"Esplora", 44 | "Show Swagger Petstore Example Apis":"Mostra le api di esempio di Swagger Petstore", 45 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Non è possibile leggere dal server. Potrebbe non avere le impostazioni di controllo accesso origine (access-control-origin) appropriate.", 46 | "Please specify the protocol for":"Si prega di specificare il protocollo per", 47 | "Can't read swagger JSON from":"Impossibile leggere JSON swagger da:", 48 | "Finished Loading Resource Information. Rendering Swagger UI":"Lettura informazioni risorse termianta. Swagger UI viene mostrata", 49 | "Unable to read api":"Impossibile leggere la api", 50 | "from path":"da cartella", 51 | "server returned":"il server ha restituito" 52 | }); 53 | -------------------------------------------------------------------------------- /dist/lang/it.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | /* jshint quotmark: double */ 4 | window.SwaggerTranslator.learn({ 5 | "Warning: Deprecated":"Attenzione: Deprecato", 6 | "Implementation Notes":"Note di implementazione", 7 | "Response Class":"Classe della risposta", 8 | "Status":"Stato", 9 | "Parameters":"Parametri", 10 | "Parameter":"Parametro", 11 | "Value":"Valore", 12 | "Description":"Descrizione", 13 | "Parameter Type":"Tipo di parametro", 14 | "Data Type":"Tipo di dato", 15 | "Response Messages":"Messaggi della risposta", 16 | "HTTP Status Code":"Codice stato HTTP", 17 | "Reason":"Motivo", 18 | "Response Model":"Modello di risposta", 19 | "Request URL":"URL della richiesta", 20 | "Response Body":"Corpo della risposta", 21 | "Response Code":"Oggetto della risposta", 22 | "Response Headers":"Intestazioni della risposta", 23 | "Hide Response":"Nascondi risposta", 24 | "Try it out!":"Provalo!", 25 | "Show/Hide":"Mostra/Nascondi", 26 | "List Operations":"Mostra operazioni", 27 | "Expand Operations":"Espandi operazioni", 28 | "Raw":"Grezzo (raw)", 29 | "can't parse JSON. Raw result":"non è possibile parsare il JSON. Risultato grezzo (raw).", 30 | "Model Schema":"Schema del modello", 31 | "Model":"Modello", 32 | "apply":"applica", 33 | "Username":"Nome utente", 34 | "Password":"Password", 35 | "Terms of service":"Condizioni del servizio", 36 | "Created by":"Creato da", 37 | "See more at":"Informazioni aggiuntive:", 38 | "Contact the developer":"Contatta lo sviluppatore", 39 | "api version":"versione api", 40 | "Response Content Type":"Tipo di contenuto (content type) della risposta", 41 | "fetching resource":"recuperando la risorsa", 42 | "fetching resource list":"recuperando lista risorse", 43 | "Explore":"Esplora", 44 | "Show Swagger Petstore Example Apis":"Mostra le api di esempio di Swagger Petstore", 45 | "Can't read from server. It may not have the appropriate access-control-origin settings.":"Non è possibile leggere dal server. Potrebbe non avere le impostazioni di controllo accesso origine (access-control-origin) appropriate.", 46 | "Please specify the protocol for":"Si prega di specificare il protocollo per", 47 | "Can't read swagger JSON from":"Impossibile leggere JSON swagger da:", 48 | "Finished Loading Resource Information. Rendering Swagger UI":"Lettura informazioni risorse termianta. Swagger UI viene mostrata", 49 | "Unable to read api":"Impossibile leggere la api", 50 | "from path":"da cartella", 51 | "server returned":"il server ha restituito" 52 | }); 53 | -------------------------------------------------------------------------------- /src/main/less/highlight_default.less: -------------------------------------------------------------------------------- 1 | /* Original style from softwaremaniacs.org (c) Ivan Sagalaev */ 2 | 3 | .swagger-section { 4 | 5 | pre code { 6 | display: block; padding: 0.5em; 7 | background: #F0F0F0; 8 | } 9 | 10 | pre code, 11 | pre .subst, 12 | pre .tag .title, 13 | pre .lisp .title, 14 | pre .clojure .built_in, 15 | pre .nginx .title { 16 | color: black; 17 | } 18 | 19 | pre .string, 20 | pre .title, 21 | pre .constant, 22 | pre .parent, 23 | pre .tag .value, 24 | pre .rules .value, 25 | pre .rules .value .number, 26 | pre .preprocessor, 27 | pre .ruby .symbol, 28 | pre .ruby .symbol .string, 29 | pre .aggregate, 30 | pre .template_tag, 31 | pre .django .variable, 32 | pre .smalltalk .class, 33 | pre .addition, 34 | pre .flow, 35 | pre .stream, 36 | pre .bash .variable, 37 | pre .apache .tag, 38 | pre .apache .cbracket, 39 | pre .tex .command, 40 | pre .tex .special, 41 | pre .erlang_repl .function_or_atom, 42 | pre .markdown .header { 43 | color: #800; 44 | } 45 | 46 | pre .comment, 47 | pre .annotation, 48 | pre .template_comment, 49 | pre .diff .header, 50 | pre .chunk, 51 | pre .markdown .blockquote { 52 | color: #888; 53 | } 54 | 55 | pre .number, 56 | pre .date, 57 | pre .regexp, 58 | pre .literal, 59 | pre .smalltalk .symbol, 60 | pre .smalltalk .char, 61 | pre .go .constant, 62 | pre .change, 63 | pre .markdown .bullet, 64 | pre .markdown .link_url { 65 | color: #080; 66 | } 67 | 68 | pre .label, 69 | pre .javadoc, 70 | pre .ruby .string, 71 | pre .decorator, 72 | pre .filter .argument, 73 | pre .localvars, 74 | pre .array, 75 | pre .attr_selector, 76 | pre .important, 77 | pre .pseudo, 78 | pre .pi, 79 | pre .doctype, 80 | pre .deletion, 81 | pre .envvar, 82 | pre .shebang, 83 | pre .apache .sqbracket, 84 | pre .nginx .built_in, 85 | pre .tex .formula, 86 | pre .erlang_repl .reserved, 87 | pre .prompt, 88 | pre .markdown .link_label, 89 | pre .vhdl .attribute, 90 | pre .clojure .attribute, 91 | pre .coffeescript .property { 92 | color: #88F 93 | } 94 | 95 | pre .keyword, 96 | pre .id, 97 | pre .phpdoc, 98 | pre .title, 99 | pre .built_in, 100 | pre .aggregate, 101 | pre .css .tag, 102 | pre .javadoctag, 103 | pre .phpdoc, 104 | pre .yardoctag, 105 | pre .smalltalk .class, 106 | pre .winutils, 107 | pre .bash .variable, 108 | pre .apache .tag, 109 | pre .go .typename, 110 | pre .tex .command, 111 | pre .markdown .strong, 112 | pre .request, 113 | pre .status { 114 | font-weight: bold; 115 | } 116 | 117 | pre .markdown .emphasis { 118 | font-style: italic; 119 | } 120 | 121 | pre .nginx .built_in { 122 | font-weight: normal; 123 | } 124 | 125 | pre .coffeescript .javascript, 126 | pre .javascript .xml, 127 | pre .tex .formula, 128 | pre .xml .javascript, 129 | pre .xml .vbscript, 130 | pre .xml .css, 131 | pre .xml .cdata { 132 | opacity: 0.5; 133 | } 134 | 135 | } 136 | -------------------------------------------------------------------------------- /test/e2e/v1.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var expect = require('chai').expect; 4 | var driver = require('./driver'); 5 | var servers = require('./servers'); 6 | var webdriver = require('selenium-webdriver'); 7 | var until = webdriver.until; 8 | 9 | var elements = [ 10 | 'swagger-ui-container', 11 | 'resources_container', 12 | 'api_info', 13 | 'resource_pet', 14 | 'resource_store', 15 | 'resource_user', 16 | 'header' 17 | ]; 18 | 19 | describe('swagger 1.x spec tests', function () { 20 | this.timeout(10 * 1000); 21 | 22 | before(function (done) { 23 | this.timeout(25 * 1000); 24 | servers.start('/v1.2/petstore/api-docs.json', done); 25 | }); 26 | 27 | afterEach(function(){ 28 | it('should not have any console errors', function (done) { 29 | driver.manage().logs().get('browser').then(function(browserLogs) { 30 | var errors = []; 31 | browserLogs.forEach(function(log){ 32 | // 900 and above is "error" level. Console should not have any errors 33 | if (log.level.value > 900) { 34 | console.log('browser error message:', log.message); errors.push(log); 35 | } 36 | }); 37 | expect(errors).to.be.empty; 38 | done(); 39 | }); 40 | }); 41 | }); 42 | 43 | it('should have "Swagger UI" in title', function () { 44 | return driver.wait(until.titleIs('Swagger UI'), 1000); 45 | }); 46 | 47 | elements.forEach(function (id) { 48 | it('should render element: ' + id, function (done) { 49 | var locator = webdriver.By.id(id); 50 | driver.isElementPresent(locator).then(function (isPresent) { 51 | expect(isPresent).to.be.true; 52 | done(); 53 | }); 54 | }); 55 | }); 56 | 57 | // TODO: enable me 58 | xit('should find the contact name element', function(done){ 59 | var locator = webdriver.By.css('.info_name'); 60 | driver.isElementPresent(locator).then(function (isPresent) { 61 | expect(isPresent).to.be.true; 62 | done(); 63 | }); 64 | }); 65 | 66 | it('should find the pet link', function(done){ 67 | var locator = webdriver.By.xpath('//*[@data-id="pet"]'); 68 | driver.isElementPresent(locator).then(function (isPresent) { 69 | expect(isPresent).to.be.true; 70 | done(); 71 | }); 72 | }); 73 | 74 | // TODO: enable me 75 | xit('should find the pet resource description', function(done){ 76 | var locator = webdriver.By.xpath('//div[contains(., "Operations about pets")]'); 77 | driver.findElements(locator).then(function (elements) { 78 | expect(elements.length).to.not.equal(0); 79 | done(); 80 | }); 81 | }); 82 | 83 | it('should find the user link', function(done){ 84 | var locator = webdriver.By.xpath('//*[@data-id="user"]'); 85 | driver.isElementPresent(locator).then(function (isPresent) { 86 | expect(isPresent).to.be.true; 87 | done(); 88 | }); 89 | }); 90 | 91 | it('should find the store link', function(done){ 92 | var locator = webdriver.By.xpath('//*[@data-id="store"]'); 93 | driver.isElementPresent(locator).then(function (isPresent) { 94 | expect(isPresent).to.be.true; 95 | done(); 96 | }); 97 | }); 98 | 99 | after(function(done){ 100 | servers.close(); 101 | done(); 102 | }); 103 | }); 104 | -------------------------------------------------------------------------------- /src/main/javascript/view/ParameterView.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | SwaggerUi.Views.ParameterView = Backbone.View.extend({ 4 | initialize: function(){ 5 | Handlebars.registerHelper('isArray', function(param, opts) { 6 | if (param.type.toLowerCase() === 'array' || param.allowMultiple) { 7 | return opts.fn(this); 8 | } else { 9 | return opts.inverse(this); 10 | } 11 | }); 12 | }, 13 | 14 | render: function() { 15 | var type = this.model.type || this.model.dataType; 16 | 17 | if (typeof type === 'undefined') { 18 | var schema = this.model.schema; 19 | if (schema && schema.$ref) { 20 | var ref = schema.$ref; 21 | if (ref.indexOf('#/definitions/') === 0) { 22 | type = ref.substring('#/definitions/'.length); 23 | } else { 24 | type = ref; 25 | } 26 | } 27 | } 28 | 29 | this.model.type = type; 30 | this.model.paramType = this.model.in || this.model.paramType; 31 | this.model.isBody = this.model.paramType === 'body' || this.model.in === 'body'; 32 | this.model.isFile = type && type.toLowerCase() === 'file'; 33 | 34 | // Allow for default === false 35 | if(typeof this.model.default === 'undefined') { 36 | this.model.default = this.model.defaultValue; 37 | } 38 | 39 | this.model.hasDefault = (typeof this.model.default !== 'undefined'); 40 | this.model.valueId = 'm' + this.model.name + Math.random(); 41 | 42 | if (this.model.allowableValues) { 43 | this.model.isList = true; 44 | } 45 | 46 | var template = this.template(); 47 | $(this.el).html(template(this.model)); 48 | 49 | var signatureModel = { 50 | sampleJSON: this.model.sampleJSON, 51 | isParam: true, 52 | signature: this.model.signature 53 | }; 54 | 55 | if (this.model.sampleJSON) { 56 | var signatureView = new SwaggerUi.Views.SignatureView({model: signatureModel, tagName: 'div'}); 57 | $('.model-signature', $(this.el)).append(signatureView.render().el); 58 | } 59 | else { 60 | $('.model-signature', $(this.el)).html(this.model.signature); 61 | } 62 | 63 | var isParam = false; 64 | 65 | if (this.model.isBody) { 66 | isParam = true; 67 | } 68 | 69 | var contentTypeModel = { 70 | isParam: isParam 71 | }; 72 | 73 | contentTypeModel.consumes = this.model.consumes; 74 | 75 | if (isParam) { 76 | var parameterContentTypeView = new SwaggerUi.Views.ParameterContentTypeView({model: contentTypeModel}); 77 | $('.parameter-content-type', $(this.el)).append(parameterContentTypeView.render().el); 78 | } 79 | 80 | else { 81 | var responseContentTypeView = new SwaggerUi.Views.ResponseContentTypeView({model: contentTypeModel}); 82 | $('.response-content-type', $(this.el)).append(responseContentTypeView.render().el); 83 | } 84 | 85 | return this; 86 | }, 87 | 88 | // Return an appropriate template based on if the parameter is a list, readonly, required 89 | template: function(){ 90 | if (this.model.isList) { 91 | return Handlebars.templates.param_list; 92 | } else { 93 | if (this.options.readOnly) { 94 | if (this.model.required) { 95 | return Handlebars.templates.param_readonly_required; 96 | } else { 97 | return Handlebars.templates.param_readonly; 98 | } 99 | } else { 100 | if (this.model.required) { 101 | return Handlebars.templates.param_required; 102 | } else { 103 | return Handlebars.templates.param; 104 | } 105 | } 106 | } 107 | } 108 | }); 109 | -------------------------------------------------------------------------------- /test/e2e/v2.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var expect = require('chai').expect; 4 | var webdriver = require('selenium-webdriver'); 5 | var driver = require('./driver'); 6 | var servers = require('./servers'); 7 | var until = webdriver.until; 8 | 9 | var elements = [ 10 | 'swagger-ui-container', 11 | 'resources_container', 12 | 'api_info', 13 | 'resource_pet', 14 | 'resource_store', 15 | 'resource_user', 16 | 'header' 17 | ]; 18 | 19 | describe('swagger 2.0 spec tests', function () { 20 | this.timeout(40 * 1000); 21 | 22 | before(function (done) { 23 | this.timeout(50 * 1000); 24 | servers.start('/v2/petstore.json', done); 25 | }); 26 | 27 | afterEach(function(){ 28 | it('should not have any console errors', function (done) { 29 | driver.manage().logs().get('browser').then(function(browserLogs) { 30 | var errors = []; 31 | browserLogs.forEach(function(log){ 32 | // 900 and above is "error" level. Console should not have any errors 33 | if (log.level.value > 900) { 34 | console.log('browser error message:', log.message); errors.push(log); 35 | } 36 | }); 37 | expect(errors).to.be.empty; 38 | done(); 39 | }); 40 | }); 41 | }); 42 | 43 | it('should have "Swagger UI" in title', function () { 44 | return driver.wait(until.titleIs('Swagger UI'), 1000); 45 | }); 46 | 47 | elements.forEach(function (id) { 48 | it('should render element: ' + id, function (done) { 49 | var locator = webdriver.By.id(id); 50 | driver.isElementPresent(locator).then(function (isPresent) { 51 | expect(isPresent).to.be.true; 52 | done(); 53 | }); 54 | }); 55 | }); 56 | 57 | it('should find the contact name element', function(done){ 58 | var locator = webdriver.By.css('.info_name'); 59 | driver.isElementPresent(locator).then(function (isPresent) { 60 | expect(isPresent).to.be.true; 61 | done(); 62 | }); 63 | }); 64 | 65 | it('should find the contact email element', function(done){ 66 | var locator = webdriver.By.css('.info_email'); 67 | driver.isElementPresent(locator).then(function (isPresent) { 68 | expect(isPresent).to.be.true; 69 | done(); 70 | }); 71 | }); 72 | 73 | it('should find the contact url element', function(done){ 74 | var locator = webdriver.By.css('.info_url'); 75 | driver.isElementPresent(locator).then(function (isPresent) { 76 | expect(isPresent).to.be.true; 77 | done(); 78 | }); 79 | }); 80 | 81 | it('should find the pet link', function(done){ 82 | var locator = webdriver.By.xpath('//*[@data-id="pet"]'); 83 | driver.isElementPresent(locator).then(function (isPresent) { 84 | expect(isPresent).to.be.true; 85 | done(); 86 | }); 87 | }); 88 | 89 | it('should find the pet resource description', function(done){ 90 | var locator = webdriver.By.xpath('//div[contains(., "Everything about your Pets")]'); 91 | driver.findElements(locator).then(function (elements) { 92 | expect(elements.length).to.not.equal(0); 93 | done(); 94 | }); 95 | }); 96 | 97 | it('should find the user link', function(done){ 98 | var locator = webdriver.By.xpath('//*[@data-id="user"]'); 99 | driver.isElementPresent(locator).then(function (isPresent) { 100 | expect(isPresent).to.be.true; 101 | done(); 102 | }); 103 | }); 104 | 105 | it('should find the store link', function(done){ 106 | var locator = webdriver.By.xpath('//*[@data-id="store"]'); 107 | driver.isElementPresent(locator).then(function (isPresent) { 108 | expect(isPresent).to.be.true; 109 | done(); 110 | }); 111 | }); 112 | 113 | after(function(done) { 114 | servers.close(); 115 | done(); 116 | }); 117 | }); 118 | -------------------------------------------------------------------------------- /src/main/less/screen.less: -------------------------------------------------------------------------------- 1 | @import 'src/main/less/highlight_default.less'; 2 | @import 'src/main/less/specs.less'; 3 | @import 'src/main/less/auth.less'; 4 | 5 | .swagger-section { 6 | 7 | .access { 8 | float: right; 9 | } 10 | 11 | .auth { 12 | float: right; 13 | } 14 | 15 | .api-ic { 16 | height: 18px; 17 | vertical-align: middle; 18 | display: inline-block; 19 | background: url(../images/explorer_icons.png) no-repeat; 20 | .api_information_panel { 21 | position: relative; 22 | margin-top: 20px; 23 | margin-left: -5px; 24 | background: #FFF; 25 | border: 1px solid #ccc; 26 | border-radius: 5px; 27 | display: none; 28 | font-size: 13px; 29 | max-width: 300px; 30 | line-height: 30px; 31 | color: black; 32 | padding: 5px; 33 | p { 34 | .api-msg-enabled { 35 | color: green; 36 | } 37 | .api-msg-disabled { 38 | color: red; 39 | } 40 | } 41 | } 42 | } 43 | 44 | .api-ic:hover { 45 | .api_information_panel { 46 | position: absolute; 47 | display: block; 48 | } 49 | } 50 | 51 | .ic-info { 52 | background-position: 0 0; 53 | width: 18px; 54 | margin-top: -6px; 55 | margin-left: 4px; 56 | } 57 | .ic-warning { 58 | background-position: -60px 0; 59 | width: 18px; 60 | margin-top: -6px; 61 | margin-left: 4px; 62 | } 63 | .ic-error { 64 | background-position: -30px 0; 65 | width: 18px; 66 | margin-top: -6px; 67 | margin-left: 4px; 68 | } 69 | .ic-off { 70 | background-position: -90px 0; 71 | width: 58px; 72 | margin-top: -4px; 73 | cursor: pointer; 74 | } 75 | .ic-on { 76 | background-position: -160px 0; 77 | width: 58px; 78 | margin-top: -4px; 79 | cursor: pointer; 80 | } 81 | 82 | #header { 83 | background-color: #89bf04; 84 | padding: 14px; 85 | a#logo { 86 | font-size: 1.5em; 87 | font-weight: bold; 88 | text-decoration: none; 89 | background: transparent url(../images/logo_small.png) no-repeat left center; 90 | padding: 20px 0 20px 40px; 91 | color: white; 92 | } 93 | form#api_selector { 94 | display: block; 95 | clear: none; 96 | float: right; 97 | .input { 98 | display: block; 99 | clear: none; 100 | float: left; 101 | margin: 0 10px 0 0; 102 | input#input_apiKey { 103 | width: 200px; 104 | } 105 | input#input_baseUrl { 106 | width: 400px; 107 | } 108 | a#explore { 109 | display: block; 110 | text-decoration: none; 111 | font-weight: bold; 112 | padding: 6px 8px; 113 | font-size: 0.9em; 114 | color: white; 115 | background-color: #547f00; 116 | -moz-border-radius: 4px; 117 | -webkit-border-radius: 4px; 118 | -o-border-radius: 4px; 119 | -ms-border-radius: 4px; 120 | -khtml-border-radius: 4px; 121 | border-radius: 4px; 122 | } 123 | a#explore:hover { 124 | background-color: #547f00; 125 | } 126 | input { 127 | font-size: 0.9em; 128 | padding: 3px; 129 | margin: 0; 130 | } 131 | } 132 | } 133 | } 134 | 135 | #content_message { 136 | margin: 10px 15px; 137 | font-style: italic; 138 | color: #999999; 139 | } 140 | 141 | #message-bar { 142 | min-height: 30px; 143 | text-align: center; 144 | padding-top: 10px; 145 | } 146 | 147 | } 148 | -------------------------------------------------------------------------------- /lib/jquery.ba-bbq.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010 3 | * http://benalman.com/projects/jquery-bbq-plugin/ 4 | * 5 | * Copyright (c) 2010 "Cowboy" Ben Alman 6 | * Dual licensed under the MIT and GPL licenses. 7 | * http://benalman.com/about/license/ 8 | */ 9 | (function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this); -------------------------------------------------------------------------------- /dist/lib/jquery.ba-bbq.min.js: -------------------------------------------------------------------------------- 1 | /* 2 | * jQuery BBQ: Back Button & Query Library - v1.2.1 - 2/17/2010 3 | * http://benalman.com/projects/jquery-bbq-plugin/ 4 | * 5 | * Copyright (c) 2010 "Cowboy" Ben Alman 6 | * Dual licensed under the MIT and GPL licenses. 7 | * http://benalman.com/about/license/ 8 | */ 9 | (function($,p){var i,m=Array.prototype.slice,r=decodeURIComponent,a=$.param,c,l,v,b=$.bbq=$.bbq||{},q,u,j,e=$.event.special,d="hashchange",A="querystring",D="fragment",y="elemUrlAttr",g="location",k="href",t="src",x=/^.*\?|#.*$/g,w=/^.*\#/,h,C={};function E(F){return typeof F==="string"}function B(G){var F=m.call(arguments,1);return function(){return G.apply(this,F.concat(m.call(arguments)))}}function n(F){return F.replace(/^[^#]*#?(.*)$/,"$1")}function o(F){return F.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(H,M,F,I,G){var O,L,K,N,J;if(I!==i){K=F.match(H?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);J=K[3]||"";if(G===2&&E(I)){L=I.replace(H?w:x,"")}else{N=l(K[2]);I=E(I)?l[H?D:A](I):I;L=G===2?I:G===1?$.extend({},I,N):$.extend({},N,I);L=a(L);if(H){L=L.replace(h,r)}}O=K[1]+(H?"#":L||!K[1]?"?":"")+L+J}else{O=M(F!==i?F:p[g][k])}return O}a[A]=B(f,0,o);a[D]=c=B(f,1,n);c.noEscape=function(G){G=G||"";var F=$.map(G.split(""),encodeURIComponent);h=new RegExp(F.join("|"),"g")};c.noEscape(",/");$.deparam=l=function(I,F){var H={},G={"true":!0,"false":!1,"null":null};$.each(I.replace(/\+/g," ").split("&"),function(L,Q){var K=Q.split("="),P=r(K[0]),J,O=H,M=0,R=P.split("]["),N=R.length-1;if(/\[/.test(R[0])&&/\]$/.test(R[N])){R[N]=R[N].replace(/\]$/,"");R=R.shift().split("[").concat(R);N=R.length-1}else{N=0}if(K.length===2){J=r(K[1]);if(F){J=J&&!isNaN(J)?+J:J==="undefined"?i:G[J]!==i?G[J]:J}if(N){for(;M<=N;M++){P=R[M]===""?O.length:R[M];O=O[P]=M').hide().insertAfter("body")[0].contentWindow;q=function(){return a(n.document[c][l])};o=function(u,s){if(u!==s){var t=n.document;t.open().close();t[c].hash="#"+u}};o(a())}}m.start=function(){if(r){return}var t=a();o||p();(function s(){var v=a(),u=q(t);if(v!==t){o(t=v,u);$(i).trigger(d)}else{if(u!==t){i[c][l]=i[c][l].replace(/#.*/,"")+"#"+u}}r=setTimeout(s,$[d+"Delay"])})()};m.stop=function(){if(!n){r&&clearTimeout(r);r=0}};return m})()})(jQuery,this); -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var gulp = require('gulp'); 4 | var es = require('event-stream'); 5 | var clean = require('gulp-clean'); 6 | var concat = require('gulp-concat'); 7 | var uglify = require('gulp-uglify'); 8 | var rename = require('gulp-rename'); 9 | var less = require('gulp-less'); 10 | var handlebars = require('gulp-handlebars'); 11 | var wrap = require('gulp-wrap'); 12 | var declare = require('gulp-declare'); 13 | var watch = require('gulp-watch'); 14 | var connect = require('gulp-connect'); 15 | var header = require('gulp-header'); 16 | var pkg = require('./package.json'); 17 | var order = require('gulp-order'); 18 | var jshint = require('gulp-jshint'); 19 | var banner = ['/**', 20 | ' * <%= pkg.name %> - <%= pkg.description %>', 21 | ' * @version v<%= pkg.version %>', 22 | ' * @link <%= pkg.homepage %>', 23 | ' * @license <%= pkg.license %>', 24 | ' */', 25 | ''].join('\n'); 26 | 27 | /** 28 | * Clean ups ./dist folder 29 | */ 30 | gulp.task('clean', function() { 31 | return gulp 32 | .src('./dist', {read: false}) 33 | .pipe(clean({force: true})) 34 | .on('error', log); 35 | }); 36 | 37 | /** 38 | * Processes Handlebars templates 39 | */ 40 | function templates() { 41 | return gulp 42 | .src(['./src/main/template/**/*']) 43 | .pipe(handlebars()) 44 | .pipe(wrap('Handlebars.template(<%= contents %>)')) 45 | .pipe(declare({ 46 | namespace: 'Handlebars.templates', 47 | noRedeclare: true, // Avoid duplicate declarations 48 | })) 49 | .on('error', log); 50 | } 51 | 52 | /** 53 | * JShint all *.js files 54 | */ 55 | gulp.task('lint', function () { 56 | return gulp.src('./src/main/javascript/**/*.js') 57 | .pipe(jshint()) 58 | .pipe(jshint.reporter('jshint-stylish')); 59 | }); 60 | 61 | /** 62 | * Build a distribution 63 | */ 64 | gulp.task('dist', ['clean','lint'], function() { 65 | 66 | return es.merge( 67 | gulp.src([ 68 | './src/main/javascript/**/*.js', 69 | './node_modules/swagger-client/browser/swagger-client.js' 70 | ]), 71 | templates() 72 | ) 73 | .pipe(order(['scripts.js', 'templates.js'])) 74 | .pipe(concat('swagger-ui.js')) 75 | .pipe(wrap('(function(){<%= contents %>}).call(this);')) 76 | .pipe(header(banner, { pkg: pkg } )) 77 | .pipe(gulp.dest('./dist')) 78 | .pipe(uglify()) 79 | .on('error', log) 80 | .pipe(rename({extname: '.min.js'})) 81 | .on('error', log) 82 | .pipe(gulp.dest('./dist')) 83 | .pipe(connect.reload()); 84 | }); 85 | 86 | /** 87 | * Processes less files into CSS files 88 | */ 89 | gulp.task('less', ['clean'], function() { 90 | 91 | return gulp 92 | .src([ 93 | './src/main/less/screen.less', 94 | './src/main/less/print.less', 95 | './src/main/less/reset.less', 96 | './src/main/less/style.less' 97 | ]) 98 | .pipe(less()) 99 | .on('error', log) 100 | .pipe(gulp.dest('./src/main/html/css/')) 101 | .pipe(connect.reload()); 102 | }); 103 | 104 | 105 | /** 106 | * Copy lib and html folders 107 | */ 108 | gulp.task('copy', ['less'], function() { 109 | 110 | // copy JavaScript files inside lib folder 111 | gulp 112 | .src(['./lib/**/*.{js,map}']) 113 | .pipe(gulp.dest('./dist/lib')) 114 | .on('error', log); 115 | 116 | // copy `lang` for translations 117 | gulp 118 | .src(['./lang/**/*.js']) 119 | .pipe(gulp.dest('./dist/lang')) 120 | .on('error', log); 121 | 122 | // copy all files inside html folder 123 | gulp 124 | .src(['./src/main/html/**/*']) 125 | .pipe(gulp.dest('./dist')) 126 | .on('error', log); 127 | }); 128 | 129 | /** 130 | * Watch for changes and recompile 131 | */ 132 | gulp.task('watch', function() { 133 | return watch(['./src/**/*.{js,less,handlebars}'], function() { 134 | gulp.start('default'); 135 | }); 136 | }); 137 | 138 | /** 139 | * Live reload web server of `dist` 140 | */ 141 | gulp.task('connect', function() { 142 | connect.server({ 143 | root: 'dist', 144 | livereload: true 145 | }); 146 | }); 147 | 148 | function log(error) { 149 | console.error(error.toString && error.toString()); 150 | } 151 | 152 | 153 | gulp.task('default', ['dist', 'copy']); 154 | gulp.task('serve', ['connect', 'watch']); 155 | -------------------------------------------------------------------------------- /test/specs/v1.2/petstore/store.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiVersion": "1.0.0", 3 | "swaggerVersion": "1.2", 4 | "basePath": "http://petstore.swagger.io/api", 5 | "resourcePath": "/store", 6 | "produces": [ 7 | "application/json" 8 | ], 9 | "apis": [ 10 | { 11 | "path": "/store/order/{orderId}", 12 | "operations": [ 13 | { 14 | "method": "GET", 15 | "summary": "Find purchase order by ID", 16 | "notes": "For valid response try integer IDs with value <= 5. Anything above 5 or nonintegers will generate API errors", 17 | "type": "Order", 18 | "nickname": "getOrderById", 19 | "authorizations": {}, 20 | "parameters": [ 21 | { 22 | "name": "orderId", 23 | "description": "ID of pet that needs to be fetched", 24 | "required": true, 25 | "type": "string", 26 | "paramType": "path" 27 | } 28 | ], 29 | "responseMessages": [ 30 | { 31 | "code": 400, 32 | "message": "Invalid ID supplied" 33 | }, 34 | { 35 | "code": 404, 36 | "message": "Order not found" 37 | } 38 | ] 39 | }, 40 | { 41 | "method": "DELETE", 42 | "summary": "Delete purchase order by ID", 43 | "notes": "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", 44 | "type": "void", 45 | "nickname": "deleteOrder", 46 | "authorizations": { 47 | "oauth2": [ 48 | { 49 | "scope": "test:anything", 50 | "description": "anything" 51 | } 52 | ] 53 | }, 54 | "parameters": [ 55 | { 56 | "name": "orderId", 57 | "description": "ID of the order that needs to be deleted", 58 | "required": true, 59 | "type": "string", 60 | "paramType": "path" 61 | } 62 | ], 63 | "responseMessages": [ 64 | { 65 | "code": 400, 66 | "message": "Invalid ID supplied" 67 | }, 68 | { 69 | "code": 404, 70 | "message": "Order not found" 71 | } 72 | ] 73 | } 74 | ] 75 | }, 76 | { 77 | "path": "/store/order", 78 | "operations": [ 79 | { 80 | "method": "POST", 81 | "summary": "Place an order for a pet", 82 | "notes": "", 83 | "type": "void", 84 | "nickname": "placeOrder", 85 | "authorizations": { 86 | "oauth2": [ 87 | { 88 | "scope": "test:anything", 89 | "description": "anything" 90 | } 91 | ] 92 | }, 93 | "parameters": [ 94 | { 95 | "name": "body", 96 | "description": "order placed for purchasing the pet", 97 | "required": true, 98 | "type": "Order", 99 | "paramType": "body" 100 | } 101 | ], 102 | "responseMessages": [ 103 | { 104 | "code": 400, 105 | "message": "Invalid order" 106 | } 107 | ] 108 | } 109 | ] 110 | } 111 | ], 112 | "models": { 113 | "Order": { 114 | "id": "Order", 115 | "description": "an order in the system", 116 | "properties": { 117 | "id": { 118 | "type": "integer", 119 | "format": "int64" 120 | }, 121 | "petId": { 122 | "type": "integer", 123 | "format": "int64" 124 | }, 125 | "quantity": { 126 | "type": "integer", 127 | "format": "int32" 128 | }, 129 | "status": { 130 | "type": "string", 131 | "description": "Order Status", 132 | "enum": [ 133 | "placed", 134 | " approved", 135 | " delivered" 136 | ] 137 | }, 138 | "shipDate": { 139 | "type": "string", 140 | "format": "date-time" 141 | } 142 | } 143 | } 144 | } 145 | } -------------------------------------------------------------------------------- /src/main/javascript/view/MainView.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | SwaggerUi.Views.MainView = Backbone.View.extend({ 4 | apisSorter : { 5 | alpha : function(a,b){ return a.name.localeCompare(b.name); } 6 | }, 7 | operationsSorters : { 8 | alpha : function(a,b){ return a.path.localeCompare(b.path); }, 9 | method : function(a,b){ return a.method.localeCompare(b.method); } 10 | }, 11 | initialize: function(opts){ 12 | var sorterOption, sorterFn, key, value; 13 | opts = opts || {}; 14 | 15 | this.router = opts.router; 16 | 17 | // Sort APIs 18 | if (opts.swaggerOptions.apisSorter) { 19 | sorterOption = opts.swaggerOptions.apisSorter; 20 | if (_.isFunction(sorterOption)) { 21 | sorterFn = sorterOption; 22 | } else { 23 | sorterFn = this.apisSorter[sorterOption]; 24 | } 25 | if (_.isFunction(sorterFn)) { 26 | this.model.apisArray.sort(sorterFn); 27 | } 28 | } 29 | // Sort operations of each API 30 | if (opts.swaggerOptions.operationsSorter) { 31 | sorterOption = opts.swaggerOptions.operationsSorter; 32 | if (_.isFunction(sorterOption)) { 33 | sorterFn = sorterOption; 34 | } else { 35 | sorterFn = this.operationsSorters[sorterOption]; 36 | } 37 | if (_.isFunction(sorterFn)) { 38 | for (key in this.model.apisArray) { 39 | this.model.apisArray[key].operationsArray.sort(sorterFn); 40 | } 41 | } 42 | } 43 | 44 | // set up the UI for input 45 | this.model.auths = []; 46 | 47 | for (key in this.model.securityDefinitions) { 48 | value = this.model.securityDefinitions[key]; 49 | 50 | this.model.auths.push({ 51 | name: key, 52 | type: value.type, 53 | value: value 54 | }); 55 | } 56 | 57 | if ('validatorUrl' in opts.swaggerOptions) { 58 | // Validator URL specified explicitly 59 | this.model.validatorUrl = opts.swaggerOptions.validatorUrl; 60 | } else if (this.model.url.indexOf('localhost') > 0) { 61 | // Localhost override 62 | this.model.validatorUrl = null; 63 | } else { 64 | // Default validator 65 | if(window.location.protocol === 'https:') { 66 | this.model.validatorUrl = 'https://online.swagger.io/validator'; 67 | } 68 | else { 69 | this.model.validatorUrl = 'http://online.swagger.io/validator'; 70 | } 71 | } 72 | }, 73 | 74 | render: function(){ 75 | if (this.model.securityDefinitions) { 76 | for (var name in this.model.securityDefinitions) { 77 | var auth = this.model.securityDefinitions[name]; 78 | var button; 79 | 80 | if (auth.type === 'apiKey' && $('#apikey_button').length === 0) { 81 | button = new SwaggerUi.Views.ApiKeyButton({model: auth, router: this.router}).render().el; 82 | $('.auth_main_container').append(button); 83 | } 84 | 85 | if (auth.type === 'basicAuth' && $('#basic_auth_button').length === 0) { 86 | button = new SwaggerUi.Views.BasicAuthButton({model: auth, router: this.router}).render().el; 87 | $('.auth_main_container').append(button); 88 | } 89 | } 90 | } 91 | 92 | // Render the outer container for resources 93 | $(this.el).html(Handlebars.templates.main(this.model)); 94 | 95 | // Render each resource 96 | 97 | var resources = {}; 98 | var counter = 0; 99 | for (var i = 0; i < this.model.apisArray.length; i++) { 100 | var resource = this.model.apisArray[i]; 101 | var id = resource.name; 102 | while (typeof resources[id] !== 'undefined') { 103 | id = id + '_' + counter; 104 | counter += 1; 105 | } 106 | resource.id = id; 107 | resources[id] = resource; 108 | this.addResource(resource, this.model.auths); 109 | } 110 | 111 | $('.propWrap').hover(function onHover(){ 112 | $('.optionsWrapper', $(this)).show(); 113 | }, function offhover(){ 114 | $('.optionsWrapper', $(this)).hide(); 115 | }); 116 | return this; 117 | }, 118 | 119 | addResource: function(resource, auths){ 120 | // Render a resource and add it to resources li 121 | resource.id = resource.id.replace(/\s/g, '_'); 122 | var resourceView = new SwaggerUi.Views.ResourceView({ 123 | model: resource, 124 | router: this.router, 125 | tagName: 'li', 126 | id: 'resource_' + resource.id, 127 | className: 'resource', 128 | auths: auths, 129 | swaggerOptions: this.options.swaggerOptions 130 | }); 131 | $('#resources', this.el).append(resourceView.render().el); 132 | }, 133 | 134 | clear: function(){ 135 | $(this.el).html(''); 136 | } 137 | }); 138 | -------------------------------------------------------------------------------- /src/main/template/operation.handlebars: -------------------------------------------------------------------------------- 1 | 2 |
      3 |
    • 4 |
      5 |

      6 | 7 | {{method}} 8 | 9 | 10 | {{path}} 11 | 12 |

      13 | 18 |
      19 |
    • 112 |
    113 | -------------------------------------------------------------------------------- /dist/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Swagger UI 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 102 | 103 | 104 | 105 | 115 | 116 |
     
    117 |
    118 | 119 | 120 | -------------------------------------------------------------------------------- /src/main/html/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Swagger UI 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 102 | 103 | 104 | 105 | 115 | 116 |
     
    117 |
    118 | 119 | 120 | -------------------------------------------------------------------------------- /dist/css/style.css: -------------------------------------------------------------------------------- 1 | .swagger-section #header a#logo { 2 | font-size: 1.5em; 3 | font-weight: bold; 4 | text-decoration: none; 5 | background: transparent url(../images/logo.png) no-repeat left center; 6 | padding: 20px 0 20px 40px; 7 | } 8 | #text-head { 9 | font-size: 80px; 10 | font-family: 'Roboto', sans-serif; 11 | color: #ffffff; 12 | float: right; 13 | margin-right: 20%; 14 | } 15 | .navbar-fixed-top .navbar-nav { 16 | height: auto; 17 | } 18 | .navbar-fixed-top .navbar-brand { 19 | height: auto; 20 | } 21 | .navbar-header { 22 | height: auto; 23 | } 24 | .navbar-inverse { 25 | background-color: #000; 26 | border-color: #000; 27 | } 28 | #navbar-brand { 29 | margin-left: 20%; 30 | } 31 | .navtext { 32 | font-size: 10px; 33 | } 34 | .h1, 35 | h1 { 36 | font-size: 60px; 37 | } 38 | .navbar-default .navbar-header .navbar-brand { 39 | color: #a2dfee; 40 | } 41 | /* tag titles */ 42 | .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a { 43 | color: #393939; 44 | font-family: 'Arvo', serif; 45 | font-size: 1.5em; 46 | } 47 | .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover { 48 | color: black; 49 | } 50 | .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 { 51 | color: #525252; 52 | padding-left: 0px; 53 | display: block; 54 | clear: none; 55 | float: left; 56 | font-family: 'Arvo', serif; 57 | font-weight: bold; 58 | } 59 | .navbar-default .navbar-collapse, 60 | .navbar-default .navbar-form { 61 | border-color: #0A0A0A; 62 | } 63 | .container1 { 64 | width: 1500px; 65 | margin: auto; 66 | margin-top: 0; 67 | background-image: url('../images/shield.png'); 68 | background-repeat: no-repeat; 69 | background-position: -40px -20px; 70 | margin-bottom: 210px; 71 | } 72 | .container-inner { 73 | width: 1200px; 74 | margin: auto; 75 | background-color: rgba(223, 227, 228, 0.75); 76 | padding-bottom: 40px; 77 | padding-top: 40px; 78 | border-radius: 15px; 79 | } 80 | .header-content { 81 | padding: 0; 82 | width: 1000px; 83 | } 84 | .title1 { 85 | font-size: 80px; 86 | font-family: 'Vollkorn', serif; 87 | color: #404040; 88 | text-align: center; 89 | padding-top: 40px; 90 | padding-bottom: 100px; 91 | } 92 | #icon { 93 | margin-top: -18px; 94 | } 95 | .subtext { 96 | font-size: 25px; 97 | font-style: italic; 98 | color: #08b; 99 | text-align: right; 100 | padding-right: 250px; 101 | } 102 | .bg-primary { 103 | background-color: #00468b; 104 | } 105 | .navbar-default .nav > li > a, 106 | .navbar-default .nav > li > a:focus { 107 | color: #08b; 108 | } 109 | .navbar-default .nav > li > a, 110 | .navbar-default .nav > li > a:hover { 111 | color: #08b; 112 | } 113 | .navbar-default .nav > li > a, 114 | .navbar-default .nav > li > a:focus:hover { 115 | color: #08b; 116 | } 117 | .text-faded { 118 | font-size: 25px; 119 | font-family: 'Vollkorn', serif; 120 | } 121 | .section-heading { 122 | font-family: 'Vollkorn', serif; 123 | font-size: 45px; 124 | padding-bottom: 10px; 125 | } 126 | hr { 127 | border-color: #00468b; 128 | padding-bottom: 10px; 129 | } 130 | .description { 131 | margin-top: 20px; 132 | padding-bottom: 200px; 133 | } 134 | .description li { 135 | font-family: 'Vollkorn', serif; 136 | font-size: 25px; 137 | color: #525252; 138 | margin-left: 28%; 139 | padding-top: 5px; 140 | } 141 | .gap { 142 | margin-top: 200px; 143 | } 144 | .troubleshootingtext { 145 | color: rgba(255, 255, 255, 0.7); 146 | padding-left: 30%; 147 | } 148 | .troubleshootingtext li { 149 | list-style-type: circle; 150 | font-size: 25px; 151 | padding-bottom: 5px; 152 | } 153 | .overlay { 154 | position: absolute; 155 | top: 0; 156 | left: 0; 157 | width: 100%; 158 | height: 100%; 159 | z-index: 1000; 160 | } 161 | .block.response_body.json:hover { 162 | cursor: pointer; 163 | } 164 | .backdrop { 165 | color: blue; 166 | } 167 | #myModal { 168 | height: 100%; 169 | } 170 | .modal-backdrop { 171 | bottom: 0; 172 | position: fixed; 173 | } 174 | .curl { 175 | padding: 10px; 176 | font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; 177 | font-size: 0.9em; 178 | max-height: 400px; 179 | margin-top: 5px; 180 | overflow-y: auto; 181 | background-color: #fcf6db; 182 | border: 1px solid #e5e0c6; 183 | border-radius: 4px; 184 | } 185 | .curl_title { 186 | font-size: 1.1em; 187 | margin: 0; 188 | padding: 15px 0 5px; 189 | font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif; 190 | font-weight: 500; 191 | line-height: 1.1; 192 | } 193 | .footer { 194 | display: none; 195 | } 196 | .swagger-section .swagger-ui-wrap h2 { 197 | padding: 0; 198 | } 199 | h2 { 200 | margin: 0; 201 | margin-bottom: 5px; 202 | } 203 | .markdown p { 204 | font-size: 15px; 205 | font-family: 'Arvo', serif; 206 | } 207 | .swagger-section .swagger-ui-wrap .code { 208 | font-size: 15px; 209 | font-family: 'Arvo', serif; 210 | } 211 | .swagger-section .swagger-ui-wrap b { 212 | font-family: 'Arvo', serif; 213 | } 214 | #signin:hover { 215 | cursor: pointer; 216 | } 217 | .dropdown-menu { 218 | padding: 15px; 219 | } 220 | .navbar-right .dropdown-menu { 221 | left: 0; 222 | right: auto; 223 | } 224 | #signinbutton { 225 | width: 100%; 226 | height: 32px; 227 | font-size: 13px; 228 | font-weight: bold; 229 | color: #08b; 230 | } 231 | .navbar-default .nav > li .details { 232 | color: #000000; 233 | text-transform: none; 234 | font-size: 15px; 235 | font-weight: normal; 236 | font-family: 'Open Sans', sans-serif; 237 | font-style: italic; 238 | line-height: 20px; 239 | top: -2px; 240 | } 241 | .navbar-default .nav > li .details:hover { 242 | color: black; 243 | } 244 | #signout { 245 | width: 100%; 246 | height: 32px; 247 | font-size: 13px; 248 | font-weight: bold; 249 | color: #08b; 250 | } 251 | -------------------------------------------------------------------------------- /src/main/html/css/style.css: -------------------------------------------------------------------------------- 1 | .swagger-section #header a#logo { 2 | font-size: 1.5em; 3 | font-weight: bold; 4 | text-decoration: none; 5 | background: transparent url(../images/logo.png) no-repeat left center; 6 | padding: 20px 0 20px 40px; 7 | } 8 | #text-head { 9 | font-size: 80px; 10 | font-family: 'Roboto', sans-serif; 11 | color: #ffffff; 12 | float: right; 13 | margin-right: 20%; 14 | } 15 | .navbar-fixed-top .navbar-nav { 16 | height: auto; 17 | } 18 | .navbar-fixed-top .navbar-brand { 19 | height: auto; 20 | } 21 | .navbar-header { 22 | height: auto; 23 | } 24 | .navbar-inverse { 25 | background-color: #000; 26 | border-color: #000; 27 | } 28 | #navbar-brand { 29 | margin-left: 20%; 30 | } 31 | .navtext { 32 | font-size: 10px; 33 | } 34 | .h1, 35 | h1 { 36 | font-size: 60px; 37 | } 38 | .navbar-default .navbar-header .navbar-brand { 39 | color: #a2dfee; 40 | } 41 | /* tag titles */ 42 | .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a { 43 | color: #393939; 44 | font-family: 'Arvo', serif; 45 | font-size: 1.5em; 46 | } 47 | .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover { 48 | color: black; 49 | } 50 | .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 { 51 | color: #525252; 52 | padding-left: 0px; 53 | display: block; 54 | clear: none; 55 | float: left; 56 | font-family: 'Arvo', serif; 57 | font-weight: bold; 58 | } 59 | .navbar-default .navbar-collapse, 60 | .navbar-default .navbar-form { 61 | border-color: #0A0A0A; 62 | } 63 | .container1 { 64 | width: 1500px; 65 | margin: auto; 66 | margin-top: 0; 67 | background-image: url('../images/shield.png'); 68 | background-repeat: no-repeat; 69 | background-position: -40px -20px; 70 | margin-bottom: 210px; 71 | } 72 | .container-inner { 73 | width: 1200px; 74 | margin: auto; 75 | background-color: rgba(223, 227, 228, 0.75); 76 | padding-bottom: 40px; 77 | padding-top: 40px; 78 | border-radius: 15px; 79 | } 80 | .header-content { 81 | padding: 0; 82 | width: 1000px; 83 | } 84 | .title1 { 85 | font-size: 80px; 86 | font-family: 'Vollkorn', serif; 87 | color: #404040; 88 | text-align: center; 89 | padding-top: 40px; 90 | padding-bottom: 100px; 91 | } 92 | #icon { 93 | margin-top: -18px; 94 | } 95 | .subtext { 96 | font-size: 25px; 97 | font-style: italic; 98 | color: #08b; 99 | text-align: right; 100 | padding-right: 250px; 101 | } 102 | .bg-primary { 103 | background-color: #00468b; 104 | } 105 | .navbar-default .nav > li > a, 106 | .navbar-default .nav > li > a:focus { 107 | color: #08b; 108 | } 109 | .navbar-default .nav > li > a, 110 | .navbar-default .nav > li > a:hover { 111 | color: #08b; 112 | } 113 | .navbar-default .nav > li > a, 114 | .navbar-default .nav > li > a:focus:hover { 115 | color: #08b; 116 | } 117 | .text-faded { 118 | font-size: 25px; 119 | font-family: 'Vollkorn', serif; 120 | } 121 | .section-heading { 122 | font-family: 'Vollkorn', serif; 123 | font-size: 45px; 124 | padding-bottom: 10px; 125 | } 126 | hr { 127 | border-color: #00468b; 128 | padding-bottom: 10px; 129 | } 130 | .description { 131 | margin-top: 20px; 132 | padding-bottom: 200px; 133 | } 134 | .description li { 135 | font-family: 'Vollkorn', serif; 136 | font-size: 25px; 137 | color: #525252; 138 | margin-left: 28%; 139 | padding-top: 5px; 140 | } 141 | .gap { 142 | margin-top: 200px; 143 | } 144 | .troubleshootingtext { 145 | color: rgba(255, 255, 255, 0.7); 146 | padding-left: 30%; 147 | } 148 | .troubleshootingtext li { 149 | list-style-type: circle; 150 | font-size: 25px; 151 | padding-bottom: 5px; 152 | } 153 | .overlay { 154 | position: absolute; 155 | top: 0; 156 | left: 0; 157 | width: 100%; 158 | height: 100%; 159 | z-index: 1000; 160 | } 161 | .block.response_body.json:hover { 162 | cursor: pointer; 163 | } 164 | .backdrop { 165 | color: blue; 166 | } 167 | #myModal { 168 | height: 100%; 169 | } 170 | .modal-backdrop { 171 | bottom: 0; 172 | position: fixed; 173 | } 174 | .curl { 175 | padding: 10px; 176 | font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; 177 | font-size: 0.9em; 178 | max-height: 400px; 179 | margin-top: 5px; 180 | overflow-y: auto; 181 | background-color: #fcf6db; 182 | border: 1px solid #e5e0c6; 183 | border-radius: 4px; 184 | } 185 | .curl_title { 186 | font-size: 1.1em; 187 | margin: 0; 188 | padding: 15px 0 5px; 189 | font-family: 'Open Sans', 'Helvetica Neue', Arial, sans-serif; 190 | font-weight: 500; 191 | line-height: 1.1; 192 | } 193 | .footer { 194 | display: none; 195 | } 196 | .swagger-section .swagger-ui-wrap h2 { 197 | padding: 0; 198 | } 199 | h2 { 200 | margin: 0; 201 | margin-bottom: 5px; 202 | } 203 | .markdown p { 204 | font-size: 15px; 205 | font-family: 'Arvo', serif; 206 | } 207 | .swagger-section .swagger-ui-wrap .code { 208 | font-size: 15px; 209 | font-family: 'Arvo', serif; 210 | } 211 | .swagger-section .swagger-ui-wrap b { 212 | font-family: 'Arvo', serif; 213 | } 214 | #signin:hover { 215 | cursor: pointer; 216 | } 217 | .dropdown-menu { 218 | padding: 15px; 219 | } 220 | .navbar-right .dropdown-menu { 221 | left: 0; 222 | right: auto; 223 | } 224 | #signinbutton { 225 | width: 100%; 226 | height: 32px; 227 | font-size: 13px; 228 | font-weight: bold; 229 | color: #08b; 230 | } 231 | .navbar-default .nav > li .details { 232 | color: #000000; 233 | text-transform: none; 234 | font-size: 15px; 235 | font-weight: normal; 236 | font-family: 'Open Sans', sans-serif; 237 | font-style: italic; 238 | line-height: 20px; 239 | top: -2px; 240 | } 241 | .navbar-default .nav > li .details:hover { 242 | color: black; 243 | } 244 | #signout { 245 | width: 100%; 246 | height: 32px; 247 | font-size: 13px; 248 | font-weight: bold; 249 | color: #08b; 250 | } 251 | -------------------------------------------------------------------------------- /src/main/less/style.less: -------------------------------------------------------------------------------- 1 | 2 | 3 | .swagger-section #header a#logo { 4 | font-size: 1.5em; 5 | font-weight: bold; 6 | text-decoration: none; 7 | background: transparent url(../images/logo.png) no-repeat left center; 8 | padding: 20px 0 20px 40px; 9 | } 10 | 11 | #text-head{ 12 | font-size: 80px; 13 | font-family: 'Roboto', sans-serif; 14 | color: #ffffff; 15 | float: right; 16 | margin-right: 20%; 17 | } 18 | 19 | .navbar-fixed-top .navbar-nav { 20 | height:auto; 21 | } 22 | 23 | .navbar-fixed-top .navbar-brand { 24 | height: auto; 25 | } 26 | 27 | .navbar-header { 28 | height: auto; 29 | } 30 | 31 | .navbar-inverse { 32 | background-color: #000; 33 | border-color: #000; 34 | } 35 | 36 | #navbar-brand { 37 | margin-left: 20%; 38 | 39 | } 40 | 41 | .navtext { 42 | font-size: 10px; 43 | 44 | } 45 | 46 | .h1, h1 { 47 | font-size: 60px; 48 | 49 | } 50 | 51 | 52 | 53 | .navbar-default .navbar-header .navbar-brand { 54 | color: #a2dfee; 55 | } 56 | 57 | /* tag titles */ 58 | .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a { 59 | color: #393939; 60 | font-family: 'Arvo', serif; 61 | font-size: 1.5em; 62 | 63 | } 64 | 65 | .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 a:hover { 66 | color: black; 67 | } 68 | 69 | .swagger-section .swagger-ui-wrap ul#resources li.resource div.heading h2 { 70 | color: #525252; 71 | padding-left: 0px; 72 | display: block; 73 | clear: none; 74 | float: left; 75 | font-family: 'Arvo', serif; 76 | font-weight: bold; 77 | } 78 | 79 | .navbar-default .navbar-collapse, .navbar-default .navbar-form { 80 | border-color: #0A0A0A; 81 | } 82 | 83 | .container1 { 84 | width: 1500px; 85 | margin: auto; 86 | margin-top: 0; 87 | background-image: url('../images/shield.png'); 88 | background-repeat: no-repeat; 89 | background-position: -40px -20px; 90 | margin-bottom: 210px; 91 | } 92 | 93 | .container-inner { 94 | width: 1200px; 95 | margin: auto; 96 | background-color: rgba(223,227,228, 0.75); 97 | padding-bottom: 40px; 98 | padding-top: 40px; 99 | border-radius: 15px; 100 | 101 | } 102 | 103 | .header-content { 104 | padding: 0; 105 | width: 1000px; 106 | 107 | } 108 | 109 | .title1 { 110 | font-size: 80px; 111 | font-family: 'Vollkorn', serif; 112 | color: #404040; 113 | text-align: center; 114 | padding-top: 40px; 115 | padding-bottom: 100px; 116 | } 117 | 118 | #icon { 119 | margin-top: -18px; 120 | } 121 | 122 | .subtext{ 123 | font-size: 25px; 124 | font-style: italic; 125 | color: #08b; 126 | text-align: right; 127 | padding-right: 250px; 128 | } 129 | 130 | .container-fluid { 131 | 132 | } 133 | 134 | .bg-primary { 135 | background-color: #00468b; 136 | } 137 | 138 | .navbar-default .nav > li>a, .navbar-default .nav>li>a:focus { 139 | color: #08b; 140 | } 141 | 142 | .navbar-default .nav > li>a, .navbar-default .nav>li>a:hover { 143 | color: #08b; 144 | } 145 | 146 | .navbar-default .nav > li>a, .navbar-default .nav>li>a:focus:hover { 147 | color: #08b; 148 | } 149 | 150 | .text-faded { 151 | font-size: 25px; 152 | font-family: 'Vollkorn', serif; 153 | } 154 | 155 | .section-heading{ 156 | font-family: 'Vollkorn', serif; 157 | font-size: 45px; 158 | padding-bottom: 10px; 159 | } 160 | 161 | hr { 162 | border-color: #00468b; 163 | padding-bottom: 10px; 164 | } 165 | 166 | .description { 167 | margin-top: 20px; 168 | padding-bottom: 200px; 169 | } 170 | .description li { 171 | font-family: 'Vollkorn', serif; 172 | font-size: 25px; 173 | color: #525252; 174 | margin-left: 28%; 175 | padding-top: 5px; 176 | } 177 | 178 | .gap { 179 | margin-top: 200px; 180 | } 181 | 182 | .troubleshootingtext { 183 | color: rgba(255,255,255,.7); 184 | padding-left: 30%; 185 | } 186 | 187 | .troubleshootingtext li { 188 | list-style-type: circle; 189 | font-size: 25px; 190 | padding-bottom: 5px; 191 | } 192 | 193 | .overlay { 194 | position:absolute; 195 | top:0; 196 | left:0; 197 | width:100%; 198 | height:100%; 199 | z-index:1000; 200 | } 201 | 202 | .block.response_body.json:hover{ 203 | cursor: pointer; 204 | } 205 | 206 | .backdrop { 207 | color: blue; 208 | } 209 | 210 | #myModal { 211 | height: 100%; 212 | } 213 | 214 | .modal-backdrop { 215 | bottom: 0; 216 | position: fixed; 217 | } 218 | 219 | .curl { 220 | padding: 10px; 221 | font-family: "Anonymous Pro", "Menlo", "Consolas", "Bitstream Vera Sans Mono", "Courier New", monospace; 222 | font-size: 0.9em; 223 | max-height: 400px; 224 | margin-top: 5px; 225 | overflow-y: auto; 226 | background-color: #fcf6db; 227 | border: 1px solid #e5e0c6; 228 | border-radius: 4px; 229 | 230 | } 231 | 232 | .curl_title { 233 | font-size: 1.1em; 234 | margin: 0; 235 | padding: 15px 0 5px; 236 | font-family: 'Open Sans','Helvetica Neue',Arial,sans-serif; 237 | font-weight: 500; 238 | line-height: 1.1; 239 | } 240 | 241 | .footer { 242 | display: none; 243 | } 244 | 245 | .swagger-section .swagger-ui-wrap h2 { 246 | padding: 0; 247 | } 248 | 249 | h2 { 250 | margin: 0; 251 | margin-bottom: 5px; 252 | } 253 | 254 | .markdown p { 255 | font-size: 15px; 256 | font-family: 'Arvo', serif; 257 | } 258 | 259 | .swagger-section .swagger-ui-wrap .code { 260 | font-size: 15px; 261 | font-family: 'Arvo',serif; 262 | } 263 | 264 | .swagger-section .swagger-ui-wrap b { 265 | font-family: 'Arvo',serif; 266 | } 267 | 268 | #signin:hover { 269 | cursor: pointer; 270 | } 271 | 272 | .dropdown-menu { 273 | padding: 15px; 274 | } 275 | 276 | .navbar-right .dropdown-menu { 277 | left: 0; 278 | right: auto; 279 | } 280 | 281 | #signinbutton { 282 | width: 100%; 283 | height: 32px; 284 | font-size: 13px; 285 | font-weight: bold; 286 | color: #08b; 287 | } 288 | 289 | .navbar-default .nav > li .details { 290 | color: #000000; 291 | text-transform: none; 292 | font-size: 15px; 293 | font-weight: normal; 294 | font-family: 'Open Sans', sans-serif; 295 | font-style: italic; 296 | line-height: 20px; 297 | top: -2px; 298 | } 299 | 300 | .navbar-default .nav > li .details:hover { 301 | color: black; 302 | 303 | } 304 | 305 | #signout { 306 | width: 100%; 307 | height: 32px; 308 | font-size: 13px; 309 | font-weight: bold; 310 | color: #08b; 311 | } 312 | -------------------------------------------------------------------------------- /src/main/javascript/doc.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | 4 | $(function() { 5 | 6 | // Helper function for vertically aligning DOM elements 7 | // http://www.seodenver.com/simple-vertical-align-plugin-for-jquery/ 8 | $.fn.vAlign = function() { 9 | return this.each(function(){ 10 | var ah = $(this).height(); 11 | var ph = $(this).parent().height(); 12 | var mh = (ph - ah) / 2; 13 | $(this).css('margin-top', mh); 14 | }); 15 | }; 16 | 17 | $.fn.stretchFormtasticInputWidthToParent = function() { 18 | return this.each(function(){ 19 | var p_width = $(this).closest("form").innerWidth(); 20 | var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest('form').css('padding-right'), 10); 21 | var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10); 22 | $(this).css('width', p_width - p_padding - this_padding); 23 | }); 24 | }; 25 | 26 | $('form.formtastic li.string input, form.formtastic textarea').stretchFormtasticInputWidthToParent(); 27 | 28 | // Vertically center these paragraphs 29 | // Parent may need a min-height for this to work.. 30 | $('ul.downplayed li div.content p').vAlign(); 31 | 32 | // When a sandbox form is submitted.. 33 | $("form.sandbox").submit(function(){ 34 | 35 | var error_free = true; 36 | 37 | // Cycle through the forms required inputs 38 | $(this).find("input.required").each(function() { 39 | 40 | // Remove any existing error styles from the input 41 | $(this).removeClass('error'); 42 | 43 | // Tack the error style on if the input is empty.. 44 | if ($(this).val() === '') { 45 | $(this).addClass('error'); 46 | $(this).wiggle(); 47 | error_free = false; 48 | } 49 | 50 | }); 51 | 52 | return error_free; 53 | }); 54 | 55 | }); 56 | 57 | function clippyCopiedCallback() { 58 | $('#api_key_copied').fadeIn().delay(1000).fadeOut(); 59 | 60 | // var b = $("#clippy_tooltip_" + a); 61 | // b.length != 0 && (b.attr("title", "copied!").trigger("tipsy.reload"), setTimeout(function() { 62 | // b.attr("title", "copy to clipboard") 63 | // }, 64 | // 500)) 65 | } 66 | 67 | // Logging function that accounts for browsers that don't have window.console 68 | function log(){ 69 | log.history = log.history || []; 70 | log.history.push(arguments); 71 | if(this.console){ 72 | console.log( Array.prototype.slice.call(arguments)[0] ); 73 | } 74 | } 75 | 76 | // Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913) 77 | if (Function.prototype.bind && console && typeof console.log === "object") { 78 | [ 79 | "log","info","warn","error","assert","dir","clear","profile","profileEnd" 80 | ].forEach(function (method) { 81 | console[method] = this.bind(console[method], console); 82 | }, Function.prototype.call); 83 | } 84 | 85 | window.Docs = { 86 | 87 | shebang: function() { 88 | 89 | // If shebang has an operation nickname in it.. 90 | // e.g. /docs/#!/words/get_search 91 | var fragments = $.param.fragment().split('/'); 92 | fragments.shift(); // get rid of the bang 93 | 94 | switch (fragments.length) { 95 | case 1: 96 | if (fragments[0].length > 0) { // prevent matching "#/" 97 | // Expand all operations for the resource and scroll to it 98 | var dom_id = 'resource_' + fragments[0]; 99 | 100 | Docs.expandEndpointListForResource(fragments[0]); 101 | $("#"+dom_id).slideto({highlight: false}); 102 | } 103 | break; 104 | case 2: 105 | // Refer to the endpoint DOM element, e.g. #words_get_search 106 | 107 | // Expand Resource 108 | Docs.expandEndpointListForResource(fragments[0]); 109 | $("#"+dom_id).slideto({highlight: false}); 110 | 111 | // Expand operation 112 | var li_dom_id = fragments.join('_'); 113 | var li_content_dom_id = li_dom_id + "_content"; 114 | 115 | 116 | Docs.expandOperation($('#'+li_content_dom_id)); 117 | $('#'+li_dom_id).slideto({highlight: false}); 118 | break; 119 | } 120 | 121 | }, 122 | 123 | toggleEndpointListForResource: function(resource) { 124 | var elem = $('li#resource_' + Docs.escapeResourceName(resource) + ' ul.endpoints'); 125 | if (elem.is(':visible')) { 126 | Docs.collapseEndpointListForResource(resource); 127 | } else { 128 | Docs.expandEndpointListForResource(resource); 129 | } 130 | }, 131 | 132 | // Expand resource 133 | expandEndpointListForResource: function(resource) { 134 | var resource = Docs.escapeResourceName(resource); 135 | if (resource == '') { 136 | $('.resource ul.endpoints').slideDown(); 137 | return; 138 | } 139 | 140 | $('li#resource_' + resource).addClass('active'); 141 | 142 | var elem = $('li#resource_' + resource + ' ul.endpoints'); 143 | elem.slideDown(); 144 | }, 145 | 146 | // Collapse resource and mark as explicitly closed 147 | collapseEndpointListForResource: function(resource) { 148 | var resource = Docs.escapeResourceName(resource); 149 | if (resource == '') { 150 | $('.resource ul.endpoints').slideUp(); 151 | return; 152 | } 153 | 154 | $('li#resource_' + resource).removeClass('active'); 155 | 156 | var elem = $('li#resource_' + resource + ' ul.endpoints'); 157 | elem.slideUp(); 158 | }, 159 | 160 | expandOperationsForResource: function(resource) { 161 | // Make sure the resource container is open.. 162 | Docs.expandEndpointListForResource(resource); 163 | 164 | if (resource == '') { 165 | $('.resource ul.endpoints li.operation div.content').slideDown(); 166 | return; 167 | } 168 | 169 | $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { 170 | Docs.expandOperation($(this)); 171 | }); 172 | }, 173 | 174 | collapseOperationsForResource: function(resource) { 175 | // Make sure the resource container is open.. 176 | Docs.expandEndpointListForResource(resource); 177 | 178 | if (resource == '') { 179 | $('.resource ul.endpoints li.operation div.content').slideUp(); 180 | return; 181 | } 182 | 183 | $('li#resource_' + Docs.escapeResourceName(resource) + ' li.operation div.content').each(function() { 184 | Docs.collapseOperation($(this)); 185 | }); 186 | }, 187 | 188 | escapeResourceName: function(resource) { 189 | return resource.replace(/[!"#$%&'()*+,.\/:;<=>?@\[\\\]\^`{|}~]/g, "\\$&"); 190 | }, 191 | 192 | expandOperation: function(elem) { 193 | elem.slideDown(); 194 | }, 195 | 196 | collapseOperation: function(elem) { 197 | elem.slideUp(); 198 | } 199 | }; 200 | -------------------------------------------------------------------------------- /lib/highlight.7.3.pack.js: -------------------------------------------------------------------------------- 1 | var hljs=new function(){function l(o){return o.replace(/&/gm,"&").replace(//gm,">")}function b(p){for(var o=p.firstChild;o;o=o.nextSibling){if(o.nodeName=="CODE"){return o}if(!(o.nodeType==3&&o.nodeValue.match(/\s+/))){break}}}function h(p,o){return Array.prototype.map.call(p.childNodes,function(q){if(q.nodeType==3){return o?q.nodeValue.replace(/\n/g,""):q.nodeValue}if(q.nodeName=="BR"){return"\n"}return h(q,o)}).join("")}function a(q){var p=(q.className+" "+q.parentNode.className).split(/\s+/);p=p.map(function(r){return r.replace(/^language-/,"")});for(var o=0;o"}while(x.length||v.length){var u=t().splice(0,1)[0];y+=l(w.substr(p,u.offset-p));p=u.offset;if(u.event=="start"){y+=s(u.node);r.push(u.node)}else{if(u.event=="stop"){var o,q=r.length;do{q--;o=r[q];y+=("")}while(o!=u.node);r.splice(q,1);while(q'+L[0]+""}else{r+=L[0]}N=A.lR.lastIndex;L=A.lR.exec(K)}return r+K.substr(N)}function z(){if(A.sL&&!e[A.sL]){return l(w)}var r=A.sL?d(A.sL,w):g(w);if(A.r>0){v+=r.keyword_count;B+=r.r}return''+r.value+""}function J(){return A.sL!==undefined?z():G()}function I(L,r){var K=L.cN?'':"";if(L.rB){x+=K;w=""}else{if(L.eB){x+=l(r)+K;w=""}else{x+=K;w=r}}A=Object.create(L,{parent:{value:A}});B+=L.r}function C(K,r){w+=K;if(r===undefined){x+=J();return 0}var L=o(r,A);if(L){x+=J();I(L,r);return L.rB?0:r.length}var M=s(A,r);if(M){if(!(M.rE||M.eE)){w+=r}x+=J();do{if(A.cN){x+=""}A=A.parent}while(A!=M.parent);if(M.eE){x+=l(r)}w="";if(M.starts){I(M.starts,"")}return M.rE?0:r.length}if(t(r,A)){throw"Illegal"}w+=r;return r.length||1}var F=e[D];f(F);var A=F;var w="";var B=0;var v=0;var x="";try{var u,q,p=0;while(true){A.t.lastIndex=p;u=A.t.exec(E);if(!u){break}q=C(E.substr(p,u.index-p),u[0]);p=u.index+q}C(E.substr(p));return{r:B,keyword_count:v,value:x,language:D}}catch(H){if(H=="Illegal"){return{r:0,keyword_count:0,value:l(E)}}else{throw H}}}function g(s){var o={keyword_count:0,r:0,value:l(s)};var q=o;for(var p in e){if(!e.hasOwnProperty(p)){continue}var r=d(p,s);r.language=p;if(r.keyword_count+r.r>q.keyword_count+q.r){q=r}if(r.keyword_count+r.r>o.keyword_count+o.r){q=o;o=r}}if(q.language){o.second_best=q}return o}function i(q,p,o){if(p){q=q.replace(/^((<[^>]+>|\t)+)/gm,function(r,v,u,t){return v.replace(/\t/g,p)})}if(o){q=q.replace(/\n/g,"
    ")}return q}function m(r,u,p){var v=h(r,p);var t=a(r);if(t=="no-highlight"){return}var w=t?d(t,v):g(v);t=w.language;var o=c(r);if(o.length){var q=document.createElement("pre");q.innerHTML=w.value;w.value=j(o,c(q),v)}w.value=i(w.value,u,p);var s=r.className;if(!s.match("(\\s|^)(language-)?"+t+"(\\s|$)")){s=s?(s+" "+t):t}r.innerHTML=w.value;r.className=s;r.result={language:t,kw:w.keyword_count,re:w.r};if(w.second_best){r.second_best={language:w.second_best.language,kw:w.second_best.keyword_count,re:w.second_best.r}}}function n(){if(n.called){return}n.called=true;Array.prototype.map.call(document.getElementsByTagName("pre"),b).filter(Boolean).forEach(function(o){m(o,hljs.tabReplace)})}function k(){window.addEventListener("DOMContentLoaded",n,false);window.addEventListener("load",n,false)}var e={};this.LANGUAGES=e;this.highlight=d;this.highlightAuto=g;this.fixMarkup=i;this.highlightBlock=m;this.initHighlighting=n;this.initHighlightingOnLoad=k;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BNR="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\[\\s\\S]",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BNM={cN:"number",b:this.BNR,r:0};this.inherit=function(q,r){var o={};for(var p in q){o[p]=q[p]}if(r){for(var p in r){o[p]=r[p]}}return o}}();hljs.LANGUAGES.xml=function(a){var c="[A-Za-z0-9\\._:-]+";var b={eW:true,c:[{cN:"attribute",b:c,r:0},{b:'="',rB:true,e:'"',c:[{cN:"value",b:'"',eW:true}]},{b:"='",rB:true,e:"'",c:[{cN:"value",b:"'",eW:true}]},{b:"=",c:[{cN:"value",b:"[^\\s/>]+"}]}]};return{cI:true,c:[{cN:"pi",b:"<\\?",e:"\\?>",r:10},{cN:"doctype",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},{cN:"comment",b:"",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"|$)",e:">",k:{title:"style"},c:[b],starts:{e:"",rE:true,sL:"css"}},{cN:"tag",b:"|$)",e:">",k:{title:"script"},c:[b],starts:{e:"<\/script>",rE:true,sL:"javascript"}},{b:"<%",e:"%>",sL:"vbscript"},{cN:"tag",b:"",c:[{cN:"title",b:"[^ />]+"},b]}]}}(hljs);hljs.LANGUAGES.json=function(a){var e={literal:"true false null"};var d=[a.QSM,a.CNM];var c={cN:"value",e:",",eW:true,eE:true,c:d,k:e};var b={b:"{",e:"}",c:[{cN:"attribute",b:'\\s*"',e:'"\\s*:\\s*',eB:true,eE:true,c:[a.BE],i:"\\n",starts:c}],i:"\\S"};var f={b:"\\[",e:"\\]",c:[a.inherit(c,{cN:null})],i:"\\S"};d.splice(d.length,0,b,f);return{c:d,k:e,i:"\\S"}}(hljs); -------------------------------------------------------------------------------- /dist/lib/highlight.7.3.pack.js: -------------------------------------------------------------------------------- 1 | var hljs=new function(){function l(o){return o.replace(/&/gm,"&").replace(//gm,">")}function b(p){for(var o=p.firstChild;o;o=o.nextSibling){if(o.nodeName=="CODE"){return o}if(!(o.nodeType==3&&o.nodeValue.match(/\s+/))){break}}}function h(p,o){return Array.prototype.map.call(p.childNodes,function(q){if(q.nodeType==3){return o?q.nodeValue.replace(/\n/g,""):q.nodeValue}if(q.nodeName=="BR"){return"\n"}return h(q,o)}).join("")}function a(q){var p=(q.className+" "+q.parentNode.className).split(/\s+/);p=p.map(function(r){return r.replace(/^language-/,"")});for(var o=0;o"}while(x.length||v.length){var u=t().splice(0,1)[0];y+=l(w.substr(p,u.offset-p));p=u.offset;if(u.event=="start"){y+=s(u.node);r.push(u.node)}else{if(u.event=="stop"){var o,q=r.length;do{q--;o=r[q];y+=("")}while(o!=u.node);r.splice(q,1);while(q'+L[0]+""}else{r+=L[0]}N=A.lR.lastIndex;L=A.lR.exec(K)}return r+K.substr(N)}function z(){if(A.sL&&!e[A.sL]){return l(w)}var r=A.sL?d(A.sL,w):g(w);if(A.r>0){v+=r.keyword_count;B+=r.r}return''+r.value+""}function J(){return A.sL!==undefined?z():G()}function I(L,r){var K=L.cN?'':"";if(L.rB){x+=K;w=""}else{if(L.eB){x+=l(r)+K;w=""}else{x+=K;w=r}}A=Object.create(L,{parent:{value:A}});B+=L.r}function C(K,r){w+=K;if(r===undefined){x+=J();return 0}var L=o(r,A);if(L){x+=J();I(L,r);return L.rB?0:r.length}var M=s(A,r);if(M){if(!(M.rE||M.eE)){w+=r}x+=J();do{if(A.cN){x+=""}A=A.parent}while(A!=M.parent);if(M.eE){x+=l(r)}w="";if(M.starts){I(M.starts,"")}return M.rE?0:r.length}if(t(r,A)){throw"Illegal"}w+=r;return r.length||1}var F=e[D];f(F);var A=F;var w="";var B=0;var v=0;var x="";try{var u,q,p=0;while(true){A.t.lastIndex=p;u=A.t.exec(E);if(!u){break}q=C(E.substr(p,u.index-p),u[0]);p=u.index+q}C(E.substr(p));return{r:B,keyword_count:v,value:x,language:D}}catch(H){if(H=="Illegal"){return{r:0,keyword_count:0,value:l(E)}}else{throw H}}}function g(s){var o={keyword_count:0,r:0,value:l(s)};var q=o;for(var p in e){if(!e.hasOwnProperty(p)){continue}var r=d(p,s);r.language=p;if(r.keyword_count+r.r>q.keyword_count+q.r){q=r}if(r.keyword_count+r.r>o.keyword_count+o.r){q=o;o=r}}if(q.language){o.second_best=q}return o}function i(q,p,o){if(p){q=q.replace(/^((<[^>]+>|\t)+)/gm,function(r,v,u,t){return v.replace(/\t/g,p)})}if(o){q=q.replace(/\n/g,"
    ")}return q}function m(r,u,p){var v=h(r,p);var t=a(r);if(t=="no-highlight"){return}var w=t?d(t,v):g(v);t=w.language;var o=c(r);if(o.length){var q=document.createElement("pre");q.innerHTML=w.value;w.value=j(o,c(q),v)}w.value=i(w.value,u,p);var s=r.className;if(!s.match("(\\s|^)(language-)?"+t+"(\\s|$)")){s=s?(s+" "+t):t}r.innerHTML=w.value;r.className=s;r.result={language:t,kw:w.keyword_count,re:w.r};if(w.second_best){r.second_best={language:w.second_best.language,kw:w.second_best.keyword_count,re:w.second_best.r}}}function n(){if(n.called){return}n.called=true;Array.prototype.map.call(document.getElementsByTagName("pre"),b).filter(Boolean).forEach(function(o){m(o,hljs.tabReplace)})}function k(){window.addEventListener("DOMContentLoaded",n,false);window.addEventListener("load",n,false)}var e={};this.LANGUAGES=e;this.highlight=d;this.highlightAuto=g;this.fixMarkup=i;this.highlightBlock=m;this.initHighlighting=n;this.initHighlightingOnLoad=k;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BNR="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|\\.|-|-=|/|/=|:|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\[\\s\\S]",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE],r:0};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE],r:0};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BNM={cN:"number",b:this.BNR,r:0};this.inherit=function(q,r){var o={};for(var p in q){o[p]=q[p]}if(r){for(var p in r){o[p]=r[p]}}return o}}();hljs.LANGUAGES.xml=function(a){var c="[A-Za-z0-9\\._:-]+";var b={eW:true,c:[{cN:"attribute",b:c,r:0},{b:'="',rB:true,e:'"',c:[{cN:"value",b:'"',eW:true}]},{b:"='",rB:true,e:"'",c:[{cN:"value",b:"'",eW:true}]},{b:"=",c:[{cN:"value",b:"[^\\s/>]+"}]}]};return{cI:true,c:[{cN:"pi",b:"<\\?",e:"\\?>",r:10},{cN:"doctype",b:"",r:10,c:[{b:"\\[",e:"\\]"}]},{cN:"comment",b:"",r:10},{cN:"cdata",b:"<\\!\\[CDATA\\[",e:"\\]\\]>",r:10},{cN:"tag",b:"|$)",e:">",k:{title:"style"},c:[b],starts:{e:"",rE:true,sL:"css"}},{cN:"tag",b:"|$)",e:">",k:{title:"script"},c:[b],starts:{e:"<\/script>",rE:true,sL:"javascript"}},{b:"<%",e:"%>",sL:"vbscript"},{cN:"tag",b:"",c:[{cN:"title",b:"[^ />]+"},b]}]}}(hljs);hljs.LANGUAGES.json=function(a){var e={literal:"true false null"};var d=[a.QSM,a.CNM];var c={cN:"value",e:",",eW:true,eE:true,c:d,k:e};var b={b:"{",e:"}",c:[{cN:"attribute",b:'\\s*"',e:'"\\s*:\\s*',eB:true,eE:true,c:[a.BE],i:"\\n",starts:c}],i:"\\S"};var f={b:"\\[",e:"\\]",c:[a.inherit(c,{cN:null})],i:"\\S"};d.splice(d.length,0,b,f);return{c:d,k:e,i:"\\S"}}(hljs); -------------------------------------------------------------------------------- /src/main/javascript/SwaggerUi.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | window.SwaggerUi = Backbone.Router.extend({ 4 | 5 | dom_id: 'swagger_ui', 6 | 7 | // Attributes 8 | options: null, 9 | api: null, 10 | headerView: null, 11 | mainView: null, 12 | 13 | // SwaggerUi accepts all the same options as SwaggerApi 14 | initialize: function(options) { 15 | options = options || {}; 16 | if(!options.highlightSizeThreshold) { 17 | options.highlightSizeThreshold = 100000; 18 | } 19 | 20 | // Allow dom_id to be overridden 21 | if (options.dom_id) { 22 | this.dom_id = options.dom_id; 23 | delete options.dom_id; 24 | } 25 | 26 | if (!options.supportedSubmitMethods){ 27 | options.supportedSubmitMethods = [ 28 | 'get', 29 | 'put', 30 | 'post', 31 | 'delete', 32 | 'head', 33 | 'options', 34 | 'patch' 35 | ]; 36 | } 37 | 38 | if (typeof options.oauth2RedirectUrl === 'string') { 39 | window.oAuthRedirectUrl = options.redirectUrl; 40 | } 41 | 42 | // Create an empty div which contains the dom_id 43 | if (! $('#' + this.dom_id).length){ 44 | $('body').append('
    ') ; 45 | } 46 | 47 | this.options = options; 48 | 49 | // set marked options 50 | marked.setOptions({gfm: true}); 51 | 52 | // Set the callbacks 53 | var that = this; 54 | this.options.success = function() { return that.render(); }; 55 | this.options.progress = function(d) { return that.showMessage(d); }; 56 | this.options.failure = function(d) { return that.onLoadFailure(d); }; 57 | 58 | // Create view to handle the header inputs 59 | this.headerView = new SwaggerUi.Views.HeaderView({el: $('#header')}); 60 | 61 | // Event handler for when the baseUrl/apiKey is entered by user 62 | this.headerView.on('update-swagger-ui', function(data) { 63 | return that.updateSwaggerUi(data); 64 | }); 65 | }, 66 | 67 | // Set an option after initializing 68 | setOption: function(option, value) { 69 | this.options[option] = value; 70 | }, 71 | 72 | // Get the value of a previously set option 73 | getOption: function(option) { 74 | return this.options[option]; 75 | }, 76 | 77 | // Event handler for when url/key is received from user 78 | updateSwaggerUi: function(data){ 79 | this.options.url = data.url; 80 | this.load(); 81 | }, 82 | 83 | // Create an api and render 84 | load: function(){ 85 | // Initialize the API object 86 | if (this.mainView) { 87 | this.mainView.clear(); 88 | } 89 | var url = this.options.url; 90 | if (url && url.indexOf('http') !== 0) { 91 | url = this.buildUrl(window.location.href.toString(), url); 92 | } 93 | if(this.api) { 94 | this.options.authorizations = this.api.clientAuthorizations.authz; 95 | } 96 | this.options.url = url; 97 | this.headerView.update(url); 98 | 99 | this.api = new SwaggerClient(this.options); 100 | }, 101 | 102 | // collapse all sections 103 | collapseAll: function(){ 104 | Docs.collapseEndpointListForResource(''); 105 | }, 106 | 107 | // list operations for all sections 108 | listAll: function(){ 109 | Docs.collapseOperationsForResource(''); 110 | }, 111 | 112 | // expand operations for all sections 113 | expandAll: function(){ 114 | Docs.expandOperationsForResource(''); 115 | }, 116 | 117 | // This is bound to success handler for SwaggerApi 118 | // so it gets called when SwaggerApi completes loading 119 | render: function(){ 120 | this.showMessage('Finished Loading Resource Information. Rendering Swagger UI...'); 121 | this.mainView = new SwaggerUi.Views.MainView({ 122 | model: this.api, 123 | el: $('#' + this.dom_id), 124 | swaggerOptions: this.options, 125 | router: this 126 | }).render(); 127 | this.showMessage(); 128 | switch (this.options.docExpansion) { 129 | case 'full': 130 | this.expandAll(); break; 131 | case 'list': 132 | this.listAll(); break; 133 | default: 134 | break; 135 | } 136 | this.renderGFM(); 137 | 138 | if (this.options.onComplete){ 139 | this.options.onComplete(this.api, this); 140 | } 141 | 142 | setTimeout(Docs.shebang.bind(this), 100); 143 | }, 144 | 145 | buildUrl: function(base, url){ 146 | if (url.indexOf('/') === 0) { 147 | var parts = base.split('/'); 148 | base = parts[0] + '//' + parts[2]; 149 | return base + url; 150 | } else { 151 | var endOfPath = base.length; 152 | 153 | if (base.indexOf('?') > -1){ 154 | endOfPath = Math.min(endOfPath, base.indexOf('?')); 155 | } 156 | 157 | if (base.indexOf('#') > -1){ 158 | endOfPath = Math.min(endOfPath, base.indexOf('#')); 159 | } 160 | 161 | base = base.substring(0, endOfPath); 162 | 163 | if (base.indexOf('/', base.length - 1 ) !== -1){ 164 | return base + url; 165 | } 166 | 167 | return base + '/' + url; 168 | } 169 | }, 170 | 171 | // Shows message on topbar of the ui 172 | showMessage: function(data){ 173 | if (data === undefined) { 174 | data = ''; 175 | } 176 | var $msgbar = $('#message-bar'); 177 | $msgbar.removeClass('message-fail'); 178 | $msgbar.addClass('message-success'); 179 | $msgbar.html(data); 180 | if(window.SwaggerTranslator) { 181 | window.SwaggerTranslator.translate($msgbar); 182 | } 183 | }, 184 | 185 | // shows message in red 186 | onLoadFailure: function(data){ 187 | if (data === undefined) { 188 | data = ''; 189 | } 190 | $('#message-bar').removeClass('message-success'); 191 | $('#message-bar').addClass('message-fail'); 192 | 193 | var val = $('#message-bar').text(data); 194 | 195 | if (this.options.onFailure) { 196 | this.options.onFailure(data); 197 | } 198 | 199 | return val; 200 | }, 201 | 202 | // Renders GFM for elements with 'markdown' class 203 | renderGFM: function(){ 204 | $('.markdown').each(function(){ 205 | $(this).html(marked($(this).html())); 206 | }); 207 | 208 | $('.propDesc', '.model-signature .description').each(function () { 209 | $(this).html(marked($(this).html())).addClass('markdown'); 210 | }); 211 | } 212 | 213 | }); 214 | 215 | window.SwaggerUi.Views = {}; 216 | 217 | // don't break backward compatibility with previous versions and warn users to upgrade their code 218 | (function(){ 219 | window.authorizations = { 220 | add: function() { 221 | warn('Using window.authorizations is deprecated. Please use SwaggerUi.api.clientAuthorizations.add().'); 222 | 223 | if (typeof window.swaggerUi === 'undefined') { 224 | throw new TypeError('window.swaggerUi is not defined'); 225 | } 226 | 227 | if (window.swaggerUi instanceof SwaggerUi) { 228 | window.swaggerUi.api.clientAuthorizations.add.apply(window.swaggerUi.api.clientAuthorizations, arguments); 229 | } 230 | } 231 | }; 232 | 233 | window.ApiKeyAuthorization = function() { 234 | warn('window.ApiKeyAuthorization is deprecated. Please use SwaggerClient.ApiKeyAuthorization.'); 235 | SwaggerClient.ApiKeyAuthorization.apply(window, arguments); 236 | }; 237 | 238 | window.PasswordAuthorization = function() { 239 | warn('window.PasswordAuthorization is deprecated. Please use SwaggerClient.PasswordAuthorization.'); 240 | SwaggerClient.PasswordAuthorization.apply(window, arguments); 241 | }; 242 | 243 | function warn(message) { 244 | if ('console' in window && typeof window.console.warn === 'function') { 245 | console.warn(message); 246 | } 247 | } 248 | })(); 249 | 250 | 251 | // UMD 252 | (function (root, factory) { 253 | if (typeof define === 'function' && define.amd) { 254 | // AMD. Register as an anonymous module. 255 | define(['b'], function (b) { 256 | return (root.SwaggerUi = factory(b)); 257 | }); 258 | } else if (typeof exports === 'object') { 259 | // Node. Does not work with strict CommonJS, but 260 | // only CommonJS-like environments that support module.exports, 261 | // like Node. 262 | module.exports = factory(require('b')); 263 | } else { 264 | // Browser globals 265 | root.SwaggerUi = factory(root.b); 266 | } 267 | }(this, function () { 268 | return SwaggerUi; 269 | })); 270 | -------------------------------------------------------------------------------- /test/specs/v1.2/petstore/user.json: -------------------------------------------------------------------------------- 1 | { 2 | "apiVersion": "1.0.0", 3 | "swaggerVersion": "1.2", 4 | "basePath": "http://petstore.swagger.io/api", 5 | "resourcePath": "/user", 6 | "produces": [ 7 | "application/json" 8 | ], 9 | "apis": [ 10 | { 11 | "path": "/user", 12 | "operations": [ 13 | { 14 | "method": "POST", 15 | "summary": "Create user", 16 | "notes": "This can only be done by the logged in user.", 17 | "type": "void", 18 | "nickname": "createUser", 19 | "authorizations": { 20 | "oauth2": [ 21 | { 22 | "scope": "test:anything", 23 | "description": "anything" 24 | } 25 | ] 26 | }, 27 | "parameters": [ 28 | { 29 | "name": "body", 30 | "description": "Created user object", 31 | "required": true, 32 | "type": "User", 33 | "paramType": "body" 34 | } 35 | ] 36 | } 37 | ] 38 | }, 39 | { 40 | "path": "/user/logout", 41 | "operations": [ 42 | { 43 | "method": "GET", 44 | "summary": "Logs out current logged in user session", 45 | "notes": "", 46 | "type": "void", 47 | "nickname": "logoutUser", 48 | "authorizations": {}, 49 | "parameters": [] 50 | } 51 | ] 52 | }, 53 | { 54 | "path": "/user/createWithArray", 55 | "operations": [ 56 | { 57 | "method": "POST", 58 | "summary": "Creates list of users with given input array", 59 | "notes": "", 60 | "type": "void", 61 | "nickname": "createUsersWithArrayInput", 62 | "authorizations": { 63 | "oauth2": [ 64 | { 65 | "scope": "test:anything", 66 | "description": "anything" 67 | } 68 | ] 69 | }, 70 | "parameters": [ 71 | { 72 | "name": "body", 73 | "description": "List of user object", 74 | "required": true, 75 | "type": "array", 76 | "items": { 77 | "$ref": "User" 78 | }, 79 | "paramType": "body" 80 | } 81 | ] 82 | } 83 | ] 84 | }, 85 | { 86 | "path": "/user/createWithList", 87 | "operations": [ 88 | { 89 | "method": "POST", 90 | "summary": "Creates list of users with given list input", 91 | "notes": "", 92 | "type": "void", 93 | "nickname": "createUsersWithListInput", 94 | "authorizations": { 95 | "oauth2": [ 96 | { 97 | "scope": "test:anything", 98 | "description": "anything" 99 | } 100 | ] 101 | }, 102 | "parameters": [ 103 | { 104 | "name": "body", 105 | "description": "List of user object", 106 | "required": true, 107 | "type": "array", 108 | "items": { 109 | "$ref": "User" 110 | }, 111 | "paramType": "body" 112 | } 113 | ] 114 | } 115 | ] 116 | }, 117 | { 118 | "path": "/user/{username}", 119 | "operations": [ 120 | { 121 | "method": "PUT", 122 | "summary": "Updated user", 123 | "notes": "This can only be done by the logged in user.", 124 | "type": "void", 125 | "nickname": "updateUser", 126 | "authorizations": { 127 | "oauth2": [ 128 | { 129 | "scope": "test:anything", 130 | "description": "anything" 131 | } 132 | ] 133 | }, 134 | "parameters": [ 135 | { 136 | "name": "username", 137 | "description": "name that need to be deleted", 138 | "required": true, 139 | "type": "string", 140 | "paramType": "path" 141 | }, 142 | { 143 | "name": "body", 144 | "description": "Updated user object", 145 | "required": true, 146 | "type": "User", 147 | "paramType": "body" 148 | } 149 | ], 150 | "responseMessages": [ 151 | { 152 | "code": 400, 153 | "message": "Invalid username supplied" 154 | }, 155 | { 156 | "code": 404, 157 | "message": "User not found" 158 | } 159 | ] 160 | }, 161 | { 162 | "method": "DELETE", 163 | "summary": "Delete user", 164 | "notes": "This can only be done by the logged in user.", 165 | "type": "void", 166 | "nickname": "deleteUser", 167 | "authorizations": { 168 | "oauth2": [ 169 | { 170 | "scope": "test:anything", 171 | "description": "anything" 172 | } 173 | ] 174 | }, 175 | "parameters": [ 176 | { 177 | "name": "username", 178 | "description": "The name that needs to be deleted", 179 | "required": true, 180 | "type": "string", 181 | "paramType": "path" 182 | } 183 | ], 184 | "responseMessages": [ 185 | { 186 | "code": 400, 187 | "message": "Invalid username supplied" 188 | }, 189 | { 190 | "code": 404, 191 | "message": "User not found" 192 | } 193 | ] 194 | }, 195 | { 196 | "method": "GET", 197 | "summary": "Get user by user name", 198 | "notes": "", 199 | "type": "User", 200 | "nickname": "getUserByName", 201 | "authorizations": {}, 202 | "parameters": [ 203 | { 204 | "name": "username", 205 | "description": "The name that needs to be fetched. Use user1 for testing.", 206 | "required": true, 207 | "type": "string", 208 | "paramType": "path" 209 | } 210 | ], 211 | "responseMessages": [ 212 | { 213 | "code": 400, 214 | "message": "Invalid username supplied" 215 | }, 216 | { 217 | "code": 404, 218 | "message": "User not found" 219 | } 220 | ] 221 | } 222 | ] 223 | }, 224 | { 225 | "path": "/user/login", 226 | "operations": [ 227 | { 228 | "method": "GET", 229 | "summary": "Logs user into the system", 230 | "notes": "", 231 | "type": "string", 232 | "nickname": "loginUser", 233 | "authorizations": {}, 234 | "parameters": [ 235 | { 236 | "name": "username", 237 | "description": "The user name for login", 238 | "required": true, 239 | "type": "string", 240 | "paramType": "query" 241 | }, 242 | { 243 | "name": "password", 244 | "description": "The password for login in clear text", 245 | "required": true, 246 | "type": "string", 247 | "paramType": "query" 248 | } 249 | ], 250 | "responseMessages": [ 251 | { 252 | "code": 400, 253 | "message": "Invalid username and password combination" 254 | } 255 | ] 256 | } 257 | ] 258 | } 259 | ], 260 | "models": { 261 | "User": { 262 | "id": "User", 263 | "properties": { 264 | "id": { 265 | "type": "integer", 266 | "format": "int64" 267 | }, 268 | "firstName": { 269 | "type": "string" 270 | }, 271 | "username": { 272 | "type": "string" 273 | }, 274 | "lastName": { 275 | "type": "string" 276 | }, 277 | "email": { 278 | "type": "string" 279 | }, 280 | "password": { 281 | "type": "string" 282 | }, 283 | "phone": { 284 | "type": "string" 285 | }, 286 | "userStatus": { 287 | "type": "integer", 288 | "format": "int32", 289 | "description": "User Status", 290 | "enum": [ 291 | "1-registered", 292 | "2-active", 293 | "3-closed" 294 | ] 295 | } 296 | } 297 | } 298 | } 299 | } -------------------------------------------------------------------------------- /lib/swagger-oauth.js: -------------------------------------------------------------------------------- 1 | var appName; 2 | var popupMask; 3 | var popupDialog; 4 | var clientId; 5 | var realm; 6 | var oauth2KeyName; 7 | var redirect_uri; 8 | var clientSecret; 9 | var scopeSeparator; 10 | 11 | function handleLogin() { 12 | var scopes = []; 13 | 14 | var auths = window.swaggerUi.api.authSchemes || window.swaggerUi.api.securityDefinitions; 15 | if(auths) { 16 | var key; 17 | var defs = auths; 18 | for(key in defs) { 19 | var auth = defs[key]; 20 | if(auth.type === 'oauth2' && auth.scopes) { 21 | oauth2KeyName = key; 22 | var scope; 23 | if(Array.isArray(auth.scopes)) { 24 | // 1.2 support 25 | var i; 26 | for(i = 0; i < auth.scopes.length; i++) { 27 | scopes.push(auth.scopes[i]); 28 | } 29 | } 30 | else { 31 | // 2.0 support 32 | for(scope in auth.scopes) { 33 | scopes.push({scope: scope, description: auth.scopes[scope]}); 34 | } 35 | } 36 | } 37 | } 38 | } 39 | 40 | if(window.swaggerUi.api 41 | && window.swaggerUi.api.info) { 42 | appName = window.swaggerUi.api.info.title; 43 | } 44 | 45 | $('.api-popup-dialog').remove(); 46 | popupDialog = $( 47 | [ 48 | '
    ', 49 | '
    Select OAuth2.0 Scopes
    ', 50 | '
    ', 51 | '

    Scopes are used to grant an application different levels of access to data on behalf of the end user. Each API may declare one or more scopes.', 52 | 'Learn how to use', 53 | '

    ', 54 | '

    ' + appName + ' API requires the following scopes. Select which ones you want to grant to Swagger UI.

    ', 55 | '
      ', 56 | '
    ', 57 | '

    ', 58 | '
    ', 59 | '
    ', 60 | '
    '].join('')); 61 | $(document.body).append(popupDialog); 62 | 63 | popup = popupDialog.find('ul.api-popup-scopes').empty(); 64 | for (i = 0; i < scopes.length; i ++) { 65 | scope = scopes[i]; 66 | str = '
  • ' + '
  • '; 71 | popup.append(str); 72 | } 73 | 74 | var $win = $(window), 75 | dw = $win.width(), 76 | dh = $win.height(), 77 | st = $win.scrollTop(), 78 | dlgWd = popupDialog.outerWidth(), 79 | dlgHt = popupDialog.outerHeight(), 80 | top = (dh -dlgHt)/2 + st, 81 | left = (dw - dlgWd)/2; 82 | 83 | popupDialog.css({ 84 | top: (top < 0? 0 : top) + 'px', 85 | left: (left < 0? 0 : left) + 'px' 86 | }); 87 | 88 | popupDialog.find('button.api-popup-cancel').click(function() { 89 | popupMask.hide(); 90 | popupDialog.hide(); 91 | popupDialog.empty(); 92 | popupDialog = []; 93 | }); 94 | 95 | $('button.api-popup-authbtn').unbind(); 96 | popupDialog.find('button.api-popup-authbtn').click(function() { 97 | popupMask.hide(); 98 | popupDialog.hide(); 99 | 100 | var authSchemes = window.swaggerUi.api.authSchemes; 101 | var host = window.location; 102 | var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/")); 103 | var defaultRedirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html'; 104 | var redirectUrl = window.oAuthRedirectUrl || defaultRedirectUrl; 105 | var url = null; 106 | 107 | for (var key in authSchemes) { 108 | if (authSchemes.hasOwnProperty(key)) { 109 | var flow = authSchemes[key].flow; 110 | 111 | if(authSchemes[key].type === 'oauth2' && flow && (flow === 'implicit' || flow === 'accessCode')) { 112 | var dets = authSchemes[key]; 113 | url = dets.authorizationUrl + '?response_type=' + (flow === 'implicit' ? 'token' : 'code'); 114 | window.swaggerUi.tokenName = dets.tokenName || 'access_token'; 115 | window.swaggerUi.tokenUrl = (flow === 'accessCode' ? dets.tokenUrl : null); 116 | } 117 | else if(authSchemes[key].grantTypes) { 118 | // 1.2 support 119 | var o = authSchemes[key].grantTypes; 120 | for(var t in o) { 121 | if(o.hasOwnProperty(t) && t === 'implicit') { 122 | var dets = o[t]; 123 | var ep = dets.loginEndpoint.url; 124 | url = dets.loginEndpoint.url + '?response_type=token'; 125 | window.swaggerUi.tokenName = dets.tokenName; 126 | } 127 | else if (o.hasOwnProperty(t) && t === 'accessCode') { 128 | var dets = o[t]; 129 | var ep = dets.tokenRequestEndpoint.url; 130 | url = dets.tokenRequestEndpoint.url + '?response_type=code'; 131 | window.swaggerUi.tokenName = dets.tokenName; 132 | } 133 | } 134 | } 135 | } 136 | } 137 | var scopes = [] 138 | var o = $('.api-popup-scopes').find('input:checked'); 139 | 140 | for(k =0; k < o.length; k++) { 141 | var scope = $(o[k]).attr('scope'); 142 | 143 | if (scopes.indexOf(scope) === -1) 144 | scopes.push(scope); 145 | } 146 | 147 | // Implicit auth recommends a state parameter. 148 | var state = Math.random (); 149 | 150 | window.enabledScopes=scopes; 151 | 152 | redirect_uri = redirectUrl; 153 | 154 | url += '&redirect_uri=' + encodeURIComponent(redirectUrl); 155 | url += '&realm=' + encodeURIComponent(realm); 156 | url += '&client_id=' + encodeURIComponent(clientId); 157 | url += '&scope=' + encodeURIComponent(scopes.join(scopeSeparator)); 158 | url += '&state=' + encodeURIComponent(state); 159 | 160 | window.open(url); 161 | }); 162 | 163 | popupMask.show(); 164 | popupDialog.show(); 165 | return; 166 | } 167 | 168 | 169 | function handleLogout() { 170 | for(key in window.swaggerUi.api.clientAuthorizations.authz){ 171 | window.swaggerUi.api.clientAuthorizations.remove(key) 172 | } 173 | window.enabledScopes = null; 174 | $('.api-ic.ic-on').addClass('ic-off'); 175 | $('.api-ic.ic-on').removeClass('ic-on'); 176 | 177 | // set the info box 178 | $('.api-ic.ic-warning').addClass('ic-error'); 179 | $('.api-ic.ic-warning').removeClass('ic-warning'); 180 | } 181 | 182 | function initOAuth(opts) { 183 | var o = (opts||{}); 184 | var errors = []; 185 | 186 | appName = (o.appName||errors.push('missing appName')); 187 | popupMask = (o.popupMask||$('#api-common-mask')); 188 | popupDialog = (o.popupDialog||$('.api-popup-dialog')); 189 | clientId = (o.clientId||errors.push('missing client id')); 190 | clientSecret = (o.clientSecret||null); 191 | realm = (o.realm||errors.push('missing realm')); 192 | scopeSeparator = (o.scopeSeparator||' '); 193 | 194 | if(errors.length > 0){ 195 | log('auth unable initialize oauth: ' + errors); 196 | return; 197 | } 198 | 199 | $('pre code').each(function(i, e) {hljs.highlightBlock(e)}); 200 | $('.api-ic').unbind(); 201 | $('.api-ic').click(function(s) { 202 | if($(s.target).hasClass('ic-off')) 203 | handleLogin(); 204 | else { 205 | handleLogout(); 206 | } 207 | false; 208 | }); 209 | } 210 | 211 | window.processOAuthCode = function processOAuthCode(data) { 212 | var params = { 213 | 'client_id': clientId, 214 | 'code': data.code, 215 | 'grant_type': 'authorization_code', 216 | 'redirect_uri': redirect_uri 217 | }; 218 | 219 | if (clientSecret) { 220 | params.client_secret = clientSecret; 221 | } 222 | 223 | $.ajax( 224 | { 225 | url : window.swaggerUi.tokenUrl, 226 | type: "POST", 227 | data: params, 228 | success:function(data, textStatus, jqXHR) 229 | { 230 | onOAuthComplete(data); 231 | }, 232 | error: function(jqXHR, textStatus, errorThrown) 233 | { 234 | onOAuthComplete(""); 235 | } 236 | }); 237 | }; 238 | 239 | window.onOAuthComplete = function onOAuthComplete(token) { 240 | if(token) { 241 | if(token.error) { 242 | var checkbox = $('input[type=checkbox],.secured') 243 | checkbox.each(function(pos){ 244 | checkbox[pos].checked = false; 245 | }); 246 | alert(token.error); 247 | } 248 | else { 249 | var b = token[window.swaggerUi.tokenName]; 250 | if(b){ 251 | // if all roles are satisfied 252 | var o = null; 253 | $.each($('.auth .api-ic .api_information_panel'), function(k, v) { 254 | var children = v; 255 | if(children && children.childNodes) { 256 | var requiredScopes = []; 257 | $.each((children.childNodes), function (k1, v1){ 258 | var inner = v1.innerHTML; 259 | if(inner) 260 | requiredScopes.push(inner); 261 | }); 262 | var diff = []; 263 | for(var i=0; i < requiredScopes.length; i++) { 264 | var s = requiredScopes[i]; 265 | if(window.enabledScopes && window.enabledScopes.indexOf(s) == -1) { 266 | diff.push(s); 267 | } 268 | } 269 | if(diff.length > 0){ 270 | o = v.parentNode.parentNode; 271 | $(o.parentNode).find('.api-ic.ic-on').addClass('ic-off'); 272 | $(o.parentNode).find('.api-ic.ic-on').removeClass('ic-on'); 273 | 274 | // sorry, not all scopes are satisfied 275 | $(o).find('.api-ic').addClass('ic-warning'); 276 | $(o).find('.api-ic').removeClass('ic-error'); 277 | } 278 | else { 279 | o = v.parentNode.parentNode; 280 | $(o.parentNode).find('.api-ic.ic-off').addClass('ic-on'); 281 | $(o.parentNode).find('.api-ic.ic-off').removeClass('ic-off'); 282 | 283 | // all scopes are satisfied 284 | $(o).find('.api-ic').addClass('ic-info'); 285 | $(o).find('.api-ic').removeClass('ic-warning'); 286 | $(o).find('.api-ic').removeClass('ic-error'); 287 | } 288 | } 289 | }); 290 | window.swaggerUi.api.clientAuthorizations.add(oauth2KeyName, new SwaggerClient.ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header')); 291 | } 292 | } 293 | } 294 | }; 295 | --------------------------------------------------------------------------------