swagger-ui
Advanced tools
Comparing version 2.1.5-M1 to 2.1.5-M2
@@ -100,3 +100,4 @@ var appName; | ||
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/")); | ||
var redirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html'; | ||
var defaultRedirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html'; | ||
var redirectUrl = window.oAuthRedirectUrl || defaultRedirectUrl; | ||
var url = null; | ||
@@ -107,3 +108,3 @@ | ||
var flow = authSchemes[key].flow; | ||
if(authSchemes[key].type === 'oauth2' && flow && (flow === 'implicit' || flow === 'accessCode')) { | ||
@@ -113,3 +114,3 @@ var dets = authSchemes[key]; | ||
window.swaggerUi.tokenName = dets.tokenName || 'access_token'; | ||
window.swaggerUi.tokenUrl = (flow === 'accessCode' ? dets.tokenUrl : null); | ||
window.swaggerUi.tokenUrl = (flow === 'accessCode' ? dets.tokenUrl : null); | ||
} | ||
@@ -141,3 +142,3 @@ else if(authSchemes[key].grantTypes) { | ||
var scope = $(o[k]).attr('scope'); | ||
if (scopes.indexOf(scope) === -1) | ||
@@ -147,2 +148,5 @@ scopes.push(scope); | ||
// Implicit auth recommends a state parameter. | ||
var state = Math.random (); | ||
window.enabledScopes=scopes; | ||
@@ -155,3 +159,4 @@ | ||
url += '&client_id=' + encodeURIComponent(clientId); | ||
url += '&scope=' + encodeURIComponent(scopes); | ||
url += '&scope=' + encodeURIComponent(scopes.join(' ')); | ||
url += '&state=' + encodeURIComponent(state); | ||
@@ -207,3 +212,3 @@ window.open(url); | ||
function processOAuthCode(data) { | ||
window.processOAuthCode = function processOAuthCode(data) { | ||
var params = { | ||
@@ -220,7 +225,7 @@ 'client_id': clientId, | ||
data: params, | ||
success:function(data, textStatus, jqXHR) | ||
success:function(data, textStatus, jqXHR) | ||
{ | ||
onOAuthComplete(data); | ||
}, | ||
error: function(jqXHR, textStatus, errorThrown) | ||
error: function(jqXHR, textStatus, errorThrown) | ||
{ | ||
@@ -232,3 +237,3 @@ onOAuthComplete(""); | ||
function onOAuthComplete(token) { | ||
window.onOAuthComplete = function onOAuthComplete(token) { | ||
if(token) { | ||
@@ -280,10 +285,10 @@ if(token.error) { | ||
$(o).find('.api-ic').removeClass('ic-warning'); | ||
$(o).find('.api-ic').removeClass('ic-error'); | ||
$(o).find('.api-ic').removeClass('ic-error'); | ||
} | ||
} | ||
}); | ||
window.authorizations.add(oauth2KeyName, new ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header')); | ||
window.swaggerUi.api.clientAuthorizations.add(oauth2KeyName, new SwaggerClient.ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header')); | ||
} | ||
} | ||
} | ||
} | ||
} |
@@ -5,5 +5,3 @@ 'use strict'; | ||
var es = require('event-stream'); | ||
var gutil = require('gulp-util'); | ||
var clean = require('gulp-clean'); | ||
var coffee = require('gulp-coffee'); | ||
var concat = require('gulp-concat'); | ||
@@ -20,2 +18,4 @@ var uglify = require('gulp-uglify'); | ||
var pkg = require('./package.json'); | ||
var order = require('gulp-order'); | ||
var jshint = require('gulp-jshint'); | ||
var banner = ['/**', | ||
@@ -36,3 +36,3 @@ ' * <%= pkg.name %> - <%= pkg.description %>', | ||
.pipe(clean({force: true})) | ||
.on('error', gutil.log); | ||
.on('error', log); | ||
}); | ||
@@ -52,14 +52,13 @@ | ||
})) | ||
.on('error', gutil.log); | ||
.on('error', log); | ||
} | ||
/** | ||
* Processes CoffeeScript files | ||
* JShint all *.js files | ||
*/ | ||
function coffeescript () { | ||
return gulp | ||
.src(['./src/main/coffeescript/**/*.coffee']) | ||
.pipe(coffee({bare: true})) | ||
.on('error', gutil.log); | ||
} | ||
gulp.task('lint', function () { | ||
return gulp.src('./src/main/javascript/**/*.js') | ||
.pipe(jshint()) | ||
.pipe(jshint.reporter('jshint-stylish')); | ||
}); | ||
@@ -69,15 +68,20 @@ /** | ||
*/ | ||
gulp.task('dist', ['clean'], function() { | ||
gulp.task('dist', ['clean','lint'], function() { | ||
return es.merge( | ||
gulp.src('./src/main/javascript/doc.js'), | ||
coffeescript(), | ||
gulp.src([ | ||
'./src/main/javascript/**/*.js', | ||
'./node_modules/swagger-client/browser/swagger-client.js' | ||
]), | ||
templates() | ||
) | ||
.pipe(order(['scripts.js', 'templates.js'])) | ||
.pipe(concat('swagger-ui.js')) | ||
.pipe(wrap('(function(){<%= contents %>}).call(this);')) | ||
.pipe(header(banner, { pkg: pkg } )) | ||
.pipe(gulp.dest('./dist')) | ||
.pipe(uglify()) | ||
.on('error', log) | ||
.pipe(rename({extname: '.min.js'})) | ||
.on('error', gutil.log) | ||
.on('error', log) | ||
.pipe(gulp.dest('./dist')) | ||
@@ -95,6 +99,7 @@ .pipe(connect.reload()); | ||
'./src/main/less/screen.less', | ||
'./src/main/less/print.less', | ||
'./src/main/less/reset.less' | ||
]) | ||
.pipe(less()) | ||
.on('error', gutil.log) | ||
.on('error', log) | ||
.pipe(gulp.dest('./src/main/html/css/')) | ||
@@ -112,5 +117,5 @@ .pipe(connect.reload()); | ||
gulp | ||
.src(['./lib/**/*.js']) | ||
.src(['./lib/**/*.{js,map}']) | ||
.pipe(gulp.dest('./dist/lib')) | ||
.on('error', gutil.log) | ||
.on('error', log); | ||
@@ -121,3 +126,3 @@ // copy all files inside html folder | ||
.pipe(gulp.dest('./dist')) | ||
.on('error', gutil.log) | ||
.on('error', log); | ||
}); | ||
@@ -129,3 +134,3 @@ | ||
gulp.task('watch', function() { | ||
return watch(['./src/**/*.{coffee,js,less}'], function() { | ||
return watch(['./src/**/*.{js,less,handlebars}'], function() { | ||
gulp.start('default'); | ||
@@ -145,4 +150,8 @@ }); | ||
function log(error) { | ||
console.error(error.toString && error.toString()); | ||
} | ||
gulp.task('default', ['dist', 'copy']); | ||
gulp.task('serve', ['connect', 'watch']) | ||
gulp.task('serve', ['connect', 'watch']); |
@@ -100,3 +100,4 @@ var appName; | ||
var pathname = location.pathname.substring(0, location.pathname.lastIndexOf("/")); | ||
var redirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html'; | ||
var defaultRedirectUrl = host.protocol + '//' + host.host + pathname + '/o2c.html'; | ||
var redirectUrl = window.oAuthRedirectUrl || defaultRedirectUrl; | ||
var url = null; | ||
@@ -107,3 +108,3 @@ | ||
var flow = authSchemes[key].flow; | ||
if(authSchemes[key].type === 'oauth2' && flow && (flow === 'implicit' || flow === 'accessCode')) { | ||
@@ -113,3 +114,3 @@ var dets = authSchemes[key]; | ||
window.swaggerUi.tokenName = dets.tokenName || 'access_token'; | ||
window.swaggerUi.tokenUrl = (flow === 'accessCode' ? dets.tokenUrl : null); | ||
window.swaggerUi.tokenUrl = (flow === 'accessCode' ? dets.tokenUrl : null); | ||
} | ||
@@ -141,3 +142,3 @@ else if(authSchemes[key].grantTypes) { | ||
var scope = $(o[k]).attr('scope'); | ||
if (scopes.indexOf(scope) === -1) | ||
@@ -147,2 +148,5 @@ scopes.push(scope); | ||
// Implicit auth recommends a state parameter. | ||
var state = Math.random (); | ||
window.enabledScopes=scopes; | ||
@@ -155,3 +159,4 @@ | ||
url += '&client_id=' + encodeURIComponent(clientId); | ||
url += '&scope=' + encodeURIComponent(scopes); | ||
url += '&scope=' + encodeURIComponent(scopes.join(' ')); | ||
url += '&state=' + encodeURIComponent(state); | ||
@@ -207,3 +212,3 @@ window.open(url); | ||
function processOAuthCode(data) { | ||
window.processOAuthCode = function processOAuthCode(data) { | ||
var params = { | ||
@@ -220,7 +225,7 @@ 'client_id': clientId, | ||
data: params, | ||
success:function(data, textStatus, jqXHR) | ||
success:function(data, textStatus, jqXHR) | ||
{ | ||
onOAuthComplete(data); | ||
}, | ||
error: function(jqXHR, textStatus, errorThrown) | ||
error: function(jqXHR, textStatus, errorThrown) | ||
{ | ||
@@ -232,3 +237,3 @@ onOAuthComplete(""); | ||
function onOAuthComplete(token) { | ||
window.onOAuthComplete = function onOAuthComplete(token) { | ||
if(token) { | ||
@@ -280,10 +285,10 @@ if(token.error) { | ||
$(o).find('.api-ic').removeClass('ic-warning'); | ||
$(o).find('.api-ic').removeClass('ic-error'); | ||
$(o).find('.api-ic').removeClass('ic-error'); | ||
} | ||
} | ||
}); | ||
window.authorizations.add(oauth2KeyName, new ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header')); | ||
window.swaggerUi.api.clientAuthorizations.add(oauth2KeyName, new SwaggerClient.ApiKeyAuthorization('Authorization', 'Bearer ' + b, 'header')); | ||
} | ||
} | ||
} | ||
} | ||
} |
{ | ||
"name": "swagger-ui", | ||
"author": "Tony Tam <fehguy@gmail.com>", | ||
"description": "Swagger UI is a dependency-free collection of HTML, Javascript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API", | ||
"version": "2.1.5-M1", | ||
"contributors": [ | ||
{ | ||
"name": "Mohsen Azimi", | ||
"email": "me@azimi.me" | ||
} | ||
], | ||
"description": "Swagger UI is a dependency-free collection of HTML, JavaScript, and CSS assets that dynamically generate beautiful documentation from a Swagger-compliant API", | ||
"version": "2.1.5-M2", | ||
"homepage": "http://swagger.io", | ||
"license": "Apache 2.0", | ||
"main": "dist/swagger-ui.js", | ||
"scripts": { | ||
"build": "./node_modules/gulp/bin/gulp.js;", | ||
"serve": "./node_modules/gulp/bin/gulp.js serve;", | ||
"test": "./node_modules/gulp/bin/gulp.js; ./node_modules/mocha/bin/mocha" | ||
"build": "gulp", | ||
"serve": "gulp serve", | ||
"prejshint": "gulp", | ||
"jshint": "jshint .", | ||
"pretest": "npm run jshint", | ||
"test": "mocha" | ||
}, | ||
@@ -18,32 +28,29 @@ "repository": { | ||
"readmeFilename": "README.md", | ||
"dependencies": { | ||
"shred": "0.8.10", | ||
"btoa": "1.1.1", | ||
"swagger-client": "2.1.5-M1" | ||
}, | ||
"devDependencies": { | ||
"chai": "^1.10.0", | ||
"cors": "2.1.1", | ||
"docco": "0.4.x", | ||
"event-stream": "^3.2.1", | ||
"express": "3.x", | ||
"gulp": "^3.8.10", | ||
"chai": "^2.1.0", | ||
"cors": "^2.5.3", | ||
"docco": "^0.7.0", | ||
"event-stream": "^3.2.2", | ||
"express": "^4.12.0", | ||
"gulp": "^3.8.11", | ||
"gulp-clean": "^0.3.1", | ||
"gulp-coffee": "^2.2.0", | ||
"gulp-concat": "^2.4.3", | ||
"gulp-concat": "^2.5.2", | ||
"gulp-connect": "^2.2.0", | ||
"gulp-declare": "^0.3.0", | ||
"gulp-handlebars": "^3.0.1", | ||
"gulp-header": "1.2.2", | ||
"gulp-less": "^2.0.1", | ||
"gulp-header": "^1.2.2", | ||
"gulp-jshint": "^1.10.0", | ||
"gulp-less": "^3.0.1", | ||
"gulp-order": "^1.1.1", | ||
"gulp-rename": "^1.2.0", | ||
"gulp-uglify": "^1.1.0", | ||
"gulp-util": "^3.0.2", | ||
"gulp-watch": "^4.1.0", | ||
"gulp-wrap": "^0.10.1", | ||
"http-server": "^0.7.4", | ||
"less": "~1.4.2", | ||
"gulp-watch": "^4.1.1", | ||
"gulp-wrap": "^0.11.0", | ||
"http-server": "git+https://github.com/nodeapps/http-server.git", | ||
"jshint-stylish": "^1.0.1", | ||
"less": "^2.4.0", | ||
"mocha": "^2.1.0", | ||
"selenium-webdriver": "^2.44.0" | ||
"selenium-webdriver": "^2.45.0", | ||
"swagger-client": "2.1.6-M2" | ||
} | ||
} |
# Swagger UI | ||
[![Build Status](https://travis-ci.org/swagger-api/swagger-ui.svg)](https://travis-ci.org/swagger-api/swagger-ui) | ||
[![Build Status](https://travis-ci.org/swagger-api/swagger-ui.svg?branch=master)](https://travis-ci.org/swagger-api/swagger-ui) | ||
@@ -23,3 +23,3 @@ 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. | ||
------------------ | ------------ | -------------------------- | ----- | ------ | ||
2.1.5-M1 | 2015-02-18 | 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-ui) | | ||
2.1.1-M2 | 2015-04-16 | 1.1, 1.2, 2.0 | [master](https://github.com/swagger-api/swagger-ui) | | ||
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) | | ||
@@ -34,2 +34,5 @@ 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) | | ||
##### Browser support | ||
Swagger UI works in all evergreen desktop browsers (Chrome, Safari, Firefox). Internet Explorer support is version 8 (IE8) and above. | ||
### Build | ||
@@ -55,2 +58,3 @@ 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: | ||
This will start Swagger UI at `http://localhost:8080`. | ||
### Use | ||
@@ -63,9 +67,9 @@ Once you open the Swagger UI, it will load the [Swagger Petstore](http://petstore.swagger.io/v2/swagger.json) service and show its APIs. You can enter your own server url and click explore to view the API. | ||
- dist: Contains a distribution which you can deploy on a server or load from your local machine. | ||
- dist/lang: The swagger localization | ||
- lib: Contains javascript dependencies which swagger-ui depends on | ||
- node_modules: Contains node modules which swagger-ui uses for its development. | ||
- src | ||
- src/main/coffeescript: main code in CoffeeScript | ||
- src/main/templates: [handlebars](http://handlebarsjs.com/) templates used to render swagger-ui | ||
- src/main/html: the html files, some images and css | ||
- src/main/javascript: some legacy javascript referenced by CoffeeScript code | ||
- src/main/javascript: main code | ||
@@ -76,8 +80,8 @@ ### SwaggerUi | ||
```javascript | ||
window.swaggerUi = new SwaggerUi({ | ||
url:"http://petstore.swagger.io/v2/swagger.json", | ||
dom_id:"swagger-ui-container" | ||
}); | ||
var swaggerUi = new SwaggerUi({ | ||
url:"http://petstore.swagger.io/v2/swagger.json", | ||
dom_id:"swagger-ui-container" | ||
}); | ||
window.swaggerUi.load(); | ||
swaggerUi.load(); | ||
``` | ||
@@ -95,6 +99,9 @@ | ||
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. | ||
apisSorter | Apply a sort to the API/tags list. It can be 'alpha' (sort by name) or a function (see Array.prototype.sort() to know how sort function works). Default is the order returned by the server unchanged. | ||
operationsSorter | Apply a sort to the operation list of each API. It can be 'alpha' (sort by paths alphanumerically), 'method' (sort by HTTP method) or a function (see Array.prototype.sort() to know how sort function works). Default is the order returned by the server unchanged. | ||
onComplete | This is a callback function parameter which can be passed to be notified of when SwaggerUI has completed rendering successfully. | ||
onFailure | This 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. | ||
supportedSubmitMethods | An array of of the HTTP operations that will have the 'Try it out!` option. An empty array disables all operations. This does not filter the operations from the display. | ||
oauth2RedirectUrl | OAuth redirect URL | ||
@@ -112,7 +119,7 @@ * All other parameters are explained in greater detail below | ||
```js | ||
// add a new ApiKeyAuthorization when the api-key changes in the ui. | ||
// add a new SwaggerClient.ApiKeyAuthorization when the api-key changes in the ui. | ||
$('#input_apiKey').change(function() { | ||
var key = $('#input_apiKey')[0].value; | ||
if(key && key.trim() != "") { | ||
window.authorizations.add("key", new ApiKeyAuthorization("api_key", key, "header")); | ||
swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("api_key", key, "header")); | ||
} | ||
@@ -128,3 +135,3 @@ }) | ||
```js | ||
window.authorizations.add("key", new ApiKeyAuthorization("Authorization", "XXXX", "header")); | ||
swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("Authorization", "XXXX", "header")); | ||
``` | ||
@@ -134,2 +141,27 @@ | ||
### Localization and translation | ||
The localization files are in the [lang](/lang) directory. Note that language files and translator is not included in SwaggerUI by default. You need to add them manually. | ||
To enable translation you should append next two lines in your Swagger's index.html (or another entry point you use) | ||
```html | ||
<script src='lang/translator.js' type='text/javascript'></script> | ||
<script src='lang/en.js' type='text/javascript'></script> | ||
``` | ||
The first line script is a translator and the second one is your language lexemes. | ||
If you wish to append support for new language you just need to create lang/your_lang.js and fill it like it's done in existing files. | ||
To append new lexemex for translation you shoul do two things: | ||
1. Add lexeme into the language file. | ||
Example of new line: "new sentence":"translation of new sentence". | ||
2. Mark this lexeme in source html with attribute data-sw-translate. | ||
Example of changed source: | ||
```html | ||
<anyHtmlTag data-sw-translate>new sentence</anyHtmlTag> | ||
or <anyHtmlTag data-sw-translate value='new sentence'/> | ||
``` | ||
. | ||
At this moment only inner html, title-attribute and value-attribute are going to be translated. | ||
## CORS Support | ||
@@ -200,5 +232,6 @@ | ||
To share your changes, [submit a pull request](https://github.com/swagger-api/swagger-ui/pull/new/master). | ||
To share your changes, [submit a pull request](https://github.com/swagger-api/swagger-ui/pull/new/develop_2.0). | ||
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. | ||
## Change Log | ||
Plsee see [releases](https://github.com/swagger-api/swagger-ui/releases) for change log. | ||
@@ -205,0 +238,0 @@ ## License |
@@ -0,1 +1,4 @@ | ||
'use strict'; | ||
$(function() { | ||
@@ -6,7 +9,7 @@ | ||
$.fn.vAlign = function() { | ||
return this.each(function(i){ | ||
var ah = $(this).height(); | ||
var ph = $(this).parent().height(); | ||
var mh = (ph - ah) / 2; | ||
$(this).css('margin-top', mh); | ||
return this.each(function(){ | ||
var ah = $(this).height(); | ||
var ph = $(this).parent().height(); | ||
var mh = (ph - ah) / 2; | ||
$(this).css('margin-top', mh); | ||
}); | ||
@@ -16,7 +19,7 @@ }; | ||
$.fn.stretchFormtasticInputWidthToParent = function() { | ||
return this.each(function(i){ | ||
var p_width = $(this).closest("form").innerWidth(); | ||
var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest("form").css('padding-right'), 10); | ||
var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10); | ||
$(this).css('width', p_width - p_padding - this_padding); | ||
return this.each(function(){ | ||
var p_width = $(this).closest("form").innerWidth(); | ||
var p_padding = parseInt($(this).closest("form").css('padding-left') ,10) + parseInt($(this).closest('form').css('padding-right'), 10); | ||
var this_padding = parseInt($(this).css('padding-left'), 10) + parseInt($(this).css('padding-right'), 10); | ||
$(this).css('width', p_width - p_padding - this_padding); | ||
}); | ||
@@ -43,3 +46,3 @@ }; | ||
// Tack the error style on if the input is empty.. | ||
if ($(this).val() == '') { | ||
if ($(this).val() === '') { | ||
$(this).addClass('error'); | ||
@@ -57,3 +60,3 @@ $(this).wiggle(); | ||
function clippyCopiedCallback(a) { | ||
function clippyCopiedCallback() { | ||
$('#api_key_copied').fadeIn().delay(1000).fadeOut(); | ||
@@ -69,3 +72,3 @@ | ||
// Logging function that accounts for browsers that don't have window.console | ||
log = function(){ | ||
function log(){ | ||
log.history = log.history || []; | ||
@@ -76,6 +79,6 @@ log.history.push(arguments); | ||
} | ||
}; | ||
} | ||
// Handle browsers that do console incorrectly (IE9 and below, see http://stackoverflow.com/a/5539378/7913) | ||
if (Function.prototype.bind && console && typeof console.log == "object") { | ||
if (Function.prototype.bind && console && typeof console.log === "object") { | ||
[ | ||
@@ -88,3 +91,3 @@ "log","info","warn","error","assert","dir","clear","profile","profileEnd" | ||
var Docs = { | ||
window.Docs = { | ||
@@ -141,3 +144,3 @@ shebang: function() { | ||
} | ||
$('li#resource_' + resource).addClass('active'); | ||
@@ -166,3 +169,3 @@ | ||
Docs.expandEndpointListForResource(resource); | ||
if (resource == '') { | ||
@@ -169,0 +172,0 @@ $('.resource ul.endpoints li.operation div.content').slideDown(); |
@@ -0,16 +1,8 @@ | ||
'use strict'; | ||
var expect = require('chai').expect; | ||
var driver = require('./driver'); | ||
var servers = require('./servers'); | ||
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 specs = path.join(__dirname, '..', '..', 'test', 'specs'); | ||
var DOCS_PORT = 8080; | ||
var SPEC_SERVER_PORT = 8081 | ||
var headers = { | ||
'Access-Control-Allow-Origin': '*', | ||
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept' | ||
}; | ||
var elements = [ | ||
@@ -26,17 +18,8 @@ 'swagger-ui-container', | ||
describe('swagger 1.x spec tests', function (done) { | ||
describe('swagger 1.x spec tests', function () { | ||
this.timeout(10 * 1000); | ||
var swaggerUI, specServer, driver; | ||
before(function () { | ||
swaggerUI = createServer({ root: dist, headers: headers }); | ||
specServer = createServer({ root: specs, headers: headers }); | ||
driver = new webdriver.Builder(). | ||
withCapabilities(webdriver.Capabilities.firefox()).build(); | ||
swaggerUI.listen(DOCS_PORT); | ||
specServer.listen(SPEC_SERVER_PORT); | ||
var swaggerSpecLocation = encodeURIComponent('http://localhost:' + SPEC_SERVER_PORT + '/v1.2/petstore/api-docs') | ||
driver.get('http://localhost:' + DOCS_PORT + '/index.html?url=' + swaggerSpecLocation); | ||
before(function (done) { | ||
this.timeout(25 * 1000); | ||
servers.start('/v1.2/petstore/api-docs.json', done); | ||
}); | ||
@@ -50,4 +33,5 @@ | ||
// 900 and above is "error" level. Console should not have any errors | ||
if (log.level.value > 900) | ||
if (log.level.value > 900) { | ||
console.log('browser error message:', log.message); errors.push(log); | ||
} | ||
}); | ||
@@ -70,3 +54,3 @@ expect(errors).to.be.empty; | ||
it('should render element: ' + id, function (done) { | ||
var locator = webdriver.By.id(id) | ||
var locator = webdriver.By.id(id); | ||
driver.isElementPresent(locator).then(function (isPresent) { | ||
@@ -79,3 +63,4 @@ expect(isPresent).to.be.true; | ||
it('should find the contact name element', function(done){ | ||
// TODO: enable me | ||
xit('should find the contact name element', function(done){ | ||
var locator = webdriver.By.css('.info_name'); | ||
@@ -89,3 +74,3 @@ driver.isElementPresent(locator).then(function (isPresent) { | ||
it('should find the pet link', function(done){ | ||
var locator = webdriver.By.xpath("//*[@data-id='pet']"); | ||
var locator = webdriver.By.xpath('//*[@data-id="pet"]'); | ||
driver.isElementPresent(locator).then(function (isPresent) { | ||
@@ -97,4 +82,5 @@ expect(isPresent).to.be.true; | ||
it('should find the pet resource description', function(done){ | ||
var locator = webdriver.By.xpath("//div[contains(., 'Operations about pets')]"); | ||
// TODO: enable me | ||
xit('should find the pet resource description', function(done){ | ||
var locator = webdriver.By.xpath('//div[contains(., "Operations about pets")]'); | ||
driver.findElements(locator).then(function (elements) { | ||
@@ -107,3 +93,3 @@ expect(elements.length).to.not.equal(0); | ||
it('should find the user link', function(done){ | ||
var locator = webdriver.By.xpath("//*[@data-id='user']"); | ||
var locator = webdriver.By.xpath('//*[@data-id="user"]'); | ||
driver.isElementPresent(locator).then(function (isPresent) { | ||
@@ -116,3 +102,3 @@ expect(isPresent).to.be.true; | ||
it('should find the store link', function(done){ | ||
var locator = webdriver.By.xpath("//*[@data-id='store']"); | ||
var locator = webdriver.By.xpath('//*[@data-id="store"]'); | ||
driver.isElementPresent(locator).then(function (isPresent) { | ||
@@ -124,7 +110,5 @@ expect(isPresent).to.be.true; | ||
after(function() { | ||
swaggerUI.close(); | ||
specServer.close(); | ||
driver.quit(); | ||
after(function(){ | ||
servers.close(); | ||
}); | ||
}); |
@@ -0,16 +1,9 @@ | ||
'use strict'; | ||
var expect = require('chai').expect; | ||
var webdriver = require('selenium-webdriver'); | ||
var createServer = require('http-server').createServer; | ||
var expect = require('chai').expect; | ||
var path = require('path') | ||
var driver = require('./driver'); | ||
var servers = require('./servers'); | ||
var dist = path.join(__dirname, '..', '..', 'dist'); | ||
var specs = path.join(__dirname, '..', '..', 'test', 'specs'); | ||
var DOCS_PORT = 8080; | ||
var SPEC_SERVER_PORT = 8081 | ||
var headers = { | ||
'Access-Control-Allow-Origin': '*', | ||
'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept' | ||
}; | ||
var elements = [ | ||
@@ -26,17 +19,8 @@ 'swagger-ui-container', | ||
describe('swagger 2.0 spec tests', function (done) { | ||
describe('swagger 2.0 spec tests', function () { | ||
this.timeout(10 * 1000); | ||
var swaggerUI, specServer, driver; | ||
before(function () { | ||
swaggerUI = createServer({ root: dist, headers: headers }); | ||
specServer = createServer({ root: specs, headers: headers }); | ||
driver = new webdriver.Builder(). | ||
withCapabilities(webdriver.Capabilities.firefox()).build(); | ||
swaggerUI.listen(DOCS_PORT); | ||
specServer.listen(SPEC_SERVER_PORT); | ||
var swaggerSpecLocation = encodeURIComponent('http://localhost:' + SPEC_SERVER_PORT + '/v2/petstore.json') | ||
driver.get('http://localhost:' + DOCS_PORT + '/index.html?url=' + swaggerSpecLocation); | ||
before(function (done) { | ||
this.timeout(25 * 1000); | ||
servers.start('/v2/petstore.json', done); | ||
}); | ||
@@ -50,4 +34,5 @@ | ||
// 900 and above is "error" level. Console should not have any errors | ||
if (log.level.value > 900) | ||
if (log.level.value > 900) { | ||
console.log('browser error message:', log.message); errors.push(log); | ||
} | ||
}); | ||
@@ -103,3 +88,3 @@ expect(errors).to.be.empty; | ||
it('should find the pet link', function(done){ | ||
var locator = webdriver.By.xpath("//*[@data-id='pet']"); | ||
var locator = webdriver.By.xpath('//*[@data-id="pet"]'); | ||
driver.isElementPresent(locator).then(function (isPresent) { | ||
@@ -111,4 +96,12 @@ expect(isPresent).to.be.true; | ||
it('should find the pet resource description', function(done){ | ||
var locator = webdriver.By.xpath('//div[contains(., "Everything about your Pets")]'); | ||
driver.findElements(locator).then(function (elements) { | ||
expect(elements.length).to.not.equal(0); | ||
done(); | ||
}); | ||
}); | ||
it('should find the user link', function(done){ | ||
var locator = webdriver.By.xpath("//*[@data-id='user']"); | ||
var locator = webdriver.By.xpath('//*[@data-id="user"]'); | ||
driver.isElementPresent(locator).then(function (isPresent) { | ||
@@ -121,3 +114,3 @@ expect(isPresent).to.be.true; | ||
it('should find the store link', function(done){ | ||
var locator = webdriver.By.xpath("//*[@data-id='store']"); | ||
var locator = webdriver.By.xpath('//*[@data-id="store"]'); | ||
driver.isElementPresent(locator).then(function (isPresent) { | ||
@@ -130,6 +123,4 @@ expect(isPresent).to.be.true; | ||
after(function() { | ||
swaggerUI.close(); | ||
specServer.close(); | ||
driver.quit(); | ||
servers.close(); | ||
}); | ||
}); |
{ | ||
"swagger": "2.0", | ||
"info": { | ||
"description": "This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.wordnik.com\">http://swagger.wordnik.com</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters", | ||
"description": "This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters", | ||
"version": "1.0.0", | ||
@@ -11,3 +11,3 @@ "title": "Swagger Petstore", | ||
"name": "Your pals at Swagger", | ||
"email": "apiteam@wordnik.com" | ||
"email": "apiteam@swagger.io" | ||
}, | ||
@@ -19,3 +19,3 @@ "license": { | ||
}, | ||
"host": "petstore.swagger.wordnik.com", | ||
"host": "petstore.swagger.io", | ||
"basePath": "/v2", | ||
@@ -25,2 +25,24 @@ "schemes": [ | ||
], | ||
"tags": [ | ||
{ | ||
"name": "user", | ||
"description": "Operations about user" | ||
}, | ||
{ | ||
"name": "store", | ||
"description": "Access to Petstore orders", | ||
"externalDocs": { | ||
"description": "Find out more", | ||
"url": "http://swagger.io" | ||
} | ||
}, | ||
{ | ||
"name": "pet", | ||
"description": "Everything about your Pets", | ||
"externalDocs": { | ||
"description": "Find out more", | ||
"url": "http://swagger.io" | ||
} | ||
} | ||
], | ||
"paths": { | ||
@@ -578,3 +600,4 @@ "/pet": { | ||
"required": false, | ||
"type": "string" | ||
"type": "string", | ||
"format": "password" | ||
} | ||
@@ -727,3 +750,3 @@ ], | ||
"type": "oauth2", | ||
"authorizationUrl": "http://petstore.swagger.wordnik.com/api/oauth/dialog", | ||
"authorizationUrl": "http://petstore.swagger.io/api/oauth/dialog", | ||
"flow": "implicit" | ||
@@ -730,0 +753,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 3 instances in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
3442410
0
135
35628
241
3
21
25
4
- Removedbtoa@1.1.1
- Removedshred@0.8.10
- Removedswagger-client@2.1.5-M1
- Removedax@0.1.8(transitive)
- Removedbtoa@1.1.1(transitive)
- Removedcookiejar@1.3.1(transitive)
- Removediconv-lite@0.6.3(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedshred@0.8.10(transitive)
- Removedsprintf@0.1.1(transitive)
- Removedswagger-client@2.1.5-M1(transitive)