Merge branch 'develop_2.0' of github.com:swagger-api/swagger-ui into develop_2.0
This commit is contained in:
7
.travis.yml
Normal file
7
.travis.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- '0.10'
|
||||
install:
|
||||
- export DISPLAY=:99.0
|
||||
- sh -e /etc/init.d/xvfb start
|
||||
- npm install
|
||||
60
Cakefile
60
Cakefile
@@ -1,8 +1,8 @@
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
{exec} = require 'child_process'
|
||||
less = require 'less'
|
||||
handlebars = require 'handlebars'
|
||||
ncp = require 'ncp'
|
||||
|
||||
sourceFiles = [
|
||||
'SwaggerUi'
|
||||
@@ -23,12 +23,12 @@ sourceFiles = [
|
||||
|
||||
task 'clean', 'Removes distribution', ->
|
||||
console.log 'Clearing dist...'
|
||||
exec 'rm -rf dist'
|
||||
rmDir('dist') if fs.existsSync('dist')
|
||||
|
||||
task 'dist', 'Build a distribution', ->
|
||||
console.log "Build distribution in ./dist"
|
||||
fs.mkdirSync('dist') if not path.existsSync('dist')
|
||||
fs.mkdirSync('dist/lib') if not path.existsSync('dist/lib')
|
||||
fs.mkdirSync('dist') if not fs.existsSync('dist')
|
||||
fs.mkdirSync('dist/lib') if not fs.existsSync('dist/lib')
|
||||
|
||||
appContents = new Array remaining = sourceFiles.length
|
||||
for file, index in sourceFiles then do (file, index) ->
|
||||
@@ -67,7 +67,6 @@ task 'dist', 'Build a distribution', ->
|
||||
throw err if err
|
||||
fs.unlink 'dist/_swagger-ui.coffee'
|
||||
console.log ' : Combining with javascript...'
|
||||
|
||||
fs.readFile 'package.json', 'utf8', (err, fileContents) ->
|
||||
obj = JSON.parse(fileContents)
|
||||
exec 'echo "// swagger-ui.js" > dist/swagger-ui.js'
|
||||
@@ -93,13 +92,16 @@ task 'dist', 'Build a distribution', ->
|
||||
|
||||
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 ' !'
|
||||
ncp.ncp 'lib', 'dist/lib', (err) ->
|
||||
reportNcpErrors err
|
||||
console.log ' : Copied swagger-ui libs'
|
||||
fs.mkdirSync('dist/lib') if not fs.existsSync('dist/lib')
|
||||
fs.createReadStream('node_modules/swagger-client/lib/swagger.js').pipe(fs.createWriteStream('dist/lib/swagger.js'));
|
||||
console.log ' : Copied swagger dependencies'
|
||||
ncp.ncp 'src/main/html', 'dist', (err) ->
|
||||
reportNcpErrors err
|
||||
console.log ' : Copied html dependencies'
|
||||
console.log ' !'
|
||||
|
||||
task 'spec', "Run the test suite", ->
|
||||
exec "open spec.html", (err, stdout, stderr) ->
|
||||
@@ -138,3 +140,37 @@ notify = (message) ->
|
||||
# title: 'CoffeeScript'
|
||||
# image: 'bin/CoffeeScript.png'
|
||||
# try require('growl') message, options
|
||||
|
||||
cat = (dest, files) ->
|
||||
for file in files
|
||||
body = fs.readFileSync(file);
|
||||
fs.appendFileSync(dest, body);
|
||||
fs.appendFileSync(dest, "\n");
|
||||
|
||||
rmDir = (dirPath) ->
|
||||
try
|
||||
files = fs.readdirSync(dirPath)
|
||||
catch e
|
||||
return
|
||||
if files.length > 0
|
||||
i = 0
|
||||
|
||||
while i < files.length
|
||||
filePath = dirPath + "/" + files[i]
|
||||
if fs.statSync(filePath).isFile()
|
||||
fs.unlinkSync filePath
|
||||
else
|
||||
rmDir filePath
|
||||
i++
|
||||
fs.rmdirSync dirPath
|
||||
|
||||
reportNcpErrors = (err) ->
|
||||
if Array.isArray(err)
|
||||
console.error "There were errors during the copy."
|
||||
err.forEach (err) ->
|
||||
console.error err.stack or err.message
|
||||
process.exit 1
|
||||
else if err
|
||||
console.error "An error has occurred."
|
||||
console.error err.stack or err.message
|
||||
process.exit 1
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
# Swagger UI
|
||||
|
||||
[](https://travis-ci.org/swagger-api/swagger-ui)
|
||||
|
||||
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
|
||||
|
||||
11
package.json
11
package.json
@@ -4,7 +4,7 @@
|
||||
"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",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "./node_modules/coffee-script/bin/cake dist; ./node_modules/mocha/bin/mocha src/test/e2e/index.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -24,8 +24,13 @@
|
||||
"less": "~1.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"express": "3.x",
|
||||
"chai": "^1.10.0",
|
||||
"cors": "2.1.1",
|
||||
"docco": "0.4.x",
|
||||
"cors": "2.1.1"
|
||||
"express": "3.x",
|
||||
"http-server": "^0.7.4",
|
||||
"mocha": "^2.1.0",
|
||||
"ncp": "^1.0.1",
|
||||
"selenium-webdriver": "^2.44.0"
|
||||
}
|
||||
}
|
||||
|
||||
63
src/test/e2e/index.js
Normal file
63
src/test/e2e/index.js
Normal file
@@ -0,0 +1,63 @@
|
||||
var webdriver = require('selenium-webdriver');
|
||||
var createServer = require('http-server').createServer;
|
||||
var expect = require('chai').expect;
|
||||
var path = require('path')
|
||||
|
||||
var dist = path.join(__dirname, '..', '..', '..', 'dist');
|
||||
var PORT = 8080;
|
||||
|
||||
console.log('started static server from', dist, 'at port', PORT);
|
||||
|
||||
var server = createServer({
|
||||
root: dist,
|
||||
headers: {
|
||||
'Access-Control-Allow-Origin': '*',
|
||||
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept'
|
||||
}
|
||||
});
|
||||
|
||||
server.listen(PORT);
|
||||
|
||||
var driver = new webdriver.Builder().
|
||||
withCapabilities(webdriver.Capabilities.firefox()).
|
||||
build();
|
||||
|
||||
|
||||
describe('basics', function () {
|
||||
|
||||
this.timeout(10 * 1000);
|
||||
|
||||
beforeEach(function () {
|
||||
driver.get('http://localhost:' + PORT);
|
||||
});
|
||||
|
||||
it('should have "Swagger UI" in title', function (done) {
|
||||
|
||||
driver.wait(function() {
|
||||
return driver.getTitle().then(function(title) {
|
||||
var hasTitle = title.indexOf('Swagger UI') > -1;
|
||||
|
||||
if (hasTitle) {
|
||||
expect(title).to.contain('Swagger UI');
|
||||
done();
|
||||
}
|
||||
|
||||
return hasTitle;
|
||||
});
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
|
||||
describe('cleanup', function () {
|
||||
|
||||
it('kills the static server', function () {
|
||||
server.close();
|
||||
});
|
||||
|
||||
it('quit the webdriver', function () {
|
||||
driver.quit();
|
||||
});
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user