Compare commits

...
105 Commits
Author SHA1 Message Date
Tony Tam 8831e289c0 updated versions 2014-11-11 00:17:02 -08:00
Tony Tam 329772af4c merged from auth_2.0 branch 2014-11-11 00:16:13 -08:00
Tony Tam 8e20a32344 updated js libs 2014-11-10 23:19:14 -08:00
Tony Tam d1d2bc75db rebuilt lib 2014-11-03 22:53:14 -08:00
Tony Tam 7457b2027d smarter content type detection 2014-11-03 22:52:17 -08:00
Tony Tam 22c7a9672c updated from swagger-js 2014-10-30 07:59:02 -07:00
Tony Tam 9bdc758147 Merge branch 'master' of github.com:swagger-api/swagger-ui 2014-10-30 07:54:09 -07:00
Tony Tam 23562cecd0 added back exports 2014-10-30 07:53:10 -07:00
Tony Tam 424dde251e Merge pull request #692 from whitlockjc/fix-678
Do not create operations for non-HTTP methods/verbs
2014-10-28 09:36:22 -07:00
Jeremy Whitlock 295fa75dc4 Do not create operations for non-HTTP methods/verbs
Fixes #678
2014-10-28 09:49:03 -06:00
Tony Tam cdd02ad8a3 Update README.md
removed per #688
2014-10-25 13:32:33 -07:00
Tony Tam aefd35237c updated for auth 2014-10-25 11:33:04 -07:00
Tony Tam 73f02aa182 minor formatting 2014-10-25 11:27:40 -07:00
Tony Tam 799069640b removed validator for 1.2 specs 2014-10-23 00:09:14 -07:00
Tony Tam 38112e3cd0 whitespace 2014-10-22 17:28:08 -07:00
Tony Tam 918bd9eedb updated readme 2014-10-22 17:26:57 -07:00
Tony Tam 2d0b3262f3 updated index 2014-10-20 07:28:45 -07:00
Tony Tam 97d23f61de fix for https://github.com/wordnik/swagger-ui/issues/644, verify path object by type 2014-10-20 07:27:06 -07:00
Tony Tam 187dacd8e4 Merge branch 'master' of github.com:wordnik/swagger-ui 2014-10-18 17:39:02 -07:00
Tony Tam 9ba4c38783 updated swagger-js for https://github.com/wordnik/swagger-js/issues/151 2014-10-18 17:38:25 -07:00
Tony Tam 32df32da8e Update README.md 2014-10-18 17:14:35 -07:00
Tony Tam de0f9d58ee updated build 2014-10-18 16:08:01 -07:00
Tony Tam bc38d35aea updated js client 2014-10-18 16:07:22 -07:00
Tony Tam 1738bf1272 fix for #663 2014-10-18 15:57:09 -07:00
Tony Tam 4d1e48df39 updated client per #669 2014-10-18 15:25:28 -07:00
Tony Tam dc84dfc8f8 updated js client 2014-10-17 15:26:05 -07:00
Tony Tam d16b149f39 fix for #632, param names other than 2014-10-17 08:52:44 -07:00
Tony Tam c6fb33a9c7 added support for body params with name other than 2014-10-17 08:51:15 -07:00
Tony Tam b0301d6ee3 rebuilt with deprecate support, https://github.com/wordnik/swagger-ui/pull/645 2014-10-17 06:23:33 -07:00
Tony Tam 97efb054bf Merge pull request #645 from callenx/addDeprecated
Adding deprecated indicator to operations
2014-10-17 06:22:34 -07:00
Tony Tam f882750e5c merged from https://github.com/wordnik/swagger-ui/pull/642 2014-10-17 06:21:00 -07:00
Tony Tam 7957201b61 updated version for publish 2014-10-16 09:10:02 -07:00
Tony Tam 52f55054ed updated swagger-js library 2014-10-16 09:09:22 -07:00
Tony Tam 6b448c1fae Merge branch 'master' of github.com:wordnik/swagger-ui 2014-10-16 02:03:07 -07:00
Tony Tam 559221de56 updated version check, multi support for 2.0 2014-10-16 02:02:56 -07:00
Tony Tam 2bedc01807 Update README.md 2014-10-07 21:15:49 -07:00
Tony Tam e52f83b501 updated version to alpha tag 2014-10-06 13:03:22 -07:00
Chris Allen 20c555306f Adding deprecated indicator to operations 2014-10-03 16:52:44 -07:00
Tony Tam 03dd9fb7f4 fix for header undefined 2014-10-02 23:39:21 -07:00
Tony Tam a4a6c6191b Merge branch 'master' of github.com:wordnik/swagger-ui 2014-10-02 15:29:33 -07:00
Tony Tam 4d2ad25a10 added check for schema 2014-10-02 15:29:26 -07:00
Tony Tam 23fe6d337b Merge pull request #639 from edmondchui/master
Show response for 20x as default if response 200 is not present
2014-10-02 15:19:34 -07:00
Edmond Chui 841acc6db0 Fix swagger-ui issue#637 [https://github.com/wordnik/swagger-ui/issues/637] to show response for 20x as default if response 200 is not present. 2014-10-02 15:13:35 -07:00
Tony Tam 5823358e73 fix for #626, added support for (default || defaultValue) 2014-09-29 22:35:30 -07:00
Tony Tam a39ab425bf undid double stringify 2014-09-28 20:23:04 -07:00
Tony Tam b0eff2d78b added exception handling, updated client 2014-09-28 20:19:17 -07:00
Tony Tam 1eac80abdd formatting 2014-09-28 19:26:59 -07:00
Tony Tam 162ec41fcc Merge branch 'master' of github.com:wordnik/swagger-ui 2014-09-27 22:59:27 -07:00
Tony Tam cbead84f8e updated library 2014-09-27 22:59:19 -07:00
Tony Tam 25c4ab4d5e Merge pull request #619 from miniharryc/master
Update README.md
2014-09-26 13:23:49 -07:00
Harold Combs db28e8b6db Update README.md
Fixed a couple of typos
2014-09-26 16:19:10 -04:00
Tony Tam b7a452eca3 fix for #605, create default tag group 2014-09-26 09:52:27 -07:00
Tony Tam 4e15e9a068 added key listener 2014-09-25 21:44:23 -07:00
Tony Tam b9e79d6824 Merge pull request #594 from alexagranov/master
pull out onChange handler for #input_apiKey so it can be called manually
2014-09-25 21:39:24 -07:00
Tony Tam 1842c41b10 Merge pull request #613 from wordnik/develop_2.0
Sync `develop_2.0` branch back to `master`
2014-09-25 21:38:28 -07:00
Tony Tam 607cca6229 fix for #612 2014-09-25 21:32:55 -07:00
Tony Tam d3f373c188 fixed version 2014-09-25 21:28:34 -07:00
Tony Tam 8918fa1c24 added validator for v2 2014-09-25 21:23:05 -07:00
Tony Tam 3492c72024 added logic for link 2014-09-25 21:02:31 -07:00
Tony Tam 0209cdd42b updated lib 2014-09-25 06:04:18 -04:00
Tony Tam af6eed4eb4 fix for #606, renamed resource to in the template 2014-09-23 10:00:03 -07:00
Tony Tam 2eabeb667a updated client, converted newlines to br in description 2014-09-23 01:26:18 -07:00
Tony Tam d838073389 updated libraries 2014-09-23 00:57:04 -07:00
Tony Tam 922848b195 fix for #602 2014-09-23 00:54:14 -07:00
Tony Tam da661827bf fix for #596 2014-09-22 21:55:48 -07:00
Tony Tam 82e9ceaca6 rebuilt distro 2014-09-20 21:21:13 -07:00
Tony Tam 0cabc3017b updated client to enable auth #588 2014-09-20 21:21:04 -07:00
Tony Tam fedb12960b added null check 2014-09-20 21:20:15 -07:00
Tony Tam 8258d8b4d9 added null check 2014-09-20 21:20:04 -07:00
Tony Tam b9d6f388e9 Merge pull request #589 from davidcole/escape_returned_html
Escape returned HTML
2014-09-20 13:45:20 -07:00
Tony Tam 2edfb5ef0c Merge pull request #591 from johnkchiu/develop_2.0
Fixing tags check for undefined.
2014-09-20 09:18:32 -07:00
Tony Tam 35aac47df3 Merge pull request #584 from KnisterPeter/master
Use initial url parameter if given, else fallback to petstore example
2014-09-20 09:09:10 -07:00
Alex Agranov 19c34cf1ea tidy up the commenting 2014-09-19 18:18:57 -04:00
Alex Agranov ad3e9e5481 pull out onChange handler for #input_apiKey so it can be called manually 2014-09-19 18:14:28 -04:00
Tony Tam 3a43a4cd91 Merge branch 'master' of github.com:wordnik/swagger-ui 2014-09-19 11:35:45 -07:00
Tony Tam a0f398853a fix for #592, added http method 2014-09-19 11:35:37 -07:00
John Chiu 5bdc109746 Fixing tags check for undefined. 2014-09-19 11:13:46 -07:00
David Cole 252100b704 Escape returned HTML. 2014-09-19 13:44:45 -04:00
Markus Wolf 55a5abb9c7 Use initial url parameter if given, else fallback to petstore example 2014-09-19 10:55:17 +02:00
Tony Tam d9f13e9163 Update package.json 2014-09-18 23:03:27 -07:00
Tony Tam 7570e85389 updated link 2014-09-18 21:27:47 -07:00
Tony Tam e7b803b018 updated link 2014-09-18 21:27:13 -07:00
Tony Tam a26651a3bd updated versions 2014-09-18 21:26:12 -07:00
Tony Tam 6675568d09 merged from develop 2014-09-18 21:26:04 -07:00
Tony Tam bd354103f1 merged from develop 2014-09-18 21:12:30 -07:00
Tony Tam c0b11e4719 updated links 2014-09-18 21:09:22 -07:00
Tony Tam 4e508c0a1e updated link 2014-09-18 21:04:24 -07:00
Tony Tam b9c631e09e merged from master 2014-09-18 19:40:33 -07:00
Tony Tam 4ad4b499ee fix for license structure change 2014-09-18 09:29:52 -07:00
Tony Tam 26734d711e added compatibility table 2014-09-18 09:14:43 -07:00
Tony Tam ba14498fbd added links to readme 2014-09-18 09:11:21 -07:00
Tony Tam 390c8c8408 added links to readme 2014-09-18 09:04:21 -07:00
Tony Tam bc4f60a955 added links to readme 2014-09-18 08:28:37 -07:00
Tony Tam 88118bfc32 updated readme, resource to remove url if not present 2014-09-18 08:24:32 -07:00
Tony Tam b653a9909b updated readme, resource to remove url if not present 2014-09-18 08:24:17 -07:00
Tony Tam 91822035ef added response check for swagger 2.0/1.2 client 2014-09-16 17:40:33 -07:00
Tony Tam 394afba3e5 fix for #570, sanitized tag names 2014-09-15 17:37:50 -07:00
Tony Tam b2096eb21b removed stubs 2014-09-15 17:37:22 -07:00
Tony Tam 0c44f83c26 updated swagger lib 2014-09-15 17:36:28 -07:00
Tony Tam 674b288fe6 Merge pull request #572 from dblock/handlebars-from-npm
Use handlebars installed from npm.
2014-09-15 16:17:10 -07:00
dblock 0cdcbfb70b Use handlebars from npm. 2014-09-15 18:58:08 -04:00
Tony Tam 0395bf3eb3 updated swagger-js 2014-09-14 14:06:31 -07:00
Tony Tam 66718f23dd updates to develop branch 2014-09-12 16:09:42 -07:00
Tony Tam 963c009870 added 2.0 client 2014-09-11 15:39:09 -07:00
Tony Tam bdec07e8c3 updated files 2014-09-07 17:12:03 -07:00
31 changed files with 7169 additions and 3490 deletions
+13 -11
View File
@@ -2,6 +2,7 @@ fs = require 'fs'
path = require 'path'
{exec} = require 'child_process'
less = require 'less'
handlebars = require 'handlebars'
sourceFiles = [
'SwaggerUi'
@@ -15,6 +16,8 @@ sourceFiles = [
'view/ContentTypeView'
'view/ResponseContentTypeView'
'view/ParameterContentTypeView'
'view/ApiKeyButton'
'view/BasicAuthButton'
]
@@ -41,18 +44,17 @@ task 'dist', 'Build a distribution', ->
templateContents = new Array remaining = templateFiles.length
for file, index in templateFiles then do (file, index) ->
console.log " : Compiling src/main/template/#{file}"
exec "handlebars src/main/template/#{file} -f dist/_#{file}.js", (err, stdout, stderr) ->
fs.readFile "src/main/template/#{file}", 'utf8', (err, source) ->
throw err if err
fs.readFile 'dist/_' + file + '.js', 'utf8', (err, fileContents) ->
throw err if err
templateContents[index] = fileContents
fs.unlink 'dist/_' + file + '.js'
if --remaining is 0
templateContents.push '\n\n'
fs.writeFile 'dist/_swagger-ui-templates.js', templateContents.join('\n\n'), 'utf8', (err) ->
throw err if err
build()
compiled = handlebars.precompile(source)
templateContents[index] = '(function() {\n var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};\ntemplates[\'' + file.replace('.handlebars', '') + '\'] = template(' + compiled + ');\n})();'
fs.unlink 'dist/_' + file + '.js', (err) ->
console.log "#{err.code}: #{err.path}" unless err.code == 'ENOENT'
if --remaining is 0
templateContents.push '\n\n'
fs.writeFile 'dist/_swagger-ui-templates.js', templateContents.join('\n\n'), 'utf8', (err) ->
throw err if err
build()
build = ->
console.log ' : Collecting Coffeescript source...'
+21 -13
View File
@@ -1,6 +1,5 @@
# Swagger UI
Swagger UI is part of Swagger project. The Swagger project allows you to produce, visualize and consume your OWN RESTful services. No proxy or 3rd party services required. Do it your own way.
Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically
@@ -8,12 +7,22 @@ generate beautiful documentation and sandbox from a Swagger-compliant API. Becau
## What's Swagger?
The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swager removes the guesswork in calling the service.
The goal of Swagger™ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swagger removes the guesswork in calling the service.
Check out [Swagger-Spec](https://github.com/wordnik/swagger-spec) for additional information about the Swagger project, including additional libraries with support for other languages and more.
Check out [Swagger-Spec](https://github.com/swagger-api/swagger-spec) for additional information about the Swagger project, including additional libraries with support for other languages and more.
## Compatability
The Swagger Specification has undergone 3 revisions since initial creation in 2010. The swagger-ui project has the following compatibilies with the swagger specification:
Swagger UI Version | Release Date | Swagger Spec compatability | Notes | Status
------------------ | ------------ | -------------------------- | ----- | ------
2.1.0-alpha.1 (in development) | 2014-10-06 | 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-ui/tree/master) | [Issues](https://github.com/swagger-api/swagger-ui/milestones/v2.1.0)
2.0.24 | 2014-09-12 | 1.1, 1.2 | [tag v2.0.24](https://github.com/swagger-api/swagger-ui/tree/v2.0.24) |
1.0.13 | 2013-03-08 | 1.1, 1.2 | [tag v1.0.13](https://github.com/swagger-api/swagger-ui/tree/v1.0.13) |
1.0.1 | 2011-10-11 | 1.0, 1.1 | [tag v1.0.1](https://github.com/swagger-api/swagger-ui/tree/v1.0.1) |
## How to Use It
### Download
@@ -23,10 +32,9 @@ You can use the swagger-ui code AS-IS! No need to build or recompile--just clon
You can rebuild swagger-ui on your own to tweak it or just so you can say you did. To do so, follow these steps:
1. install [handlebars](http://handlebarsjs.com/)
2. install java
3. npm install
4. npm run-script build
5. You should see the distribution under the dist folder. Open ./dist/index.html to launch Swagger UI in a browser
2. npm install
3. npm run-script build
4. You should see the distribution under the dist folder. Open ./dist/index.html to launch Swagger UI in a browser
### Use
Once you open the Swagger UI, it will load the [Swagger Petstore](http://petstore.swagger.wordnik.com/api/api-docs) service and show its APIs. You can enter your own server url and click explore to view the API.
@@ -45,7 +53,7 @@ You may choose to customize Swagger UI for your organization. Here is an overvie
- src/main/javascript: some legacy javascript referenced by CoffeeScript code
### SwaggerUi
To use swagger-ui you should take a look at the [source of swagger-ui html page](https://github.com/wordnik/swagger-ui/tree/master/src/main/html) and customize it. This basically requires you to instantiate a SwaggerUi object and call load() on it as below:
To use swagger-ui you should take a look at the [source of swagger-ui html page](https://github.com/swagger-api/swagger-ui/tree/master/src/main/html) and customize it. This basically requires you to instantiate a SwaggerUi object and call load() on it as below:
```javascript
window.swaggerUi = new SwaggerUi({
@@ -55,7 +63,7 @@ To use swagger-ui you should take a look at the [source of swagger-ui html page]
window.swaggerUi.load();
```
* *url* parameter should point to a resource listing url as per [Swagger Spec](https://github.com/wordnik/swagger-core/wiki)
* *url* parameter should point to a resource listing url as per [Swagger Spec](https://github.com/swagger-api/swagger-spec/)
* *dom_id parameter* is the the id of a dom element inside which SwaggerUi will put the user interface for swagger
* *booleanValues* SwaggerUI renders boolean data types as a dropdown. By default it provides a 'true' and 'false' string as the possible choices. You can use this parameter to change the values in dropdown to be something else, for example 0 and 1 by setting booleanValues to new Array(0, 1)
* *docExpansion* controls how the API listing is displayed. It can be set to 'none' (default), 'list' (shows operations for each resource), or 'full' (fully expanded: shows operations and their details)
@@ -67,11 +75,11 @@ To use swagger-ui you should take a look at the [source of swagger-ui html page]
### HTTP Methods and API Invocation
swagger-ui supports invocation of all HTTP methods APIs including GET, PUT, POST, DELETE, PATCH, OPTIONS. These are handled in the [swagger-js](https://github.com/wordnik/swagger-js) project, please see there for specifics on their usage.
swagger-ui supports invocation of all HTTP methods APIs including GET, PUT, POST, DELETE, PATCH, OPTIONS. These are handled in the [swagger-js](https://github.com/swagger-api/swagger-js) project, please see there for specifics on their usage.
### Header Parameters
Header params are supported through a pluggable mechanism in [swagger-js](https://github.com/wordnik/swagger-js). You can see the [index.html](https://github.com/wordnik/swagger-ui/blob/master/dist/index.html) for a sample of how to dynamically set headers:
Header params are supported through a pluggable mechanism in [swagger-js](https://github.com/swagger-api/swagger-js). You can see the [index.html](https://github.com/swagger-api/swagger-ui/blob/master/dist/index.html) for a sample of how to dynamically set headers:
```js
// add a new ApiKeyAuthorization when the api-key changes in the ui.
@@ -96,9 +104,9 @@ Note! You can pass multiple header params on a single request, just use unique
## How to Improve It
Create your own fork of [wordnik/swagger-ui](https://github.com/wordnik/swagger-ui)
Create your own fork of [wordnik/swagger-ui](https://github.com/swagger-api/swagger-ui)
To share your changes, [submit a pull request](https://github.com/wordnik/swagger-ui/pull/new/master).
To share your changes, [submit a pull request](https://github.com/swagger-api/swagger-ui/pull/new/master).
Since the javascript files are compiled from coffeescript, please submit changes in the *.coffee files! We have to reject changes only in the .js files as they will be lost on each build of the ui.
+53 -36
View File
@@ -16,50 +16,67 @@
<script src='lib/underscore-min.js' type='text/javascript'></script>
<script src='lib/backbone-min.js' type='text/javascript'></script>
<script src='lib/swagger.js' type='text/javascript'></script>
<script src='lib/swagger-client.js' type='text/javascript'></script>
<script src='swagger-ui.js' type='text/javascript'></script>
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
<!-- enabling this will enable oauth2 implicit scope support -->
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
<script type="text/javascript">
$(function () {
window.swaggerUi = new SwaggerUi({
url: "http://petstore.swagger.wordnik.com/api/api-docs",
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
onComplete: function(swaggerApi, swaggerUi){
log("Loaded SwaggerUI");
if(typeof initOAuth == "function") {
/*
initOAuth({
clientId: "your-client-id",
realm: "your-realms",
appName: "your-app-name"
});
*/
}
$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
sorter : "alpha"
});
$('#input_apiKey').change(function() {
var key = $('#input_apiKey')[0].value;
log("key: " + key);
if(key && key.trim() != "") {
log("added key " + key);
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
var url = window.location.search.match(/url=([^&]+)/);
if (url && url.length > 1) {
url = url[1];
} else {
url = "http://petstore.swagger.wordnik.com/v2/swagger.json";
}
})
window.swaggerUi.load();
window.swaggerUi = new SwaggerUi({
url: url,
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
onComplete: function(swaggerApi, swaggerUi){
log("Loaded SwaggerUI");
if(typeof initOAuth == "function") {
/*
initOAuth({
clientId: "your-client-id",
realm: "your-realms",
appName: "your-app-name"
});
*/
}
$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
sorter : "alpha"
});
function addApiKeyAuthorization() {
var key = $('#input_apiKey')[0].value;
log("key: " + key);
if(key && key.trim() != "") {
log("added key " + key);
window.authorizations.add("api_key", new ApiKeyAuthorization("api_key", key, "query"));
}
}
$('#input_apiKey').change(function() {
addApiKeyAuthorization();
});
// if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
/*
var apiKey = "myApiKeyXXXX123456789";
$('#input_apiKey').val(apiKey);
addApiKeyAuthorization();
*/
window.swaggerUi.load();
});
</script>
</head>
+3 -3
View File
@@ -2131,10 +2131,10 @@ require.define("/shred/mixins/headers.js", function (require, module, exports, _
// to `Content-Type`.
var corsetCase = function(string) {
return string.toLowerCase()
return string;//.toLowerCase()
//.replace("_","-")
.replace(/(^|-)(\w)/g,
function(s) { return s.toUpperCase(); });
// .replace(/(^|-)(\w)/g,
// function(s) { return s.toUpperCase(); });
};
// We suspect that `initializeHeaders` was once more complicated ...
+1489
View File
File diff suppressed because it is too large Load Diff
+72 -46
View File
@@ -7,10 +7,29 @@ var realm;
function handleLogin() {
var scopes = [];
if(window.swaggerUi.api.authSchemes
&& window.swaggerUi.api.authSchemes.oauth2
&& window.swaggerUi.api.authSchemes.oauth2.scopes) {
scopes = window.swaggerUi.api.authSchemes.oauth2.scopes;
var auths = window.swaggerUi.api.authSchemes || window.swaggerUi.api.securityDefinitions;
if(auths) {
var key;
var defs = auths;
for(key in defs) {
var auth = defs[key];
if(auth.type === 'oauth2' && auth.scopes) {
var scope;
if(Array.isArray(auth.scopes)) {
// 1.2 support
var i;
for(i = 0; i < auth.scopes.length; i++) {
scopes.push(auth.scopes[i]);
}
}
else {
// 2.0 support
for(scope in auth.scopes) {
scopes.push({scope: scope, description: auth.scopes[scope]});
}
}
}
}
}
if(window.swaggerUi.api
@@ -18,36 +37,32 @@ function handleLogin() {
appName = window.swaggerUi.api.info.title;
}
if(popupDialog.length > 0)
popupDialog = popupDialog.last();
else {
popupDialog = $(
[
'<div class="api-popup-dialog">',
'<div class="api-popup-title">Select OAuth2.0 Scopes</div>',
'<div class="api-popup-content">',
'<p>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.',
'<a href="#">Learn how to use</a>',
'</p>',
'<p><strong>' + appName + '</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI.</p>',
'<ul class="api-popup-scopes">',
'</ul>',
'<p class="error-msg"></p>',
'<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button">Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>',
'</div>',
'</div>'].join(''));
$(document.body).append(popupDialog);
popupDialog = $(
[
'<div class="api-popup-dialog">',
'<div class="api-popup-title">Select OAuth2.0 Scopes</div>',
'<div class="api-popup-content">',
'<p>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.',
'<a href="#">Learn how to use</a>',
'</p>',
'<p><strong>' + appName + '</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI.</p>',
'<ul class="api-popup-scopes">',
'</ul>',
'<p class="error-msg"></p>',
'<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button">Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>',
'</div>',
'</div>'].join(''));
$(document.body).append(popupDialog);
popup = popupDialog.find('ul.api-popup-scopes').empty();
for (i = 0; i < scopes.length; i ++) {
scope = scopes[i];
str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"/>' + '<label for="scope_' + i + '">' + scope.scope;
if (scope.description) {
str += '<br/><span class="api-scope-desc">' + scope.description + '</span>';
}
str += '</label></li>';
popup.append(str);
popup = popupDialog.find('ul.api-popup-scopes').empty();
for (i = 0; i < scopes.length; i ++) {
scope = scopes[i];
str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"/>' + '<label for="scope_' + i + '">' + scope.scope;
if (scope.description) {
str += '<br/><span class="api-scope-desc">' + scope.description + '</span>';
}
str += '</label></li>';
popup.append(str);
}
var $win = $(window),
@@ -67,7 +82,10 @@ function handleLogin() {
popupDialog.find('button.api-popup-cancel').click(function() {
popupMask.hide();
popupDialog.hide();
popupDialog.empty();
popupDialog = [];
});
popupDialog.find('button.api-popup-authbtn').click(function() {
popupMask.hide();
popupDialog.hide();
@@ -75,17 +93,26 @@ function handleLogin() {
var authSchemes = window.swaggerUi.api.authSchemes;
var host = window.location;
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
var redirectUrl = host.protocol + '//' + host.host + pathname + "/o2c.html";
var redirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html';
var url = null;
for (var key in authSchemes) {
if (authSchemes.hasOwnProperty(key)) {
var o = authSchemes[key].grantTypes;
for(var t in o) {
if(o.hasOwnProperty(t) && t === 'implicit') {
var dets = o[t];
url = dets.loginEndpoint.url + "?response_type=token";
window.swaggerUi.tokenName = dets.tokenName;
if(authSchemes[key].type === 'oauth2' && authSchemes[key].flow === 'implicit') {
var dets = authSchemes[key];
url = dets.authorizationUrl + '?response_type=token';
window.swaggerUi.tokenName = dets.tokenUrl || 'access_token';
}
else if(authSchemes[key].grantTypes) {
// 1.2 support
var o = authSchemes[key].grantTypes;
for(var t in o) {
if(o.hasOwnProperty(t) && t === 'implicit') {
var dets = o[t];
var ep = dets.loginEndpoint.url;
url = dets.loginEndpoint.url + '?response_type=token';
window.swaggerUi.tokenName = dets.tokenName;
}
}
}
}
@@ -94,7 +121,7 @@ function handleLogin() {
var o = $('.api-popup-scopes').find('input:checked');
for(k =0; k < o.length; k++) {
scopes.push($(o[k]).attr("scope"));
scopes.push($(o[k]).attr('scope'));
}
window.enabledScopes=scopes;
@@ -130,14 +157,14 @@ function initOAuth(opts) {
var o = (opts||{});
var errors = [];
appName = (o.appName||errors.push("missing appName"));
appName = (o.appName||errors.push('missing appName'));
popupMask = (o.popupMask||$('#api-common-mask'));
popupDialog = (o.popupDialog||$('.api-popup-dialog'));
clientId = (o.clientId||errors.push("missing client id"));
realm = (o.realm||errors.push("missing realm"));
clientId = (o.clientId||errors.push('missing client id'));
realm = (o.realm||errors.push('missing realm'));
if(errors.length > 0){
log("auth unable initialize oauth: " + errors);
log('auth unable initialize oauth: ' + errors);
return;
}
@@ -203,8 +230,7 @@ function onOAuthComplete(token) {
}
}
});
window.authorizations.add("oauth2", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header"));
window.authorizations.add('oauth2', new ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
}
}
}
+1568 -1547
View File
File diff suppressed because it is too large Load Diff
+469 -124
View File
@@ -1,5 +1,5 @@
// swagger-ui.js
// version 2.0.23
// version 2.1.0-alpha.4
$(function() {
// Helper function for vertically aligning DOM elements
@@ -93,7 +93,6 @@ var Docs = {
switch (fragments.length) {
case 1:
// Expand all operations for the resource and scroll to it
log('shebang resource:' + fragments[0]);
var dom_id = 'resource_' + fragments[0];
Docs.expandEndpointListForResource(fragments[0]);
@@ -101,7 +100,6 @@ var Docs = {
break;
case 2:
// Refer to the endpoint DOM element, e.g. #words_get_search
log('shebang endpoint: ' + fragments.join('_'));
// Expand Resource
Docs.expandEndpointListForResource(fragments[0]);
@@ -111,8 +109,6 @@ var Docs = {
var li_dom_id = fragments.join('_');
var li_content_dom_id = li_dom_id + "_content";
log("li_dom_id " + li_dom_id);
log("li_content_dom_id " + li_content_dom_id);
Docs.expandOperation($('#'+li_content_dom_id));
$('#'+li_dom_id).slideto({highlight: false});
@@ -189,6 +185,35 @@ var Docs = {
}
};(function() {
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['apikey_button_view'] = template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
buffer += "<div class='auth_button' id='apikey_button'><img class='auth_icon' alt='apply api key' src='images/apikey.jpeg'></div>\n<div class='auth_container' id='apikey_container'>\n <div class='key_input_container'>\n <div class='auth_label'>";
if (stack1 = helpers.keyName) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.keyName; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "</div>\n <input placeholder=\"api_key\" class=\"auth_input\" id=\"input_apiKey_entry\" name=\"apiKey\" type=\"text\"/>\n <div class='auth_submit'><a class='auth_submit_button' id=\"apply_api_key\" href=\"#\">apply</a></div>\n </div>\n</div>\n\n";
return buffer;
});
})();
(function() {
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['basic_auth_button_view'] = template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
return "<div class='auth_button' id='basic_auth_button'><img class='auth_icon' src='images/password.jpeg'></div>\n<div class='auth_container' id='basic_auth_container'>\n <div class='key_input_container'>\n <div class=\"auth_label\">Username</div>\n <input placeholder=\"username\" class=\"auth_input\" id=\"input_username\" name=\"username\" type=\"text\"/>\n <div class=\"auth_label\">Password</div>\n <input placeholder=\"password\" class=\"auth_input\" id=\"input_password\" name=\"password\" type=\"password\"/>\n <div class='auth_submit'><a class='auth_submit_button' id=\"apply_basic_auth\" href=\"#\">apply</a></div>\n </div>\n</div>\n\n";
});
})();
(function() {
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['content_type'] = template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
@@ -235,23 +260,23 @@ function program4(depth0,data) {
templates['main'] = template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
var buffer = "", stack1, stack2, functionType="function", escapeExpression=this.escapeExpression, self=this;
function program1(depth0,data) {
var buffer = "", stack1, stack2;
buffer += "\n <div class=\"info_title\">"
buffer += "\n <div class=\"info_title\">"
+ escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.title)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</div>\n <div class=\"info_description\">";
+ "</div>\n <div class=\"info_description\">";
stack2 = ((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.description)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1);
if(stack2 || stack2 === 0) { buffer += stack2; }
buffer += "</div>\n ";
buffer += "</div>\n ";
stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.termsOfServiceUrl), {hash:{},inverse:self.noop,fn:self.program(2, program2, data),data:data});
if(stack2 || stack2 === 0) { buffer += stack2; }
buffer += "\n ";
buffer += "\n ";
stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.contact), {hash:{},inverse:self.noop,fn:self.program(4, program4, data),data:data});
if(stack2 || stack2 === 0) { buffer += stack2; }
buffer += "\n ";
buffer += "\n ";
stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.license), {hash:{},inverse:self.noop,fn:self.program(6, program6, data),data:data});
if(stack2 || stack2 === 0) { buffer += stack2; }
buffer += "\n ";
@@ -270,7 +295,7 @@ function program4(depth0,data) {
var buffer = "", stack1;
buffer += "<div class='info_contact'><a href=\"mailto:"
+ escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.contact)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.contact)),stack1 == null || stack1 === false ? stack1 : stack1.name)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "\">Contact the developer</a></div>";
return buffer;
}
@@ -279,9 +304,9 @@ function program6(depth0,data) {
var buffer = "", stack1;
buffer += "<div class='info_license'><a href='"
+ escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.licenseUrl)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.license)),stack1 == null || stack1 === false ? stack1 : stack1.url)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "'>"
+ escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.license)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ escapeExpression(((stack1 = ((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.license)),stack1 == null || stack1 === false ? stack1 : stack1.name)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "</a></div>";
return buffer;
}
@@ -289,25 +314,49 @@ function program6(depth0,data) {
function program8(depth0,data) {
var buffer = "", stack1;
buffer += "\n , <span style=\"font-variant: small-caps\">api version</span>: ";
if (stack1 = helpers.apiVersion) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.apiVersion; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += "\n , <span style=\"font-variant: small-caps\">api version</span>: "
+ escapeExpression(((stack1 = ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.version)),typeof stack1 === functionType ? stack1.apply(depth0) : stack1))
+ "\n ";
return buffer;
}
function program10(depth0,data) {
var buffer = "", stack1;
buffer += "\n <span style=\"float:right\"><a href=\"";
if (stack1 = helpers.validatorUrl) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.validatorUrl; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "\n ";
+ "/debug?url=";
if (stack1 = helpers.url) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "\"><img id=\"validator\" src=\"";
if (stack1 = helpers.validatorUrl) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.validatorUrl; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "?url=";
if (stack1 = helpers.url) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "\"></a>\n </span>\n ";
return buffer;
}
buffer += "<div class='info' id='api_info'>\n ";
stack1 = helpers['if'].call(depth0, depth0.info, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n</div>\n<div class='container' id='resources_container'>\n <ul id='resources'>\n </ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: ";
buffer += "\n</div>\n<div class='container' id='resources_container'>\n <ul id='resources'></ul>\n\n <div class=\"footer\">\n <br>\n <br>\n <h4 style=\"color: #999\">[ <span style=\"font-variant: small-caps\">base url</span>: ";
if (stack1 = helpers.basePath) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.basePath; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "\n ";
stack1 = helpers['if'].call(depth0, depth0.apiVersion, {hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "]</h4>\n </div>\n</div>\n";
+ "\n ";
stack2 = helpers['if'].call(depth0, ((stack1 = depth0.info),stack1 == null || stack1 === false ? stack1 : stack1.version), {hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data});
if(stack2 || stack2 === 0) { buffer += stack2; }
buffer += "]\n ";
stack2 = helpers['if'].call(depth0, depth0.validatorUrl, {hash:{},inverse:self.noop,fn:self.program(10, program10, data),data:data});
if(stack2 || stack2 === 0) { buffer += stack2; }
buffer += "\n </h4>\n </div>\n</div>\n";
return buffer;
});
})();
@@ -321,31 +370,43 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
function program1(depth0,data) {
var buffer = "", stack1;
buffer += "\n <h4>Implementation Notes</h4>\n <p>";
if (stack1 = helpers.notes) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.notes; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "</p>\n ";
return buffer;
return "deprecated";
}
function program3(depth0,data) {
return "\n <div class=\"auth\">\n <span class=\"api-ic ic-error\"></span>";
return "\n <h4>Warning: Deprecated</h4>\n ";
}
function program5(depth0,data) {
var buffer = "", stack1;
buffer += "\n <h4>Implementation Notes</h4>\n <p>";
if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "</p>\n ";
return buffer;
}
function program7(depth0,data) {
return "\n <div class=\"auth\">\n <span class=\"api-ic ic-error\"></span>";
}
function program9(depth0,data) {
var buffer = "", stack1;
buffer += "\n <div id=\"api_information_panel\" style=\"top: 526px; left: 776px; display: none;\">\n ";
stack1 = helpers.each.call(depth0, depth0, {hash:{},inverse:self.noop,fn:self.program(6, program6, data),data:data});
stack1 = helpers.each.call(depth0, depth0, {hash:{},inverse:self.noop,fn:self.program(10, program10, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n </div>\n ";
return buffer;
}
function program6(depth0,data) {
function program10(depth0,data) {
var buffer = "", stack1, stack2;
buffer += "\n <div title='";
@@ -357,43 +418,43 @@ function program6(depth0,data) {
return buffer;
}
function program8(depth0,data) {
function program12(depth0,data) {
return "</div>";
}
function program10(depth0,data) {
function program14(depth0,data) {
return "\n <div class='access'>\n <span class=\"api-ic ic-off\" title=\"click to authenticate\"></span>\n </div>\n ";
}
function program12(depth0,data) {
function program16(depth0,data) {
return "\n <h4>Response Class</h4>\n <p><span class=\"model-signature\" /></p>\n <br/>\n <div class=\"response-content-type\" />\n ";
}
function program14(depth0,data) {
function program18(depth0,data) {
return "\n <h4>Parameters</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th style=\"width: 100px; max-width: 100px\">Parameter</th>\n <th style=\"width: 310px; max-width: 310px\">Value</th>\n <th style=\"width: 200px; max-width: 200px\">Description</th>\n <th style=\"width: 100px; max-width: 100px\">Parameter Type</th>\n <th style=\"width: 220px; max-width: 230px\">Data Type</th>\n </tr>\n </thead>\n <tbody class=\"operation-params\">\n\n </tbody>\n </table>\n ";
}
function program16(depth0,data) {
function program20(depth0,data) {
return "\n <div style='margin:0;padding:0;display:inline'></div>\n <h4>Response Messages</h4>\n <table class='fullwidth'>\n <thead>\n <tr>\n <th>HTTP Status Code</th>\n <th>Reason</th>\n <th>Response Model</th>\n </tr>\n </thead>\n <tbody class=\"operation-status\">\n \n </tbody>\n </table>\n ";
}
function program18(depth0,data) {
function program22(depth0,data) {
return "\n ";
}
function program20(depth0,data) {
function program24(depth0,data) {
return "\n <div class='sandbox_header'>\n <input class='submit' name='commit' type='button' value='Try it out!' />\n <a href='#' class='response_hider' style='display:none'>Hide Response</a>\n <span class='response_throbber' style='display:none'></span>\n </div>\n ";
@@ -431,7 +492,10 @@ function program20(depth0,data) {
if (stack1 = helpers.nickname) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "' class=\"toggleOperation\">";
+ "' class=\"toggleOperation ";
stack1 = helpers['if'].call(depth0, depth0.deprecated, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\">";
if (stack1 = helpers.path) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.path; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
@@ -456,40 +520,43 @@ function program20(depth0,data) {
else { stack1 = depth0.nickname; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "_content' style='display:none'>\n ";
stack1 = helpers['if'].call(depth0, depth0.notes, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
stack1 = helpers['if'].call(depth0, depth0.deprecated, {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
options = {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data};
stack1 = helpers['if'].call(depth0, depth0.description, {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
options = {hash:{},inverse:self.noop,fn:self.program(7, program7, data),data:data};
if (stack1 = helpers.oauth) { stack1 = stack1.call(depth0, options); }
else { stack1 = depth0.oauth; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if (!helpers.oauth) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
stack1 = helpers.each.call(depth0, depth0.oauth, {hash:{},inverse:self.noop,fn:self.program(5, program5, data),data:data});
stack1 = helpers.each.call(depth0, depth0.oauth, {hash:{},inverse:self.noop,fn:self.program(9, program9, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
options = {hash:{},inverse:self.noop,fn:self.program(8, program8, data),data:data};
options = {hash:{},inverse:self.noop,fn:self.program(12, program12, data),data:data};
if (stack1 = helpers.oauth) { stack1 = stack1.call(depth0, options); }
else { stack1 = depth0.oauth; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if (!helpers.oauth) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
options = {hash:{},inverse:self.noop,fn:self.program(10, program10, data),data:data};
options = {hash:{},inverse:self.noop,fn:self.program(14, program14, data),data:data};
if (stack1 = helpers.oauth) { stack1 = stack1.call(depth0, options); }
else { stack1 = depth0.oauth; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if (!helpers.oauth) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
stack1 = helpers['if'].call(depth0, depth0.type, {hash:{},inverse:self.noop,fn:self.program(12, program12, data),data:data});
stack1 = helpers['if'].call(depth0, depth0.type, {hash:{},inverse:self.noop,fn:self.program(16, program16, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n <form accept-charset='UTF-8' class='sandbox'>\n <div style='margin:0;padding:0;display:inline'></div>\n ";
stack1 = helpers['if'].call(depth0, depth0.parameters, {hash:{},inverse:self.noop,fn:self.program(14, program14, data),data:data});
stack1 = helpers['if'].call(depth0, depth0.parameters, {hash:{},inverse:self.noop,fn:self.program(18, program18, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
stack1 = helpers['if'].call(depth0, depth0.responseMessages, {hash:{},inverse:self.noop,fn:self.program(16, program16, data),data:data});
stack1 = helpers['if'].call(depth0, depth0.responseMessages, {hash:{},inverse:self.noop,fn:self.program(20, program20, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
stack1 = helpers['if'].call(depth0, depth0.isReadOnly, {hash:{},inverse:self.program(20, program20, data),fn:self.program(18, program18, data),data:data});
stack1 = helpers['if'].call(depth0, depth0.isReadOnly, {hash:{},inverse:self.program(24, program24, data),fn:self.program(22, program22, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n </form>\n <div class='response' style='display:none'>\n <h4>Request URL</h4>\n <div class='block request_url'></div>\n <h4>Response Body</h4>\n <div class='block response_body'></div>\n <h4>Response Code</h4>\n <div class='block response_code'></div>\n <h4>Response Headers</h4>\n <div class='block response_headers'></div>\n </div>\n </div>\n </li>\n </ul>\n";
return buffer;
@@ -527,7 +594,7 @@ function program4(depth0,data) {
var buffer = "", stack1;
buffer += "\n ";
stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(7, program7, data),fn:self.program(5, program5, data),data:data});
stack1 = helpers['if'].call(depth0, depth0['default'], {hash:{},inverse:self.program(7, program7, data),fn:self.program(5, program5, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
return buffer;
@@ -540,8 +607,8 @@ function program5(depth0,data) {
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "'>";
if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if (stack1 = helpers['default']) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0['default']; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "</textarea>\n ";
return buffer;
@@ -571,7 +638,7 @@ function program10(depth0,data) {
var buffer = "", stack1;
buffer += "\n ";
stack1 = helpers['if'].call(depth0, depth0.defaultValue, {hash:{},inverse:self.program(13, program13, data),fn:self.program(11, program11, data),data:data});
stack1 = helpers['if'].call(depth0, depth0['default'], {hash:{},inverse:self.program(13, program13, data),fn:self.program(11, program11, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n ";
return buffer;
@@ -584,8 +651,8 @@ function program11(depth0,data) {
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "' placeholder='' type='text' value='";
if (stack1 = helpers.defaultValue) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.defaultValue; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if (stack1 = helpers['default']) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0['default']; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "'/>\n ";
return buffer;
@@ -1077,6 +1144,17 @@ function program1(depth0,data) {
return " : ";
}
function program3(depth0,data) {
var buffer = "", stack1;
buffer += "<li>\n <a href='";
if (stack1 = helpers.url) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "'>Raw</a>\n </li>";
return buffer;
}
buffer += "<div class='heading'>\n <h2>\n <a href='#!/";
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
@@ -1091,12 +1169,12 @@ function program1(depth0,data) {
buffer += escapeExpression(stack1)
+ "</a> ";
options = {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data};
if (stack1 = helpers.description) { stack1 = stack1.call(depth0, options); }
else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if (!helpers.description) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
if (stack1 = helpers.summary) { stack1 = stack1.call(depth0, options); }
else { stack1 = depth0.summary; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if (!helpers.summary) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
if(stack1 || stack1 === 0) { buffer += stack1; }
if (stack1 = helpers.description) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.description; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if (stack1 = helpers.summary) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.summary; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n </h2>\n <ul class='options'>\n <li>\n <a href='#!/";
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
@@ -1118,11 +1196,13 @@ function program1(depth0,data) {
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ ">\n Expand Operations\n </a>\n </li>\n <li>\n <a href='";
if (stack1 = helpers.url) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
+ ">\n Expand Operations\n </a>\n </li>\n ";
options = {hash:{},inverse:self.noop,fn:self.program(3, program3, data),data:data};
if (stack1 = helpers.url) { stack1 = stack1.call(depth0, options); }
else { stack1 = depth0.url; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "'>Raw</a>\n </li>\n </ul>\n</div>\n<ul class='endpoints' id='";
if (!helpers.url) { stack1 = blockHelperMissing.call(depth0, stack1, options); }
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n </ul>\n</div>\n<ul class='endpoints' id='";
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
@@ -1182,15 +1262,15 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression;
buffer += "<div>\n<ul class=\"signature-nav\">\n <li><a class=\"description-link\" href=\"#\">Model</a></li>\n <li><a class=\"snippet-link\" href=\"#\">Model Schema</a></li>\n</ul>\n<div>\n\n<div class=\"signature-container\">\n <div class=\"description\">\n ";
buffer += "<div>\n<ul class=\"signature-nav\">\n <li><a class=\"description-link\" href=\"#\">Model</a></li>\n <li><a class=\"snippet-link\" href=\"#\">Model Schema</a></li>\n</ul>\n<div>\n\n<div class=\"signature-container\">\n <div class=\"description\">\n ";
if (stack1 = helpers.signature) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.signature; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n </div>\n\n <div class=\"snippet\">\n <pre><code>";
buffer += "\n </div>\n\n <div class=\"snippet\">\n <pre><code>";
if (stack1 = helpers.sampleJSON) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.sampleJSON; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "</code></pre>\n <small class=\"notice\"></small>\n </div>\n</div>\n\n";
+ "</code></pre>\n <small class=\"notice\"></small>\n </div>\n</div>\n\n";
return buffer;
});
})();
@@ -1220,7 +1300,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
// Generated by CoffeeScript 1.6.3
(function() {
var ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi, _ref, _ref1, _ref10, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
var ApiKeyButton, BasicAuthButton, ContentTypeView, HeaderView, MainView, OperationView, ParameterContentTypeView, ParameterView, ResourceView, ResponseContentTypeView, SignatureView, StatusCodeView, SwaggerUi, _ref, _ref1, _ref10, _ref11, _ref12, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, _ref9,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
@@ -1262,7 +1342,13 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
return _this.showMessage(d);
};
this.options.failure = function(d) {
return _this.onLoadFailure(d);
if (_this.api && _this.api.isValid === false) {
log("not a valid 2.0 spec, loading legacy client");
_this.api = new SwaggerApi(_this.options);
return _this.api.build();
} else {
return _this.onLoadFailure(d);
}
};
this.headerView = new HeaderView({
el: $('#header')
@@ -1272,6 +1358,14 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
});
};
SwaggerUi.prototype.setOption = function(option, value) {
return this.options[option] = value;
};
SwaggerUi.prototype.getOption = function(option) {
return this.options[option];
};
SwaggerUi.prototype.updateSwaggerUi = function(data) {
this.options.url = data.url;
return this.load();
@@ -1288,9 +1382,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
}
this.options.url = url;
this.headerView.update(url);
this.api = new SwaggerApi(this.options);
this.api.build();
return this.api;
this.api = new SwaggerClient(this.options);
return this.api.build();
};
SwaggerUi.prototype.render = function() {
@@ -1451,26 +1544,64 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
};
MainView.prototype.initialize = function(opts) {
var route, sorter, sorterName, _i, _len, _ref3;
var auth, key, name, url, value, _ref3;
if (opts == null) {
opts = {};
}
if (opts.swaggerOptions.sorter) {
sorterName = opts.swaggerOptions.sorter;
sorter = sorters[sorterName];
_ref3 = this.model.apisArray;
for (_i = 0, _len = _ref3.length; _i < _len; _i++) {
route = _ref3[_i];
route.operationsArray.sort(sorter);
}
if (sorterName === "alpha") {
return this.model.apisArray.sort(sorter);
this.model.auths = [];
_ref3 = this.model.securityDefinitions;
for (key in _ref3) {
value = _ref3[key];
auth = {
name: key,
type: value.type,
value: value
};
this.model.auths.push(auth);
}
if (this.model.info && this.model.info.license && typeof this.model.info.license === 'string') {
name = this.model.info.license;
url = this.model.info.licenseUrl;
this.model.info.license = {};
this.model.info.license.name = name;
this.model.info.license.url = url;
}
if (!this.model.info) {
this.model.info = {};
}
if (!this.model.info.version) {
this.model.info.version = this.model.apiVersion;
}
if (this.model.swaggerVersion === "2.0") {
if ("validatorUrl" in opts.swaggerOptions) {
return this.model.validatorUrl = opts.swaggerOptions.validatorUrl;
} else if (this.model.url.match(/https?:\/\/localhost/)) {
return this.model.validatorUrl = this.model.url;
} else {
return this.model.validatorUrl = "http://online.swagger.io/validator";
}
}
};
MainView.prototype.render = function() {
var counter, id, resource, resources, _i, _len, _ref3;
var auth, button, counter, id, name, resource, resources, _i, _len, _ref3;
if (this.model.securityDefinitions) {
for (name in this.model.securityDefinitions) {
auth = this.model.securityDefinitions[name];
if (auth.type === "apiKey" && $("#apikey_button").length === 0) {
button = new ApiKeyButton({
model: auth
}).render().el;
$('.auth_main_container').append(button);
}
if (auth.type === "basicAuth" && $("#basic_auth_button").length === 0) {
button = new BasicAuthButton({
model: auth
}).render().el;
$('.auth_main_container').append(button);
}
}
}
$(this.el).html(Handlebars.templates.main(this.model));
resources = {};
counter = 0;
@@ -1484,18 +1615,20 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
}
resource.id = id;
resources[id] = resource;
this.addResource(resource);
this.addResource(resource, this.model.auths);
}
return this;
};
MainView.prototype.addResource = function(resource) {
MainView.prototype.addResource = function(resource, auths) {
var resourceView;
resource.id = resource.id.replace(/\s/g, '_');
resourceView = new ResourceView({
model: resource,
tagName: 'li',
id: 'resource_' + resource.id,
className: 'resource',
auths: auths,
swaggerOptions: this.options.swaggerOptions
});
return $('#resources').append(resourceView.render().el);
@@ -1517,12 +1650,23 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
return _ref3;
}
ResourceView.prototype.initialize = function() {};
ResourceView.prototype.initialize = function(opts) {
if (opts == null) {
opts = {};
}
this.auths = opts.auths;
if ("" === this.model.description) {
return this.model.description = null;
}
};
ResourceView.prototype.render = function() {
var counter, id, methods, operation, _i, _len, _ref4;
$(this.el).html(Handlebars.templates.resource(this.model));
methods = {};
if (this.model.description) {
this.model.summary = this.model.description;
}
_ref4 = this.model.operationsArray;
for (_i = 0, _len = _ref4.length; _i < _len; _i++) {
operation = _ref4[_i];
@@ -1539,7 +1683,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
}
$('.toggleEndpointList', this.el).click(this.callDocs.bind(this, 'toggleEndpointListForResource'));
$('.collapseResource', this.el).click(this.callDocs.bind(this, 'collapseOperationsForResource'));
$('.expandResource', this.el).click(this.callDocs.bind(this, 'expandOperationsForResoruce'));
$('.expandResource', this.el).click(this.callDocs.bind(this, 'expandOperationsForResource'));
return this;
};
@@ -1550,7 +1694,8 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
model: operation,
tagName: 'li',
className: 'endpoint',
swaggerOptions: this.options.swaggerOptions
swaggerOptions: this.options.swaggerOptions,
auths: this.auths
});
$('.endpoints', $(this.el)).append(operationView.render().el);
return this.number++;
@@ -1584,7 +1729,13 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
'mouseout .api-ic': 'mouseExit'
};
OperationView.prototype.initialize = function() {};
OperationView.prototype.initialize = function(opts) {
if (opts == null) {
opts = {};
}
this.auths = opts.auths;
return this;
};
OperationView.prototype.mouseEnter = function(e) {
var elem, hgh, pos, scMaxX, scMaxY, scX, scY, wd, x, y;
@@ -1621,30 +1772,83 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
};
OperationView.prototype.render = function() {
var contentTypeModel, isMethodSubmissionSupported, k, o, param, responseContentTypeView, responseSignatureView, signatureModel, statusCode, type, v, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref5, _ref6, _ref7, _ref8;
var a, auth, auths, code, contentTypeModel, isMethodSubmissionSupported, k, key, o, param, ref, responseContentTypeView, responseSignatureView, schema, schemaObj, signatureModel, statusCode, type, v, value, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref10, _ref11, _ref5, _ref6, _ref7, _ref8, _ref9;
isMethodSubmissionSupported = true;
if (!isMethodSubmissionSupported) {
this.model.isReadOnly = true;
}
this.model.description = this.model.description || this.model.notes;
if (this.model.description) {
this.model.description = this.model.description.replace(/(?:\r\n|\r|\n)/g, '<br />');
}
this.model.oauth = null;
if (this.model.authorizations) {
_ref5 = this.model.authorizations;
for (k in _ref5) {
v = _ref5[k];
if (k === "oauth2") {
if (this.model.oauth === null) {
this.model.oauth = {};
if (Array.isArray(this.model.authorizations)) {
_ref5 = this.model.authorizations;
for (_i = 0, _len = _ref5.length; _i < _len; _i++) {
auths = _ref5[_i];
for (key in auths) {
auth = auths[key];
for (a in this.auths) {
auth = this.auths[a];
if (auth.type === 'oauth2') {
this.model.oauth = {};
this.model.oauth.scopes = [];
_ref6 = auth.value.scopes;
for (k in _ref6) {
v = _ref6[k];
o = {
scope: k,
description: v
};
this.model.oauth.scopes.push(o);
}
}
}
}
if (this.model.oauth.scopes === void 0) {
this.model.oauth.scopes = [];
}
for (_i = 0, _len = v.length; _i < _len; _i++) {
o = v[_i];
this.model.oauth.scopes.push(o);
}
} else {
_ref7 = this.model.authorizations;
for (k in _ref7) {
v = _ref7[k];
if (k === "oauth2") {
if (this.model.oauth === null) {
this.model.oauth = {};
}
if (this.model.oauth.scopes === void 0) {
this.model.oauth.scopes = [];
}
for (_j = 0, _len1 = v.length; _j < _len1; _j++) {
o = v[_j];
this.model.oauth.scopes.push(o);
}
}
}
}
}
if (typeof this.model.responses !== 'undefined') {
this.model.responseMessages = [];
_ref8 = this.model.responses;
for (code in _ref8) {
value = _ref8[code];
schema = null;
schemaObj = this.model.responses[code].schema;
if (schemaObj && schemaObj['$ref']) {
schema = schemaObj['$ref'];
if (schema.indexOf('#/definitions/') === 0) {
schema = schema.substring('#/definitions/'.length);
}
}
this.model.responseMessages.push({
code: code,
message: value.description,
responseModel: schema
});
}
}
if (typeof this.model.responseMessages === 'undefined') {
this.model.responseMessages = [];
}
$(this.el).html(Handlebars.templates.operation(this.model));
if (this.model.responseClassSignature && this.model.responseClassSignature !== 'string') {
signatureModel = {
@@ -1658,6 +1862,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
});
$('.model-signature', $(this.el)).append(responseSignatureView.render().el);
} else {
this.model.responseClassSignature = 'string';
$('.model-signature', $(this.el)).html(this.model.type);
}
contentTypeModel = {
@@ -1665,29 +1870,40 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
};
contentTypeModel.consumes = this.model.consumes;
contentTypeModel.produces = this.model.produces;
_ref6 = this.model.parameters;
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
param = _ref6[_j];
_ref9 = this.model.parameters;
for (_k = 0, _len2 = _ref9.length; _k < _len2; _k++) {
param = _ref9[_k];
type = param.type || param.dataType;
if (type.toLowerCase() === 'file') {
if (typeof type === 'undefined') {
schema = param.schema;
if (schema && schema['$ref']) {
ref = schema['$ref'];
if (ref.indexOf('#/definitions/') === 0) {
type = ref.substring('#/definitions/'.length);
} else {
type = ref;
}
}
}
if (type && type.toLowerCase() === 'file') {
if (!contentTypeModel.consumes) {
log("set content type ");
contentTypeModel.consumes = 'multipart/form-data';
}
}
param.type = type;
}
responseContentTypeView = new ResponseContentTypeView({
model: contentTypeModel
});
$('.response-content-type', $(this.el)).append(responseContentTypeView.render().el);
_ref7 = this.model.parameters;
for (_k = 0, _len2 = _ref7.length; _k < _len2; _k++) {
param = _ref7[_k];
_ref10 = this.model.parameters;
for (_l = 0, _len3 = _ref10.length; _l < _len3; _l++) {
param = _ref10[_l];
this.addParameter(param, contentTypeModel.consumes);
}
_ref8 = this.model.responseMessages;
for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) {
statusCode = _ref8[_l];
_ref11 = this.model.responseMessages;
for (_m = 0, _len4 = _ref11.length; _m < _len4; _m++) {
statusCode = _ref11[_m];
this.addStatusCode(statusCode);
}
return this;
@@ -1753,7 +1969,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) {
o = _ref6[_j];
if ((o.value != null) && jQuery.trim(o.value).length > 0) {
map["body"] = o.value;
map[o.name] = o.value;
}
}
_ref7 = form.find("select");
@@ -1808,7 +2024,6 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
headerParams[param.name] = map[param.name];
}
}
log(headerParams);
_ref8 = form.find('input[type~="file"]');
for (_l = 0, _len3 = _ref8.length; _l < _len3; _l++) {
el = _ref8[_l];
@@ -1883,7 +2098,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
}
}
if (options.length > 0) {
return options.join(",");
return options;
} else {
return null;
}
@@ -1986,7 +2201,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
};
OperationView.prototype.showStatus = function(response) {
var code, content, contentType, headers, opts, pre, response_body, response_body_el, url;
var code, content, contentType, e, headers, json, opts, pre, response_body, response_body_el, url;
if (response.content === void 0) {
content = response.data;
url = response.url;
@@ -1995,18 +2210,31 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
url = response.request.url;
}
headers = response.headers;
contentType = headers && headers["Content-Type"] ? headers["Content-Type"].split(";")[0].trim() : null;
contentType = null;
if (headers) {
contentType = headers["Content-Type"] || headers["content-type"];
if (contentType) {
contentType = contentType.split(";")[0].trim();
}
}
if (!content) {
code = $('<code />').text("no content");
pre = $('<pre class="json" />').append(code);
} else if (contentType === "application/json" || /\+json$/.test(contentType)) {
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, " "));
json = null;
try {
json = JSON.stringify(JSON.parse(content), null, " ");
} catch (_error) {
e = _error;
json = "can't parse JSON. Raw result:\n\n" + content;
}
code = $('<code />').text(json);
pre = $('<pre class="json" />').append(code);
} else if (contentType === "application/xml" || /\+xml$/.test(contentType)) {
code = $('<code />').text(this.formatXml(content));
pre = $('<pre class="xml" />').append(code);
} else if (contentType === "text/html") {
code = $('<code />').html(content);
code = $('<code />').html(_.escape(content));
pre = $('<pre class="xml" />').append(code);
} else if (/^image\//.test(contentType)) {
pre = $('<img>').attr('src', url);
@@ -2104,14 +2332,28 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
};
ParameterView.prototype.render = function() {
var contentTypeModel, isParam, parameterContentTypeView, responseContentTypeView, signatureModel, signatureView, template, type;
var contentTypeModel, isParam, parameterContentTypeView, ref, responseContentTypeView, schema, signatureModel, signatureView, template, type;
type = this.model.type || this.model.dataType;
if (typeof type === 'undefined') {
schema = this.model.schema;
if (schema && schema['$ref']) {
ref = schema['$ref'];
if (ref.indexOf('#/definitions/') === 0) {
type = ref.substring('#/definitions/'.length);
} else {
type = ref;
}
}
}
this.model.type = type;
this.model.paramType = this.model["in"] || this.model.paramType;
if (this.model.paramType === 'body') {
this.model.isBody = true;
}
if (type.toLowerCase() === 'file') {
if (type && type.toLowerCase() === 'file') {
this.model.isFile = true;
}
this.model["default"] = this.model["default"] || this.model.defaultValue;
template = this.template();
$(this.el).html(template(this.model));
signatureModel = {
@@ -2321,4 +2563,107 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
})(Backbone.View);
ApiKeyButton = (function(_super) {
__extends(ApiKeyButton, _super);
function ApiKeyButton() {
_ref11 = ApiKeyButton.__super__.constructor.apply(this, arguments);
return _ref11;
}
ApiKeyButton.prototype.initialize = function() {};
ApiKeyButton.prototype.render = function() {
var template;
template = this.template();
$(this.el).html(template(this.model));
return this;
};
ApiKeyButton.prototype.events = {
"click #apikey_button": "toggleApiKeyContainer",
"click #apply_api_key": "applyApiKey"
};
ApiKeyButton.prototype.applyApiKey = function() {
var elem;
window.authorizations.add(this.model.name, new ApiKeyAuthorization(this.model.name, $("#input_apiKey_entry").val(), this.model["in"]));
window.swaggerUi.load();
return elem = $('#apikey_container').show();
};
ApiKeyButton.prototype.toggleApiKeyContainer = function() {
var elem;
if ($('#apikey_container').length > 0) {
elem = $('#apikey_container').first();
if (elem.is(':visible')) {
return elem.hide();
} else {
$('.auth_container').hide();
return elem.show();
}
}
};
ApiKeyButton.prototype.template = function() {
return Handlebars.templates.apikey_button_view;
};
return ApiKeyButton;
})(Backbone.View);
BasicAuthButton = (function(_super) {
__extends(BasicAuthButton, _super);
function BasicAuthButton() {
_ref12 = BasicAuthButton.__super__.constructor.apply(this, arguments);
return _ref12;
}
BasicAuthButton.prototype.initialize = function() {};
BasicAuthButton.prototype.render = function() {
var template;
template = this.template();
$(this.el).html(template(this.model));
return this;
};
BasicAuthButton.prototype.events = {
"click #basic_auth_button": "togglePasswordContainer",
"click #apply_basic_auth": "applyPassword"
};
BasicAuthButton.prototype.applyPassword = function() {
var elem, password, username;
console.log("applying password");
username = $(".input_username").val();
password = $(".input_password").val();
window.authorizations.add(this.model.type, new PasswordAuthorization("basic", username, password));
window.swaggerUi.load();
return elem = $('#basic_auth_container').hide();
};
BasicAuthButton.prototype.togglePasswordContainer = function() {
var elem;
if ($('#basic_auth_container').length > 0) {
elem = $('#basic_auth_container').show();
if (elem.is(':visible')) {
return elem.slideUp();
} else {
$('.auth_container').hide();
return elem.show();
}
}
};
BasicAuthButton.prototype.template = function() {
return Handlebars.templates.basic_auth_button_view;
};
return BasicAuthButton;
})(Backbone.View);
}).call(this);
+1 -1
View File
File diff suppressed because one or more lines are too long
+3 -3
View File
@@ -2131,10 +2131,10 @@ require.define("/shred/mixins/headers.js", function (require, module, exports, _
// to `Content-Type`.
var corsetCase = function(string) {
return string.toLowerCase()
return string;//.toLowerCase()
//.replace("_","-")
.replace(/(^|-)(\w)/g,
function(s) { return s.toUpperCase(); });
// .replace(/(^|-)(\w)/g,
// function(s) { return s.toUpperCase(); });
};
// We suspect that `initializeHeaders` was once more complicated ...
File diff suppressed because it is too large Load Diff
+72 -46
View File
@@ -7,10 +7,29 @@ var realm;
function handleLogin() {
var scopes = [];
if(window.swaggerUi.api.authSchemes
&& window.swaggerUi.api.authSchemes.oauth2
&& window.swaggerUi.api.authSchemes.oauth2.scopes) {
scopes = window.swaggerUi.api.authSchemes.oauth2.scopes;
var auths = window.swaggerUi.api.authSchemes || window.swaggerUi.api.securityDefinitions;
if(auths) {
var key;
var defs = auths;
for(key in defs) {
var auth = defs[key];
if(auth.type === 'oauth2' && auth.scopes) {
var scope;
if(Array.isArray(auth.scopes)) {
// 1.2 support
var i;
for(i = 0; i < auth.scopes.length; i++) {
scopes.push(auth.scopes[i]);
}
}
else {
// 2.0 support
for(scope in auth.scopes) {
scopes.push({scope: scope, description: auth.scopes[scope]});
}
}
}
}
}
if(window.swaggerUi.api
@@ -18,36 +37,32 @@ function handleLogin() {
appName = window.swaggerUi.api.info.title;
}
if(popupDialog.length > 0)
popupDialog = popupDialog.last();
else {
popupDialog = $(
[
'<div class="api-popup-dialog">',
'<div class="api-popup-title">Select OAuth2.0 Scopes</div>',
'<div class="api-popup-content">',
'<p>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.',
'<a href="#">Learn how to use</a>',
'</p>',
'<p><strong>' + appName + '</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI.</p>',
'<ul class="api-popup-scopes">',
'</ul>',
'<p class="error-msg"></p>',
'<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button">Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>',
'</div>',
'</div>'].join(''));
$(document.body).append(popupDialog);
popupDialog = $(
[
'<div class="api-popup-dialog">',
'<div class="api-popup-title">Select OAuth2.0 Scopes</div>',
'<div class="api-popup-content">',
'<p>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.',
'<a href="#">Learn how to use</a>',
'</p>',
'<p><strong>' + appName + '</strong> API requires the following scopes. Select which ones you want to grant to Swagger UI.</p>',
'<ul class="api-popup-scopes">',
'</ul>',
'<p class="error-msg"></p>',
'<div class="api-popup-actions"><button class="api-popup-authbtn api-button green" type="button">Authorize</button><button class="api-popup-cancel api-button gray" type="button">Cancel</button></div>',
'</div>',
'</div>'].join(''));
$(document.body).append(popupDialog);
popup = popupDialog.find('ul.api-popup-scopes').empty();
for (i = 0; i < scopes.length; i ++) {
scope = scopes[i];
str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"/>' + '<label for="scope_' + i + '">' + scope.scope;
if (scope.description) {
str += '<br/><span class="api-scope-desc">' + scope.description + '</span>';
}
str += '</label></li>';
popup.append(str);
popup = popupDialog.find('ul.api-popup-scopes').empty();
for (i = 0; i < scopes.length; i ++) {
scope = scopes[i];
str = '<li><input type="checkbox" id="scope_' + i + '" scope="' + scope.scope + '"/>' + '<label for="scope_' + i + '">' + scope.scope;
if (scope.description) {
str += '<br/><span class="api-scope-desc">' + scope.description + '</span>';
}
str += '</label></li>';
popup.append(str);
}
var $win = $(window),
@@ -67,7 +82,10 @@ function handleLogin() {
popupDialog.find('button.api-popup-cancel').click(function() {
popupMask.hide();
popupDialog.hide();
popupDialog.empty();
popupDialog = [];
});
popupDialog.find('button.api-popup-authbtn').click(function() {
popupMask.hide();
popupDialog.hide();
@@ -75,17 +93,26 @@ function handleLogin() {
var authSchemes = window.swaggerUi.api.authSchemes;
var host = window.location;
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/"));
var redirectUrl = host.protocol + '//' + host.host + pathname + "/o2c.html";
var redirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html';
var url = null;
for (var key in authSchemes) {
if (authSchemes.hasOwnProperty(key)) {
var o = authSchemes[key].grantTypes;
for(var t in o) {
if(o.hasOwnProperty(t) && t === 'implicit') {
var dets = o[t];
url = dets.loginEndpoint.url + "?response_type=token";
window.swaggerUi.tokenName = dets.tokenName;
if(authSchemes[key].type === 'oauth2' && authSchemes[key].flow === 'implicit') {
var dets = authSchemes[key];
url = dets.authorizationUrl + '?response_type=token';
window.swaggerUi.tokenName = dets.tokenUrl || 'access_token';
}
else if(authSchemes[key].grantTypes) {
// 1.2 support
var o = authSchemes[key].grantTypes;
for(var t in o) {
if(o.hasOwnProperty(t) && t === 'implicit') {
var dets = o[t];
var ep = dets.loginEndpoint.url;
url = dets.loginEndpoint.url + '?response_type=token';
window.swaggerUi.tokenName = dets.tokenName;
}
}
}
}
@@ -94,7 +121,7 @@ function handleLogin() {
var o = $('.api-popup-scopes').find('input:checked');
for(k =0; k < o.length; k++) {
scopes.push($(o[k]).attr("scope"));
scopes.push($(o[k]).attr('scope'));
}
window.enabledScopes=scopes;
@@ -130,14 +157,14 @@ function initOAuth(opts) {
var o = (opts||{});
var errors = [];
appName = (o.appName||errors.push("missing appName"));
appName = (o.appName||errors.push('missing appName'));
popupMask = (o.popupMask||$('#api-common-mask'));
popupDialog = (o.popupDialog||$('.api-popup-dialog'));
clientId = (o.clientId||errors.push("missing client id"));
realm = (o.realm||errors.push("missing realm"));
clientId = (o.clientId||errors.push('missing client id'));
realm = (o.realm||errors.push('missing realm'));
if(errors.length > 0){
log("auth unable initialize oauth: " + errors);
log('auth unable initialize oauth: ' + errors);
return;
}
@@ -203,8 +230,7 @@ function onOAuthComplete(token) {
}
}
});
window.authorizations.add("oauth2", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header"));
window.authorizations.add('oauth2', new ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
}
}
}
+1568 -1547
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "swagger-ui",
"version": "2.0.24",
"version": "2.1.0-alpha.4",
"description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API",
"scripts": {
"build": "PATH=$PATH:./node_modules/.bin cake dist",
@@ -19,7 +19,7 @@
"readmeFilename": "README.md",
"dependencies": {
"coffee-script": "~1.6.3",
"swagger-client": "2.0.36",
"swagger-client": "2.0.41",
"handlebars": "~1.0.10",
"less": "~1.4.2"
}
+20 -5
View File
@@ -22,9 +22,16 @@ class SwaggerUi extends Backbone.Router
@options = options
# Set the callbacks
@options.success = => @render()
@options.success = =>
@render()
@options.progress = (d) => @showMessage(d)
@options.failure = (d) => @onLoadFailure(d)
@options.failure = (d) =>
if @api and @api.isValid is false
log "not a valid 2.0 spec, loading legacy client"
@api = new SwaggerApi(@options)
@api.build()
else
@onLoadFailure(d)
# Create view to handle the header inputs
@headerView = new HeaderView({el: $('#header')})
@@ -32,6 +39,14 @@ class SwaggerUi extends Backbone.Router
# Event handler for when the baseUrl/apiKey is entered by user
@headerView.on 'update-swagger-ui', (data) => @updateSwaggerUi(data)
# Set an option after initializing
setOption: (option,value) ->
@options[option] = value
# Get the value of a previously set option
getOption: (option) ->
@options[option]
# Event handler for when url/key is received from user
updateSwaggerUi: (data) ->
@options.url = data.url
@@ -47,9 +62,9 @@ class SwaggerUi extends Backbone.Router
@options.url = url
@headerView.update(url)
@api = new SwaggerApi(@options)
@api.build()
@api
@api = new SwaggerClient(@options)
@api.build()
# This is bound to success handler for SwaggerApi
# so it gets called when SwaggerApi completes loading
@@ -0,0 +1,31 @@
class ApiKeyButton extends Backbone.View
initialize: ->
render: ->
template = @template()
$(@el).html(template(@model))
@
events:
"click #apikey_button" : "toggleApiKeyContainer"
"click #apply_api_key" : "applyApiKey"
applyApiKey: ->
window.authorizations.add(@model.name, new ApiKeyAuthorization(@model.name, $("#input_apiKey_entry").val(), @model.in))
window.swaggerUi.load()
elem = $('#apikey_container').show()
toggleApiKeyContainer: ->
if $('#apikey_container').length > 0
elem = $('#apikey_container').first()
if elem.is ':visible'
elem.hide()
else
# hide others
$('.auth_container').hide()
elem.show()
template: ->
Handlebars.templates.apikey_button_view
@@ -0,0 +1,35 @@
class BasicAuthButton extends Backbone.View
initialize: ->
render: ->
template = @template()
$(@el).html(template(@model))
@
events:
"click #basic_auth_button" : "togglePasswordContainer"
"click #apply_basic_auth" : "applyPassword"
applyPassword: ->
console.log "applying password"
username = $(".input_username").val()
password = $(".input_password").val()
window.authorizations.add(@model.type, new PasswordAuthorization("basic", username, password))
window.swaggerUi.load()
elem = $('#basic_auth_container').hide()
togglePasswordContainer: ->
if $('#basic_auth_container').length > 0
elem = $('#basic_auth_container').show()
if elem.is ':visible'
elem.slideUp()
else
# hide others
$('.auth_container').hide()
elem.show()
template: ->
Handlebars.templates.basic_auth_button_view
+51 -10
View File
@@ -5,15 +5,48 @@ class MainView extends Backbone.View
}
initialize: (opts={}) ->
if opts.swaggerOptions.sorter
sorterName = opts.swaggerOptions.sorter
sorter = sorters[sorterName]
for route in @model.apisArray
route.operationsArray.sort sorter
if (sorterName == "alpha") # sort top level paths if alpha
@model.apisArray.sort sorter
# set up the UI for input
@model.auths = []
for key, value of @model.securityDefinitions
auth = {name: key, type: value.type, value: value}
@model.auths.push auth
if @model.info and @model.info.license and typeof @model.info.license is 'string'
name = @model.info.license
url = @model.info.licenseUrl
@model.info.license = {}
@model.info.license.name = name
@model.info.license.url = url
if !@model.info
@model.info = {}
if !@model.info.version
@model.info.version = @model.apiVersion
if @model.swaggerVersion is "2.0"
if "validatorUrl" of opts.swaggerOptions
# Validator URL specified explicitly
@model.validatorUrl = opts.swaggerOptions.validatorUrl
else if @model.url.match(/https?:\/\/localhost/)
# Localhost override
@model.validatorUrl = @model.url
else
# Default validator
@model.validatorUrl = "http://online.swagger.io/validator"
render: ->
if @model.securityDefinitions
for name of @model.securityDefinitions
auth = @model.securityDefinitions[name]
if auth.type is "apiKey" and $("#apikey_button").length is 0
button = new ApiKeyButton({model: auth}).render().el
$('.auth_main_container').append button
if auth.type is "basicAuth" and $("#basic_auth_button").length is 0
button = new BasicAuthButton({model: auth}).render().el
$('.auth_main_container').append button
# Render the outer container for resources
$(@el).html(Handlebars.templates.main(@model))
@@ -28,12 +61,20 @@ class MainView extends Backbone.View
counter += 1
resource.id = id
resources[id] = resource
@addResource resource
@addResource resource, @model.auths
@
addResource: (resource) ->
addResource: (resource, auths) ->
# Render a resource and add it to resources li
resourceView = new ResourceView({model: resource, tagName: 'li', id: 'resource_' + resource.id, className: 'resource', swaggerOptions: @options.swaggerOptions})
resource.id = resource.id.replace(/\s/g, '_')
resourceView = new ResourceView({
model: resource,
tagName: 'li',
id: 'resource_' + resource.id,
className: 'resource',
auths: auths,
swaggerOptions: @options.swaggerOptions
})
$('#resources').append resourceView.render().el
clear: ->
+67 -18
View File
@@ -10,7 +10,10 @@ class OperationView extends Backbone.View
'mouseout .api-ic' : 'mouseExit'
}
initialize: ->
initialize: (opts={}) ->
@auths = opts.auths
@
mouseEnter: (e) ->
elem = $(e.currentTarget.parentNode).find('#api_information_panel')
@@ -44,16 +47,46 @@ class OperationView extends Backbone.View
isMethodSubmissionSupported = true #jQuery.inArray(@model.method, @model.supportedSubmitMethods) >= 0
@model.isReadOnly = true unless isMethodSubmissionSupported
# 1.2 syntax for description was `notes`
@model.description = (@model.description || @model.notes)
if @model.description
@model.description = @model.description.replace(/(?:\r\n|\r|\n)/g, '<br />')
@model.oauth = null
if @model.authorizations
for k, v of @model.authorizations
if k == "oauth2"
if @model.oauth == null
@model.oauth = {}
if @model.oauth.scopes is undefined
@model.oauth.scopes = []
for o in v
@model.oauth.scopes.push o
if Array.isArray @model.authorizations
for auths in @model.authorizations
for key, auth of auths
for a of @auths
auth = @auths[a]
if auth.type == 'oauth2'
@model.oauth = {}
@model.oauth.scopes = []
for k, v of auth.value.scopes
o = {scope: k, description: v}
@model.oauth.scopes.push o
else
for k, v of @model.authorizations
if k == "oauth2"
if @model.oauth == null
@model.oauth = {}
if @model.oauth.scopes is undefined
@model.oauth.scopes = []
for o in v
@model.oauth.scopes.push o
if typeof @model.responses isnt 'undefined'
@model.responseMessages = []
for code, value of @model.responses
schema = null
schemaObj = @model.responses[code].schema
if schemaObj and schemaObj['$ref']
schema = schemaObj['$ref']
if schema.indexOf('#/definitions/') is 0
schema = schema.substring('#/definitions/'.length)
@model.responseMessages.push {code: code, message: value.description, responseModel: schema }
if typeof @model.responseMessages is 'undefined'
@model.responseMessages = []
$(@el).html(Handlebars.templates.operation(@model))
@@ -66,6 +99,7 @@ class OperationView extends Backbone.View
responseSignatureView = new SignatureView({model: signatureModel, tagName: 'div'})
$('.model-signature', $(@el)).append responseSignatureView.render().el
else
@model.responseClassSignature = 'string'
$('.model-signature', $(@el)).html(@model.type)
contentTypeModel =
@@ -76,10 +110,18 @@ class OperationView extends Backbone.View
for param in @model.parameters
type = param.type || param.dataType
if type.toLowerCase() == 'file'
if typeof type is 'undefined'
schema = param.schema
if schema and schema['$ref']
ref = schema['$ref']
if ref.indexOf('#/definitions/') is 0
type = ref.substring('#/definitions/'.length)
else
type = ref
if type and type.toLowerCase() == 'file'
if !contentTypeModel.consumes
log "set content type "
contentTypeModel.consumes = 'multipart/form-data'
param.type = type
responseContentTypeView = new ResponseContentTypeView({model: contentTypeModel})
$('.response-content-type', $(@el)).append responseContentTypeView.render().el
@@ -131,7 +173,7 @@ class OperationView extends Backbone.View
for o in form.find("textarea")
if(o.value? && jQuery.trim(o.value).length > 0)
map["body"] = o.value
map[o.name] = o.value
for o in form.find("select")
val = this.getSelectedValue o
@@ -171,8 +213,6 @@ class OperationView extends Backbone.View
if param.paramType is 'header'
headerParams[param.name] = map[param.name]
log headerParams
# add files
for el in form.find('input[type~="file"]')
if typeof el.files[0] isnt 'undefined'
@@ -241,7 +281,7 @@ class OperationView extends Backbone.View
options = []
options.push opt.value for opt in select.options when opt.selected
if options.length > 0
options.join ","
options
else
null
@@ -335,19 +375,28 @@ class OperationView extends Backbone.View
headers = response.headers
# if server is nice, and sends content-type back, we can use it
contentType = if headers && headers["Content-Type"] then headers["Content-Type"].split(";")[0].trim() else null
contentType = null
if headers
contentType = headers["Content-Type"] or headers["content-type"]
if contentType
contentType = contentType.split(";")[0].trim()
if !content
code = $('<code />').text("no content")
pre = $('<pre class="json" />').append(code)
else if contentType is "application/json" || /\+json$/.test(contentType)
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, " "))
json = null
try
json = JSON.stringify(JSON.parse(content), null, " ")
catch e
json = "can't parse JSON. Raw result:\n\n" + content
code = $('<code />').text(json)
pre = $('<pre class="json" />').append(code)
else if contentType is "application/xml" || /\+xml$/.test(contentType)
code = $('<code />').text(@formatXml(content))
pre = $('<pre class="xml" />').append(code)
else if contentType is "text/html"
code = $('<code />').html(content)
code = $('<code />').html(_.escape(content))
pre = $('<pre class="xml" />').append(code)
else if /^image\//.test(contentType)
pre = $('<img>').attr('src',url)
@@ -9,8 +9,21 @@ class ParameterView extends Backbone.View
render: ->
type = @model.type || @model.dataType
if typeof type is 'undefined'
schema = @model.schema
if schema and schema['$ref']
ref = schema['$ref']
if ref.indexOf('#/definitions/') is 0
type = ref.substring('#/definitions/'.length)
else
type = ref
@model.type = type
@model.paramType = @model.in || @model.paramType
@model.isBody = true if @model.paramType == 'body'
@model.isFile = true if type.toLowerCase() == 'file'
@model.isFile = true if type and type.toLowerCase() == 'file'
@model.default = (@model.default || @model.defaultValue)
template = @template()
$(@el).html(template(@model))
+14 -3
View File
@@ -1,11 +1,16 @@
class ResourceView extends Backbone.View
initialize: ->
initialize: (opts={}) ->
@auths = opts.auths
if "" is @model.description
@model.description = null
render: ->
$(@el).html(Handlebars.templates.resource(@model))
methods = {}
if @model.description
@model.summary = @model.description
# Render each operation
for operation in @model.operationsArray
counter = 0
@@ -23,7 +28,7 @@ class ResourceView extends Backbone.View
$('.toggleEndpointList', @el).click(this.callDocs.bind(this, 'toggleEndpointListForResource'))
$('.collapseResource', @el).click(this.callDocs.bind(this, 'collapseOperationsForResource'))
$('.expandResource', @el).click(this.callDocs.bind(this, 'expandOperationsForResoruce'))
$('.expandResource', @el).click(this.callDocs.bind(this, 'expandOperationsForResource'))
return @
@@ -32,7 +37,13 @@ class ResourceView extends Backbone.View
operation.number = @number
# Render an operation and add it to operations li
operationView = new OperationView({model: operation, tagName: 'li', className: 'endpoint', swaggerOptions: @options.swaggerOptions})
operationView = new OperationView({
model: operation,
tagName: 'li',
className: 'endpoint',
swaggerOptions: @options.swaggerOptions,
auths: @auths
})
$('.endpoints', $(@el)).append operationView.render().el
@number++
+53 -36
View File
@@ -16,50 +16,67 @@
<script src='lib/underscore-min.js' type='text/javascript'></script>
<script src='lib/backbone-min.js' type='text/javascript'></script>
<script src='lib/swagger.js' type='text/javascript'></script>
<script src='lib/swagger-client.js' type='text/javascript'></script>
<script src='swagger-ui.js' type='text/javascript'></script>
<script src='lib/highlight.7.3.pack.js' type='text/javascript'></script>
<!-- enabling this will enable oauth2 implicit scope support -->
<script src='lib/swagger-oauth.js' type='text/javascript'></script>
<script type="text/javascript">
$(function () {
window.swaggerUi = new SwaggerUi({
url: "http://petstore.swagger.wordnik.com/api/api-docs",
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
onComplete: function(swaggerApi, swaggerUi){
log("Loaded SwaggerUI");
if(typeof initOAuth == "function") {
/*
initOAuth({
clientId: "your-client-id",
realm: "your-realms",
appName: "your-app-name"
});
*/
}
$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
sorter : "alpha"
});
$('#input_apiKey').change(function() {
var key = $('#input_apiKey')[0].value;
log("key: " + key);
if(key && key.trim() != "") {
log("added key " + key);
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "query"));
var url = window.location.search.match(/url=([^&]+)/);
if (url && url.length > 1) {
url = url[1];
} else {
url = "http://petstore.swagger.wordnik.com/v2/swagger.json";
}
})
window.swaggerUi.load();
window.swaggerUi = new SwaggerUi({
url: url,
dom_id: "swagger-ui-container",
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],
onComplete: function(swaggerApi, swaggerUi){
log("Loaded SwaggerUI");
if(typeof initOAuth == "function") {
/*
initOAuth({
clientId: "your-client-id",
realm: "your-realms",
appName: "your-app-name"
});
*/
}
$('pre code').each(function(i, e) {
hljs.highlightBlock(e)
});
},
onFailure: function(data) {
log("Unable to Load SwaggerUI");
},
docExpansion: "none",
sorter : "alpha"
});
function addApiKeyAuthorization() {
var key = $('#input_apiKey')[0].value;
log("key: " + key);
if(key && key.trim() != "") {
log("added key " + key);
window.authorizations.add("api_key", new ApiKeyAuthorization("api_key", key, "query"));
}
}
$('#input_apiKey').change(function() {
addApiKeyAuthorization();
});
// if you have an apiKey you would like to pre-populate on the page for demonstration purposes...
/*
var apiKey = "myApiKeyXXXX123456789";
$('#input_apiKey').val(apiKey);
addApiKeyAuthorization();
*/
window.swaggerUi.load();
});
</script>
</head>
-4
View File
@@ -91,7 +91,6 @@ var Docs = {
switch (fragments.length) {
case 1:
// Expand all operations for the resource and scroll to it
log('shebang resource:' + fragments[0]);
var dom_id = 'resource_' + fragments[0];
Docs.expandEndpointListForResource(fragments[0]);
@@ -99,7 +98,6 @@ var Docs = {
break;
case 2:
// Refer to the endpoint DOM element, e.g. #words_get_search
log('shebang endpoint: ' + fragments.join('_'));
// Expand Resource
Docs.expandEndpointListForResource(fragments[0]);
@@ -109,8 +107,6 @@ var Docs = {
var li_dom_id = fragments.join('_');
var li_content_dom_id = li_dom_id + "_content";
log("li_dom_id " + li_dom_id);
log("li_content_dom_id " + li_content_dom_id);
Docs.expandOperation($('#'+li_content_dom_id));
$('#'+li_dom_id).slideto({highlight: false});
+1 -1
View File
@@ -80,4 +80,4 @@
padding-top: 10px;
}
}
}
@@ -0,0 +1,9 @@
<div class='auth_button' id='apikey_button'><img class='auth_icon' alt='apply api key' src='images/apikey.jpeg'></div>
<div class='auth_container' id='apikey_container'>
<div class='key_input_container'>
<div class='auth_label'>{{keyName}}</div>
<input placeholder="api_key" class="auth_input" id="input_apiKey_entry" name="apiKey" type="text"/>
<div class='auth_submit'><a class='auth_submit_button' id="apply_api_key" href="#">apply</a></div>
</div>
</div>
@@ -0,0 +1,11 @@
<div class='auth_button' id='basic_auth_button'><img class='auth_icon' src='images/password.jpeg'></div>
<div class='auth_container' id='basic_auth_container'>
<div class='key_input_container'>
<div class="auth_label">Username</div>
<input placeholder="username" class="auth_input" id="input_username" name="username" type="text"/>
<div class="auth_label">Password</div>
<input placeholder="password" class="auth_input" id="input_password" name="password" type="password"/>
<div class='auth_submit'><a class='auth_submit_button' id="apply_basic_auth" href="#">apply</a></div>
</div>
</div>
+18 -14
View File
@@ -1,22 +1,26 @@
<div class='info' id='api_info'>
{{#if info}}
<div class="info_title">{{info.title}}</div>
<div class="info_description">{{{info.description}}}</div>
{{#if info.termsOfServiceUrl}}<div class="info_tos"><a href="{{info.termsOfServiceUrl}}">Terms of service</a></div>{{/if}}
{{#if info.contact}}<div class='info_contact'><a href="mailto:{{info.contact}}">Contact the developer</a></div>{{/if}}
{{#if info.license}}<div class='info_license'><a href='{{info.licenseUrl}}'>{{info.license}}</a></div>{{/if}}
<div class="info_title">{{info.title}}</div>
<div class="info_description">{{{info.description}}}</div>
{{#if info.termsOfServiceUrl}}<div class="info_tos"><a href="{{info.termsOfServiceUrl}}">Terms of service</a></div>{{/if}}
{{#if info.contact}}<div class='info_contact'><a href="mailto:{{info.contact.name}}">Contact the developer</a></div>{{/if}}
{{#if info.license}}<div class='info_license'><a href='{{info.license.url}}'>{{info.license.name}}</a></div>{{/if}}
{{/if}}
</div>
<div class='container' id='resources_container'>
<ul id='resources'>
</ul>
<ul id='resources'></ul>
<div class="footer">
<br>
<br>
<h4 style="color: #999">[ <span style="font-variant: small-caps">base url</span>: {{basePath}}
{{#if apiVersion}}
, <span style="font-variant: small-caps">api version</span>: {{apiVersion}}
{{/if}}]</h4>
<div class="footer">
<br>
<br>
<h4 style="color: #999">[ <span style="font-variant: small-caps">base url</span>: {{basePath}}
{{#if info.version}}
, <span style="font-variant: small-caps">api version</span>: {{info.version}}
{{/if}}]
{{#if validatorUrl}}
<span style="float:right"><a href="{{validatorUrl}}/debug?url={{url}}"><img id="validator" src="{{validatorUrl}}?url={{url}}"></a>
</span>
{{/if}}
</h4>
</div>
</div>
+6 -3
View File
@@ -7,7 +7,7 @@
<a href='#!/{{parentId}}/{{nickname}}' class="toggleOperation">{{method}}</a>
</span>
<span class='path'>
<a href='#!/{{parentId}}/{{nickname}}' class="toggleOperation">{{path}}</a>
<a href='#!/{{parentId}}/{{nickname}}' class="toggleOperation {{#if deprecated}}deprecated{{/if}}">{{path}}</a>
</span>
</h3>
<ul class='options'>
@@ -17,9 +17,12 @@
</ul>
</div>
<div class='content' id='{{parentId}}_{{nickname}}_content' style='display:none'>
{{#if notes}}
{{#if deprecated}}
<h4>Warning: Deprecated</h4>
{{/if}}
{{#if description}}
<h4>Implementation Notes</h4>
<p>{{{notes}}}</p>
<p>{{{description}}}</p>
{{/if}}
{{#oauth}}
<div class="auth">
+4 -4
View File
@@ -6,8 +6,8 @@
<input type="file" name='{{name}}'/>
<div class="parameter-content-type" />
{{else}}
{{#if defaultValue}}
<textarea class='body-textarea' name='{{name}}'>{{defaultValue}}</textarea>
{{#if default}}
<textarea class='body-textarea' name='{{name}}'>{{default}}</textarea>
{{else}}
<textarea class='body-textarea' name='{{name}}'></textarea>
<br />
@@ -19,8 +19,8 @@
<input type="file" name='{{name}}'/>
<div class="parameter-content-type" />
{{else}}
{{#if defaultValue}}
<input class='parameter' minlength='0' name='{{name}}' placeholder='' type='text' value='{{defaultValue}}'/>
{{#if default}}
<input class='parameter' minlength='0' name='{{name}}' placeholder='' type='text' value='{{default}}'/>
{{else}}
<input class='parameter' minlength='0' name='{{name}}' placeholder='' type='text' value=''/>
{{/if}}
+3 -3
View File
@@ -1,6 +1,6 @@
<div class='heading'>
<h2>
<a href='#!/{{id}}' class="toggleEndpointList" data-id="{{id}}">{{name}}</a> {{#description}} : {{/description}}{{{description}}}
<a href='#!/{{id}}' class="toggleEndpointList" data-id="{{id}}">{{name}}</a> {{#summary}} : {{/summary}}{{{summary}}}
</h2>
<ul class='options'>
<li>
@@ -16,9 +16,9 @@
Expand Operations
</a>
</li>
<li>
{{#url}}<li>
<a href='{{url}}'>Raw</a>
</li>
</li>{{/url}}
</ul>
</div>
<ul class='endpoints' id='{{id}}_endpoint_list' style='display:none'>
+9 -9
View File
@@ -1,18 +1,18 @@
<div>
<ul class="signature-nav">
<li><a class="description-link" href="#">Model</a></li>
<li><a class="snippet-link" href="#">Model Schema</a></li>
<li><a class="description-link" href="#">Model</a></li>
<li><a class="snippet-link" href="#">Model Schema</a></li>
</ul>
<div>
<div class="signature-container">
<div class="description">
{{{signature}}}
</div>
<div class="description">
{{{signature}}}
</div>
<div class="snippet">
<pre><code>{{sampleJSON}}</code></pre>
<small class="notice"></small>
</div>
<div class="snippet">
<pre><code>{{sampleJSON}}</code></pre>
<small class="notice"></small>
</div>
</div>