Compare commits
154
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
114add9287 | ||
|
|
50cf3c3597 | ||
|
|
c7fc5d1b65 | ||
|
|
091eca50d9 | ||
|
|
1531dd69a9 | ||
|
|
932f4e35aa | ||
|
|
33f5c2e498 | ||
|
|
48a15e0cb0 | ||
|
|
42dfeab882 | ||
|
|
314b12969a | ||
|
|
8bb9391fa8 | ||
|
|
0b878111b7 | ||
|
|
616085680f | ||
|
|
53fd2f013f | ||
|
|
8888827573 | ||
|
|
af768dcdbf | ||
|
|
187e0a1162 | ||
|
|
8831e289c0 | ||
|
|
329772af4c | ||
|
|
8e20a32344 | ||
|
|
d1d2bc75db | ||
|
|
7457b2027d | ||
|
|
22c7a9672c | ||
|
|
9bdc758147 | ||
|
|
23562cecd0 | ||
|
|
424dde251e | ||
|
|
295fa75dc4 | ||
|
|
cdd02ad8a3 | ||
|
|
aefd35237c | ||
|
|
73f02aa182 | ||
|
|
799069640b | ||
|
|
38112e3cd0 | ||
|
|
918bd9eedb | ||
|
|
2d0b3262f3 | ||
|
|
97d23f61de | ||
|
|
187dacd8e4 | ||
|
|
9ba4c38783 | ||
|
|
32df32da8e | ||
|
|
de0f9d58ee | ||
|
|
bc38d35aea | ||
|
|
1738bf1272 | ||
|
|
4d1e48df39 | ||
|
|
dc84dfc8f8 | ||
|
|
d16b149f39 | ||
|
|
c6fb33a9c7 | ||
|
|
b0301d6ee3 | ||
|
|
97efb054bf | ||
|
|
f882750e5c | ||
|
|
7957201b61 | ||
|
|
52f55054ed | ||
|
|
6b448c1fae | ||
|
|
559221de56 | ||
|
|
2bedc01807 | ||
|
|
e52f83b501 | ||
|
|
20c555306f | ||
|
|
03dd9fb7f4 | ||
|
|
a4a6c6191b | ||
|
|
4d2ad25a10 | ||
|
|
23fe6d337b | ||
|
|
841acc6db0 | ||
|
|
5823358e73 | ||
|
|
a39ab425bf | ||
|
|
b0eff2d78b | ||
|
|
1eac80abdd | ||
|
|
162ec41fcc | ||
|
|
cbead84f8e | ||
|
|
25c4ab4d5e | ||
|
|
db28e8b6db | ||
|
|
b7a452eca3 | ||
|
|
4e15e9a068 | ||
|
|
b9e79d6824 | ||
|
|
1842c41b10 | ||
|
|
607cca6229 | ||
|
|
d3f373c188 | ||
|
|
8918fa1c24 | ||
|
|
3492c72024 | ||
|
|
0209cdd42b | ||
|
|
af6eed4eb4 | ||
|
|
2eabeb667a | ||
|
|
d838073389 | ||
|
|
922848b195 | ||
|
|
da661827bf | ||
|
|
82e9ceaca6 | ||
|
|
0cabc3017b | ||
|
|
fedb12960b | ||
|
|
8258d8b4d9 | ||
|
|
b9d6f388e9 | ||
|
|
2edfb5ef0c | ||
|
|
35aac47df3 | ||
|
|
19c34cf1ea | ||
|
|
ad3e9e5481 | ||
|
|
3a43a4cd91 | ||
|
|
a0f398853a | ||
|
|
5bdc109746 | ||
|
|
252100b704 | ||
|
|
55a5abb9c7 | ||
|
|
d9f13e9163 | ||
|
|
7570e85389 | ||
|
|
e7b803b018 | ||
|
|
a26651a3bd | ||
|
|
6675568d09 | ||
|
|
bd354103f1 | ||
|
|
c0b11e4719 | ||
|
|
4e508c0a1e | ||
|
|
b9c631e09e | ||
|
|
4ad4b499ee | ||
|
|
26734d711e | ||
|
|
ba14498fbd | ||
|
|
390c8c8408 | ||
|
|
bc4f60a955 | ||
|
|
88118bfc32 | ||
|
|
b653a9909b | ||
|
|
91822035ef | ||
|
|
394afba3e5 | ||
|
|
b2096eb21b | ||
|
|
0c44f83c26 | ||
|
|
674b288fe6 | ||
|
|
0cdcbfb70b | ||
|
|
0395bf3eb3 | ||
|
|
264ba2910d | ||
|
|
66718f23dd | ||
|
|
7b3b7066eb | ||
|
|
7a91117b6f | ||
|
|
963c009870 | ||
|
|
bdec07e8c3 | ||
|
|
9b0aa32941 | ||
|
|
b1964254c5 | ||
|
|
3a7b66d345 | ||
|
|
5da60bfa62 | ||
|
|
f8991bc7f5 | ||
|
|
ec81d25cb0 | ||
|
|
2b08c0e209 | ||
|
|
ee199633f6 | ||
|
|
4ea20859c7 | ||
|
|
0a52e344e7 | ||
|
|
e04b756521 | ||
|
|
9955bcc69f | ||
|
|
c17cc1010f | ||
|
|
2de104aac9 | ||
|
|
fbe5278928 | ||
|
|
b09a8e91c9 | ||
|
|
c3904c54c8 | ||
|
|
26db2ce375 | ||
|
|
28c7597138 | ||
|
|
c948b40d34 | ||
|
|
5d2bed7025 | ||
|
|
6dc12f733e | ||
|
|
dfd5e937d4 | ||
|
|
9d0417e7f2 | ||
|
|
8ad46f0813 | ||
|
|
db6419414c | ||
|
|
9b9b5b4551 | ||
|
|
50ded295d9 | ||
|
|
525241fcd2 |
@@ -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...'
|
||||
|
||||
@@ -1,19 +1,28 @@
|
||||
# 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 part of the 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
|
||||
generate beautiful documentation and sandbox from a Swagger-compliant API. Because Swagger UI has no dependencies, you can host it in any server environment, or on your local machine.
|
||||
|
||||
## 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.
|
||||
|
||||
|
||||
## Compatibility
|
||||
The Swagger Specification has undergone 3 revisions since initial creation in 2010. Compatibility between swagger-ui and the Swagger specification is as follows:
|
||||
|
||||
Swagger UI Version | Release Date | Swagger Spec compatibility | 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,21 +63,23 @@ 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)
|
||||
* *sorter* apply a sort to the API list. It can be 'alpha' (sort paths alphanumerically) or 'method' (sort operations by HTTP method). Default is the order returned by the server unchanged.
|
||||
* *onComplete* is a callback function parameter which can be passed to be notified of when SwaggerUI has completed rendering successfully.
|
||||
* *onFailure* is a callback function parameter which can be passed to be notified of when SwaggerUI encountered a failure was unable to render.
|
||||
* *highlightSizeThreshold* any size response below this threshold will be highlighted syntactically, attempting to highlight large responses can lead to browser hangs, not including a threshold will default to highlight all returned responses
|
||||
* All other parameters are explained in greater detail below
|
||||
|
||||
|
||||
### 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.
|
||||
@@ -94,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.
|
||||
|
||||
|
||||
Vendored
+8
-5
@@ -743,17 +743,20 @@
|
||||
display: inline-block;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header img {
|
||||
display: block;
|
||||
clear: none;
|
||||
float: right;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header input.submit {
|
||||
display: block;
|
||||
clear: none;
|
||||
float: left;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header span.response_throbber {
|
||||
background-image: url('../images/throbber.gif');
|
||||
width: 128px;
|
||||
height: 16px;
|
||||
display: block;
|
||||
clear: none;
|
||||
float: right;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form input[type='text'].error {
|
||||
outline: 2px solid black;
|
||||
outline-color: #cc0000;
|
||||
|
||||
Vendored
+54
-42
@@ -16,49 +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"
|
||||
});
|
||||
|
||||
$('#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>
|
||||
@@ -66,14 +84,8 @@
|
||||
<body class="swagger-section">
|
||||
<div id='header'>
|
||||
<div class="swagger-ui-wrap">
|
||||
<a id="logo" href="http://swagger.wordnik.com">swagger</a>
|
||||
<a id="logo" href="http://swagger.io">swagger</a>
|
||||
<form id='api_selector'>
|
||||
<div class='input icon-btn'>
|
||||
<img id="show-pet-store-icon" src="images/pet_store_api.png" title="Show Swagger Petstore Example Apis">
|
||||
</div>
|
||||
<div class='input icon-btn'>
|
||||
<img id="show-wordnik-dev-icon" src="images/wordnik_api.png" title="Show Wordnik Developer Apis">
|
||||
</div>
|
||||
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
|
||||
<div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
|
||||
<div class='input'><a id="explore" href="#">Explore</a></div>
|
||||
|
||||
Vendored
+3
-3
@@ -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 ...
|
||||
|
||||
Vendored
+1489
File diff suppressed because it is too large
Load Diff
Vendored
+106
-87
@@ -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,102 +37,103 @@ 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),
|
||||
dw = $win.width(),
|
||||
dh = $win.height(),
|
||||
st = $win.scrollTop(),
|
||||
dlgWd = popupDialog.outerWidth(),
|
||||
dlgHt = popupDialog.outerHeight(),
|
||||
top = (dh -dlgHt)/2 + st,
|
||||
left = (dw - dlgWd)/2;
|
||||
var $win = $(window),
|
||||
dw = $win.width(),
|
||||
dh = $win.height(),
|
||||
st = $win.scrollTop(),
|
||||
dlgWd = popupDialog.outerWidth(),
|
||||
dlgHt = popupDialog.outerHeight(),
|
||||
top = (dh -dlgHt)/2 + st,
|
||||
left = (dw - dlgWd)/2;
|
||||
|
||||
popupDialog.css({
|
||||
top: (top < 0? 0 : top) + 'px',
|
||||
left: (left < 0? 0 : left) + 'px'
|
||||
});
|
||||
popupDialog.css({
|
||||
top: (top < 0? 0 : top) + 'px',
|
||||
left: (left < 0? 0 : left) + 'px'
|
||||
});
|
||||
|
||||
popupDialog.find('button.api-popup-cancel').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
});
|
||||
popupDialog.find('button.api-popup-authbtn').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
popupDialog.find('button.api-popup-cancel').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
popupDialog.empty();
|
||||
popupDialog = [];
|
||||
});
|
||||
|
||||
var authSchemes = window.swaggerUi.api.authSchemes;
|
||||
var location = window.location;
|
||||
var locationUrl = location.protocol + '//' + location.host + location.pathname;
|
||||
var redirectUrl = locationUrl.replace("index.html","").concat("/o2c.html").replace("//o2c.html","/o2c.html");
|
||||
var url = null;
|
||||
popupDialog.find('button.api-popup-authbtn').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
|
||||
var p = window.swaggerUi.api.authSchemes;
|
||||
for (var key in p) {
|
||||
if (p.hasOwnProperty(key)) {
|
||||
var o = p[key].grantTypes;
|
||||
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 url = null;
|
||||
|
||||
for (var key in authSchemes) {
|
||||
if (authSchemes.hasOwnProperty(key)) {
|
||||
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];
|
||||
url = dets.loginEndpoint.url + "?response_type=token";
|
||||
var ep = dets.loginEndpoint.url;
|
||||
url = dets.loginEndpoint.url + '?response_type=token';
|
||||
window.swaggerUi.tokenName = dets.tokenName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var scopes = [];
|
||||
var scopeForUrl='';
|
||||
var o = $('.api-popup-scopes').find('input:checked');
|
||||
}
|
||||
var scopes = []
|
||||
var o = $('.api-popup-scopes').find('input:checked');
|
||||
|
||||
for(var k =0; k < o.length; k++) {
|
||||
scopes.push($(o[k]).attr("scope"));
|
||||
if(k > 0){
|
||||
scopeForUrl+=' ';
|
||||
}
|
||||
scopeForUrl+=$(o[k]).attr("scope");
|
||||
}
|
||||
for(k =0; k < o.length; k++) {
|
||||
scopes.push($(o[k]).attr('scope'));
|
||||
}
|
||||
|
||||
window.enabledScopes=scopes;
|
||||
|
||||
window.enabledScopes=scopes;
|
||||
|
||||
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
|
||||
url += '&realm=' + encodeURIComponent(realm);
|
||||
url += '&client_id=' + encodeURIComponent(clientId);
|
||||
url += '&scope=' + encodeURIComponent(scopeForUrl);
|
||||
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
|
||||
url += '&realm=' + encodeURIComponent(realm);
|
||||
url += '&client_id=' + encodeURIComponent(clientId);
|
||||
url += '&scope=' + encodeURIComponent(scopes);
|
||||
|
||||
window.open(url);
|
||||
});
|
||||
|
||||
window.open(url);
|
||||
});
|
||||
}
|
||||
popupMask.show();
|
||||
popupDialog.show();
|
||||
return;
|
||||
@@ -137,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;
|
||||
}
|
||||
|
||||
@@ -210,8 +230,7 @@ function onOAuthComplete(token) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
window.authorizations.add("key", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header"));
|
||||
window.authorizations.add('oauth2', new ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1581
-1472
File diff suppressed because it is too large
Load Diff
Vendored
+555
-152
File diff suppressed because it is too large
Load Diff
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+3
-3
@@ -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
+106
-87
@@ -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,102 +37,103 @@ 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),
|
||||
dw = $win.width(),
|
||||
dh = $win.height(),
|
||||
st = $win.scrollTop(),
|
||||
dlgWd = popupDialog.outerWidth(),
|
||||
dlgHt = popupDialog.outerHeight(),
|
||||
top = (dh -dlgHt)/2 + st,
|
||||
left = (dw - dlgWd)/2;
|
||||
var $win = $(window),
|
||||
dw = $win.width(),
|
||||
dh = $win.height(),
|
||||
st = $win.scrollTop(),
|
||||
dlgWd = popupDialog.outerWidth(),
|
||||
dlgHt = popupDialog.outerHeight(),
|
||||
top = (dh -dlgHt)/2 + st,
|
||||
left = (dw - dlgWd)/2;
|
||||
|
||||
popupDialog.css({
|
||||
top: (top < 0? 0 : top) + 'px',
|
||||
left: (left < 0? 0 : left) + 'px'
|
||||
});
|
||||
popupDialog.css({
|
||||
top: (top < 0? 0 : top) + 'px',
|
||||
left: (left < 0? 0 : left) + 'px'
|
||||
});
|
||||
|
||||
popupDialog.find('button.api-popup-cancel').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
});
|
||||
popupDialog.find('button.api-popup-authbtn').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
popupDialog.find('button.api-popup-cancel').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
popupDialog.empty();
|
||||
popupDialog = [];
|
||||
});
|
||||
|
||||
var authSchemes = window.swaggerUi.api.authSchemes;
|
||||
var location = window.location;
|
||||
var locationUrl = location.protocol + '//' + location.host + location.pathname;
|
||||
var redirectUrl = locationUrl.replace("index.html","").concat("/o2c.html").replace("//o2c.html","/o2c.html");
|
||||
var url = null;
|
||||
popupDialog.find('button.api-popup-authbtn').click(function() {
|
||||
popupMask.hide();
|
||||
popupDialog.hide();
|
||||
|
||||
var p = window.swaggerUi.api.authSchemes;
|
||||
for (var key in p) {
|
||||
if (p.hasOwnProperty(key)) {
|
||||
var o = p[key].grantTypes;
|
||||
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 url = null;
|
||||
|
||||
for (var key in authSchemes) {
|
||||
if (authSchemes.hasOwnProperty(key)) {
|
||||
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];
|
||||
url = dets.loginEndpoint.url + "?response_type=token";
|
||||
var ep = dets.loginEndpoint.url;
|
||||
url = dets.loginEndpoint.url + '?response_type=token';
|
||||
window.swaggerUi.tokenName = dets.tokenName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
var scopes = [];
|
||||
var scopeForUrl='';
|
||||
var o = $('.api-popup-scopes').find('input:checked');
|
||||
}
|
||||
var scopes = []
|
||||
var o = $('.api-popup-scopes').find('input:checked');
|
||||
|
||||
for(var k =0; k < o.length; k++) {
|
||||
scopes.push($(o[k]).attr("scope"));
|
||||
if(k > 0){
|
||||
scopeForUrl+=' ';
|
||||
}
|
||||
scopeForUrl+=$(o[k]).attr("scope");
|
||||
}
|
||||
for(k =0; k < o.length; k++) {
|
||||
scopes.push($(o[k]).attr('scope'));
|
||||
}
|
||||
|
||||
window.enabledScopes=scopes;
|
||||
|
||||
window.enabledScopes=scopes;
|
||||
|
||||
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
|
||||
url += '&realm=' + encodeURIComponent(realm);
|
||||
url += '&client_id=' + encodeURIComponent(clientId);
|
||||
url += '&scope=' + encodeURIComponent(scopeForUrl);
|
||||
url += '&redirect_uri=' + encodeURIComponent(redirectUrl);
|
||||
url += '&realm=' + encodeURIComponent(realm);
|
||||
url += '&client_id=' + encodeURIComponent(clientId);
|
||||
url += '&scope=' + encodeURIComponent(scopes);
|
||||
|
||||
window.open(url);
|
||||
});
|
||||
|
||||
window.open(url);
|
||||
});
|
||||
}
|
||||
popupMask.show();
|
||||
popupDialog.show();
|
||||
return;
|
||||
@@ -137,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;
|
||||
}
|
||||
|
||||
@@ -210,8 +230,7 @@ function onOAuthComplete(token) {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
window.authorizations.add("key", new ApiKeyAuthorization("Authorization", "Bearer " + b, "header"));
|
||||
window.authorizations.add('oauth2', new ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1581
-1472
File diff suppressed because it is too large
Load Diff
+3
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "swagger-ui",
|
||||
"version": "2.0.18",
|
||||
"version": "2.1.0-alpha.6",
|
||||
"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",
|
||||
@@ -18,8 +18,8 @@
|
||||
"license": "Apache",
|
||||
"readmeFilename": "README.md",
|
||||
"dependencies": {
|
||||
"coffee-script": "~1.5.0",
|
||||
"swagger-client": "2.0.29",
|
||||
"coffee-script": "~1.6.3",
|
||||
"swagger-client": "2.0.41",
|
||||
"handlebars": "~1.0.10",
|
||||
"less": "~1.4.2"
|
||||
}
|
||||
|
||||
@@ -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,15 +62,15 @@ 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
|
||||
render:() ->
|
||||
@showMessage('Finished Loading Resource Information. Rendering Swagger UI...')
|
||||
@mainView = new MainView({model: @api, el: $('#' + @dom_id)}).render()
|
||||
@mainView = new MainView({model: @api, el: $('#' + @dom_id), swaggerOptions: @options}).render()
|
||||
@showMessage()
|
||||
switch @options.docExpansion
|
||||
when "full" then Docs.expandOperationsForResource('')
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,7 +1,52 @@
|
||||
class MainView extends Backbone.View
|
||||
initialize: ->
|
||||
sorters = {
|
||||
'alpha' : (a,b) -> return a.path.localeCompare(b.path),
|
||||
'method' : (a,b) -> return a.method.localeCompare(b.method),
|
||||
}
|
||||
|
||||
initialize: (opts={}) ->
|
||||
# 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.indexOf("localhost") > 0
|
||||
# Localhost override
|
||||
@model.validatorUrl = null
|
||||
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))
|
||||
|
||||
@@ -16,13 +61,21 @@ 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'})
|
||||
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: ->
|
||||
$(@el).html ''
|
||||
$(@el).html ''
|
||||
|
||||
@@ -10,12 +10,15 @@ 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')
|
||||
x = event.pageX
|
||||
y = event.pageY
|
||||
x = e.pageX
|
||||
y = e.pageY
|
||||
scX = $(window).scrollLeft()
|
||||
scY = $(window).scrollTop()
|
||||
scMaxX = scX + $(window).width()
|
||||
@@ -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
|
||||
@@ -162,7 +204,7 @@ class OperationView extends Backbone.View
|
||||
# add params
|
||||
for param in @model.parameters
|
||||
if param.paramType is 'form'
|
||||
if map[param.name] != undefined
|
||||
if param.type.toLowerCase() isnt 'file' and map[param.name] != undefined
|
||||
bodyParam.append(param.name, map[param.name])
|
||||
|
||||
# headers in operation
|
||||
@@ -171,16 +213,12 @@ 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'
|
||||
bodyParam.append($(el).attr('name'), el.files[0])
|
||||
params += 1
|
||||
|
||||
log(bodyParam)
|
||||
|
||||
@invocationUrl =
|
||||
if @model.supportHeaderParams()
|
||||
headerParams = @model.getHeaderParams(map)
|
||||
@@ -188,8 +226,9 @@ class OperationView extends Backbone.View
|
||||
else
|
||||
@model.urlify(map, true)
|
||||
|
||||
$(".request_url", $(@el)).html "<pre>" + @invocationUrl + "</pre>"
|
||||
|
||||
$(".request_url", $(@el)).html("<pre></pre>")
|
||||
$(".request_url pre", $(@el)).text(@invocationUrl);
|
||||
|
||||
obj =
|
||||
type: @model.method
|
||||
url: @invocationUrl
|
||||
@@ -242,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
|
||||
|
||||
@@ -336,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)
|
||||
@@ -358,14 +406,18 @@ class OperationView extends Backbone.View
|
||||
pre = $('<pre class="json" />').append(code)
|
||||
|
||||
response_body = pre
|
||||
$(".request_url", $(@el)).html "<pre>" + url + "</pre>"
|
||||
$(".request_url", $(@el)).html("<pre></pre>")
|
||||
$(".request_url pre", $(@el)).text(url);
|
||||
$(".response_code", $(@el)).html "<pre>" + response.status + "</pre>"
|
||||
$(".response_body", $(@el)).html response_body
|
||||
$(".response_headers", $(@el)).html "<pre>" + JSON.stringify(response.headers, null, " ").replace(/\n/g, "<br>") + "</pre>"
|
||||
$(".response_headers", $(@el)).html "<pre>" + _.escape(JSON.stringify(response.headers, null, " ")).replace(/\n/g, "<br>") + "</pre>"
|
||||
$(".response", $(@el)).slideDown()
|
||||
$(".response_hider", $(@el)).show()
|
||||
$(".response_throbber", $(@el)).hide()
|
||||
hljs.highlightBlock($('.response_body', $(@el))[0])
|
||||
response_body_el = $('.response_body', $(@el))[0]
|
||||
# only highlight the response if response is less than threshold, default state is highlight response
|
||||
opts = @options.swaggerOptions
|
||||
if opts.highlightSizeThreshold && response.data.length > opts.highlightSizeThreshold then response_body_el else hljs.highlightBlock(response_body_el)
|
||||
|
||||
toggleOperationContent: ->
|
||||
elem = $('#' + Docs.escapeResourceName(@model.parentId) + "_" + @model.nickname + "_content")
|
||||
|
||||
@@ -9,8 +9,24 @@ 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)
|
||||
|
||||
if@model.allowableValues
|
||||
@model.isList = true
|
||||
|
||||
template = @template()
|
||||
$(@el).html(template(@model))
|
||||
|
||||
@@ -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
|
||||
@@ -20,14 +25,33 @@ class ResourceView extends Backbone.View
|
||||
operation.nickname = id
|
||||
operation.parentId = @model.id
|
||||
@addOperation operation
|
||||
@
|
||||
|
||||
$('.toggleEndpointList', @el).click(this.callDocs.bind(this, 'toggleEndpointListForResource'))
|
||||
$('.collapseResource', @el).click(this.callDocs.bind(this, 'collapseOperationsForResource'))
|
||||
$('.expandResource', @el).click(this.callDocs.bind(this, 'expandOperationsForResource'))
|
||||
|
||||
return @
|
||||
|
||||
addOperation: (operation) ->
|
||||
|
||||
operation.number = @number
|
||||
|
||||
# Render an operation and add it to operations li
|
||||
operationView = new OperationView({model: operation, tagName: 'li', className: 'endpoint'})
|
||||
operationView = new OperationView({
|
||||
model: operation,
|
||||
tagName: 'li',
|
||||
className: 'endpoint',
|
||||
swaggerOptions: @options.swaggerOptions,
|
||||
auths: @auths
|
||||
})
|
||||
$('.endpoints', $(@el)).append operationView.render().el
|
||||
|
||||
@number++
|
||||
@number++
|
||||
|
||||
#
|
||||
# Generic Event handler (`Docs` is global)
|
||||
#
|
||||
|
||||
callDocs: (fnName, e) ->
|
||||
e.preventDefault()
|
||||
Docs[fnName](e.currentTarget.getAttribute('data-id'))
|
||||
|
||||
@@ -743,17 +743,20 @@
|
||||
display: inline-block;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header img {
|
||||
display: block;
|
||||
clear: none;
|
||||
float: right;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header input.submit {
|
||||
display: block;
|
||||
clear: none;
|
||||
float: left;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content div.sandbox_header span.response_throbber {
|
||||
background-image: url('../images/throbber.gif');
|
||||
width: 128px;
|
||||
height: 16px;
|
||||
display: block;
|
||||
clear: none;
|
||||
float: right;
|
||||
}
|
||||
.swagger-section .swagger-ui-wrap ul#resources li.resource ul.endpoints li.endpoint ul.operations li.operation div.content form input[type='text'].error {
|
||||
outline: 2px solid black;
|
||||
outline-color: #cc0000;
|
||||
|
||||
+54
-42
@@ -16,49 +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"
|
||||
});
|
||||
|
||||
$('#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>
|
||||
@@ -66,14 +84,8 @@
|
||||
<body class="swagger-section">
|
||||
<div id='header'>
|
||||
<div class="swagger-ui-wrap">
|
||||
<a id="logo" href="http://swagger.wordnik.com">swagger</a>
|
||||
<a id="logo" href="http://swagger.io">swagger</a>
|
||||
<form id='api_selector'>
|
||||
<div class='input icon-btn'>
|
||||
<img id="show-pet-store-icon" src="images/pet_store_api.png" title="Show Swagger Petstore Example Apis">
|
||||
</div>
|
||||
<div class='input icon-btn'>
|
||||
<img id="show-wordnik-dev-icon" src="images/wordnik_api.png" title="Show Wordnik Developer Apis">
|
||||
</div>
|
||||
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
|
||||
<div class='input'><input placeholder="api_key" id="input_apiKey" name="apiKey" type="text"/></div>
|
||||
<div class='input'><a id="explore" href="#">Explore</a></div>
|
||||
|
||||
@@ -66,7 +66,7 @@ log = function(){
|
||||
log.history = log.history || [];
|
||||
log.history.push(arguments);
|
||||
if(this.console){
|
||||
console.log( Array.prototype.slice.call(arguments) );
|
||||
console.log( Array.prototype.slice.call(arguments)[0] );
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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});
|
||||
|
||||
@@ -80,4 +80,4 @@
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -671,17 +671,20 @@
|
||||
display: inline-block;
|
||||
font-size: 0.9em;
|
||||
}
|
||||
img {
|
||||
display: block;
|
||||
clear: none;
|
||||
float: right;
|
||||
}
|
||||
input.submit {
|
||||
display: block;
|
||||
clear: none;
|
||||
float: left;
|
||||
padding: 6px 8px;
|
||||
}
|
||||
span.response_throbber {
|
||||
background-image: url('../images/throbber.gif');
|
||||
width: 128px;
|
||||
height: 16px;
|
||||
display: block;
|
||||
clear: none;
|
||||
float: right;
|
||||
}
|
||||
}
|
||||
form {
|
||||
input[type='text'].error {
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -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">
|
||||
@@ -83,7 +86,7 @@
|
||||
<div class='sandbox_header'>
|
||||
<input class='submit' name='commit' type='button' value='Try it out!' />
|
||||
<a href='#' class='response_hider' style='display:none'>Hide Response</a>
|
||||
<img alt='Throbber' class='response_throbber' src='images/throbber.gif' style='display:none' />
|
||||
<span class='response_throbber' style='display:none'></span>
|
||||
</div>
|
||||
{{/if}}
|
||||
</form>
|
||||
|
||||
@@ -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 />
|
||||
@@ -15,10 +15,15 @@
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#if defaultValue}}
|
||||
<input class='parameter' minlength='0' name='{{name}}' placeholder='' type='text' value='{{defaultValue}}'/>
|
||||
{{#if isFile}}
|
||||
<input type="file" name='{{name}}'/>
|
||||
<div class="parameter-content-type" />
|
||||
{{else}}
|
||||
<input class='parameter' minlength='0' name='{{name}}' placeholder='' type='text' value=''/>
|
||||
{{#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}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<select {{#isArray this}} multiple='multiple'{{/isArray}} class='parameter' name='{{name}}'>
|
||||
{{#if required}}
|
||||
{{else}}
|
||||
{{#if defaultValue}}
|
||||
{{#if default}}
|
||||
{{else}}
|
||||
{{#isArray this}}
|
||||
{{else}}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<td class='code'>{{name}}</td>
|
||||
<td>
|
||||
{{#if isBody}}
|
||||
<textarea class='body-textarea' readonly='readonly' name='{{name}}'>{{defaultValue}}</textarea>
|
||||
<textarea class='body-textarea' readonly='readonly' name='{{name}}'>{{default}}</textarea>
|
||||
{{else}}
|
||||
{{#if defaultValue}}
|
||||
{{defaultValue}}
|
||||
{{#if default}}
|
||||
{{default}}
|
||||
{{else}}
|
||||
(empty)
|
||||
{{/if}}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<td class='code required'>{{name}}</td>
|
||||
<td>
|
||||
{{#if isBody}}
|
||||
<textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='{{name}}'>{{defaultValue}}</textarea>
|
||||
<textarea class='body-textarea' readonly='readonly' placeholder='(required)' name='{{name}}'>{{default}}</textarea>
|
||||
{{else}}
|
||||
{{#if defaultValue}}
|
||||
{{defaultValue}}
|
||||
{{#if default}}
|
||||
{{default}}
|
||||
{{else}}
|
||||
(empty)
|
||||
{{/if}}
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
{{#if isFile}}
|
||||
<input type="file" name='{{name}}'/>
|
||||
{{else}}
|
||||
{{#if defaultValue}}
|
||||
<textarea class='body-textarea' placeholder='(required)' name='{{name}}'>{{defaultValue}}</textarea>
|
||||
{{#if default}}
|
||||
<textarea class='body-textarea' placeholder='(required)' name='{{name}}'>{{default}}</textarea>
|
||||
{{else}}
|
||||
<textarea class='body-textarea' placeholder='(required)' name='{{name}}'></textarea>
|
||||
<br />
|
||||
@@ -16,8 +16,8 @@
|
||||
{{#if isFile}}
|
||||
<input class='parameter' class='required' type='file' name='{{name}}'/>
|
||||
{{else}}
|
||||
{{#if defaultValue}}
|
||||
<input class='parameter required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value='{{defaultValue}}'/>
|
||||
{{#if default}}
|
||||
<input class='parameter required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value='{{default}}'/>
|
||||
{{else}}
|
||||
<input class='parameter required' minlength='1' name='{{name}}' placeholder='(required)' type='text' value=''/>
|
||||
{{/if}}
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
<div class='heading'>
|
||||
<h2>
|
||||
<a href='#!/{{id}}' onclick="Docs.toggleEndpointListForResource('{{id}}');">{{name}}</a> {{#description}} : {{/description}}{{{description}}}
|
||||
<a href='#!/{{id}}' class="toggleEndpointList" data-id="{{id}}">{{name}}</a> {{#summary}} : {{/summary}}{{{summary}}}
|
||||
</h2>
|
||||
<ul class='options'>
|
||||
<li>
|
||||
<a href='#!/{{id}}' id='endpointListTogger_{{id}}'
|
||||
onclick="Docs.toggleEndpointListForResource('{{id}}');">Show/Hide</a>
|
||||
<a href='#!/{{id}}' id='endpointListTogger_{{id}}' class="toggleEndpointList" data-id="{{id}}">Show/Hide</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='#' onclick="Docs.collapseOperationsForResource('{{id}}'); return false;">
|
||||
<a href='#' class="collapseResource" data-id="{{id}}">
|
||||
List Operations
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='#' onclick="Docs.expandOperationsForResource('{{id}}'); return false;">
|
||||
<a href='#' class="expandResource" data-id={{id}}>
|
||||
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'>
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user