Commit 0505d6ca authored by Pavel's avatar Pavel
Browse files

Merge pull request #1 from wordnik/master

Update to latest swagger-ui code
parents 3347d7e9 fcb82bda
fs = require 'fs'
path = require 'path'
{exec} = require 'child_process'
less = require 'less'
sourceFiles = [
'SwaggerUi'
......@@ -71,13 +72,25 @@ task 'dist', 'Build a distribution', ->
console.log ' : Minifying all...'
exec 'java -jar "./bin/yuicompressor-2.4.7.jar" --type js -o ' + 'dist/swagger-ui.min.js ' + 'dist/swagger-ui.js', (err, stdout, stderr) ->
throw err if err
pack()
lessc()
lessc = ->
# Someone who knows CoffeeScript should make this more Coffee-licious
console.log ' : Compiling LESS...'
less.render fs.readFileSync("src/main/less/screen.less", 'utf8'), (err, css) ->
console.log err
fs.writeFileSync("src/main/html/css/screen.css", css)
pack()
pack = ->
console.log ' : Packaging...'
exec 'cp -r lib dist'
console.log ' : Copied swagger-ui libs'
exec 'cp -r node_modules/swagger-client/lib/swagger.js dist/lib'
console.log ' : Copied swagger dependencies'
exec 'cp -r src/main/html/* dist'
console.log ' : Copied html dependencies'
console.log ' !'
task 'spec', "Run the test suite", ->
......@@ -107,6 +120,7 @@ task 'watch', 'Watch source files for changes and autocompile', ->
watchFiles("src/main/template")
watchFiles("src/main/javascript")
watchFiles("src/main/html")
watchFiles("src/main/less")
watchFiles("src/test")
notify = (message) ->
......@@ -115,4 +129,4 @@ notify = (message) ->
# options =
# title: 'CoffeeScript'
# image: 'bin/CoffeeScript.png'
# try require('growl') message, options
\ No newline at end of file
# try require('growl') message, options
......@@ -16,9 +16,10 @@ 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. 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
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
### 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.
......@@ -47,7 +48,7 @@ To use swagger-ui you should take a look at the [source of swagger-ui html page]
window.swaggerUi.load();
```
* *discoveryUrl* 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/wordnik/swagger-core/wiki)
* *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)
......
This diff is collapsed.
......@@ -301,7 +301,7 @@
headers: {},
on: {
error: function(response) {
return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + error.statusText + ")");
return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
},
response: function(rawResponse) {
var response;
......
......@@ -1735,7 +1735,7 @@ helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
if (content === void 0) {
code = $('<code />').text("no content");
pre = $('<pre class="json" />').append(code);
} else if (contentType.indexOf("application/json") === 0) {
} else if (contentType.indexOf("application/json") === 0 || contentType.indexOf("application/hal+json") === 0) {
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, 2));
pre = $('<pre class="json" />').append(code);
} else if (contentType.indexOf("application/xml") === 0) {
......
This diff is collapsed.
......@@ -301,7 +301,7 @@
headers: {},
on: {
error: function(response) {
return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + error.statusText + ")");
return _this.api.fail("Unable to read api '" + _this.name + "' from path " + _this.url + " (server returned " + response.statusText + ")");
},
response: function(rawResponse) {
var response;
......
{
"name": "swagger-ui",
"version": "2.0.1",
"version": "2.0.2",
"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",
......
......@@ -205,7 +205,7 @@ class OperationView extends Backbone.View
if content == undefined
code = $('<code />').text("no content")
pre = $('<pre class="json" />').append(code)
else if contentType.indexOf("application/json") == 0
else if contentType.indexOf("application/json") == 0 || contentType.indexOf("application/hal+json") == 0
code = $('<code />').text(JSON.stringify(JSON.parse(content), null, 2))
pre = $('<pre class="json" />').append(code)
else if contentType.indexOf("application/xml") == 0
......@@ -231,4 +231,4 @@ class OperationView extends Backbone.View
toggleOperationContent: ->
elem = $('#' + Docs.escapeResourceName(@model.resourceName) + "_" + @model.nickname + "_" + @model.method + "_" + @model.number + "_content")
if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem)
\ No newline at end of file
if elem.is(':visible') then Docs.collapseOperation(elem) else Docs.expandOperation(elem)
This diff is collapsed.
/* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
@import 'src/main/less/reset.less';
@import 'src/main/less/specs.less';
#header {
background-color: #89bf04;
padding: 14px;
a#logo {
font-size: 1.5em;
font-weight: bold;
text-decoration: none;
background: transparent url(../images/logo_small.png) no-repeat left center;
padding: 20px 0 20px 40px;
color: white;
}
form#api_selector {
display: block;
clear: none;
float: right;
.input {
display: block;
clear: none;
float: left;
margin: 0 10px 0 0;
input#input_apiKey {
width: 200px;
}
input#input_baseUrl {
width: 400px;
}
a#explore {
display: block;
text-decoration: none;
font-weight: bold;
padding: 6px 8px;
font-size: 0.9em;
color: white;
background-color: #547f00;
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
-o-border-radius: 4px;
-ms-border-radius: 4px;
-khtml-border-radius: 4px;
border-radius: 4px;
}
a#explore:hover {
background-color: #547f00;
}
input {
font-size: 0.9em;
padding: 3px;
margin: 0;
}
}
}
}
#content_message {
margin: 10px 15px;
font-style: italic;
color: #999999;
}
#message-bar {
min-height: 30px;
text-align: center;
padding-top: 10px;
}
\ No newline at end of file
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment