├── 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 |
--------------------------------------------------------------------------------
/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 |
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 |
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 |
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(/
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 |