Sfoglia il codice sorgente

renamed discoveryUrl to url to match js change

bubble
Tony Tam 11 anni fa
parent
commit
2a206b0a6b
9 ha cambiato i file con 63 aggiunte e 46 eliminazioni
  1. +1
    -1
      dist/index.html
  2. +23
    -14
      dist/lib/swagger.js
  3. +6
    -6
      dist/swagger-ui.js
  4. +1
    -1
      dist/swagger-ui.min.js
  5. +23
    -14
      lib/swagger.js
  6. +2
    -2
      src/main/coffeescript/SwaggerUi.coffee
  7. +4
    -4
      src/main/coffeescript/view/HeaderView.coffee
  8. +1
    -1
      src/main/html/index.html
  9. +2
    -3
      src/test/swagger-ui-spec.coffee

+ 1
- 1
dist/index.html Vedi File

@@ -20,7 +20,7 @@
<script type="text/javascript">
$(function () {
window.swaggerUi = new SwaggerUi({
discoveryUrl:"http://localhost:8002/api/api-docs",
url:"http://localhost:8002/api/api-docs",
dom_id:"swagger-ui-container",
supportHeaderParams: false,
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],


+ 23
- 14
dist/lib/swagger.js Vedi File

@@ -5,7 +5,7 @@

SwaggerApi = (function() {

SwaggerApi.prototype.discoveryUrl = "http://api.wordnik.com/v4/resources.json";
SwaggerApi.prototype.url = "http://api.wordnik.com/v4/resources.json";

SwaggerApi.prototype.debug = false;

@@ -15,12 +15,21 @@

SwaggerApi.prototype.authorizationScheme = null;

function SwaggerApi(options) {
function SwaggerApi(url, options) {
if (options == null) {
options = {};
}
if (options.discoveryUrl != null) {
this.discoveryUrl = options.discoveryUrl;
if (url) {
if (url.url) {
options = url;
} else {
this.url = url;
}
} else {
options = url;
}
if (options.url != null) {
this.url = options.url;
}
this.supportedSubmitMethods = options.supportedSubmitMethods != null ? options.supportedSubmitMethods : ['get'];
if (options.success != null) {
@@ -37,21 +46,21 @@
SwaggerApi.prototype.build = function() {
var obj,
_this = this;
this.progress('fetching resource list: ' + this.discoveryUrl);
console.log('getting ' + this.discoveryUrl);
this.progress('fetching resource list: ' + this.url);
console.log('getting ' + this.url);
obj = {
url: this.discoveryUrl,
url: this.url,
method: "get",
on: {
error: function(response) {
if (_this.discoveryUrl.substring(0, 4) !== 'http') {
return _this.fail('Please specify the protocol for ' + _this.discoveryUrl);
if (_this.url.substring(0, 4) !== 'http') {
return _this.fail('Please specify the protocol for ' + _this.url);
} else if (error.status === 0) {
return _this.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
} else if (error.status === 404) {
return _this.fail('Can\'t read swagger JSON from ' + _this.discoveryUrl);
return _this.fail('Can\'t read swagger JSON from ' + _this.url);
} else {
return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.discoveryUrl);
return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.url);
}
},
response: function(rawResponse) {
@@ -83,10 +92,10 @@
} else {
if (response.basePath) {
_this.basePath = response.basePath;
} else if (_this.discoveryUrl.indexOf('?') > 0) {
_this.basePath = _this.discoveryUrl.substring(0, _this.discoveryUrl.lastIndexOf('?'));
} else if (_this.url.indexOf('?') > 0) {
_this.basePath = _this.url.substring(0, _this.url.lastIndexOf('?'));
} else {
_this.basePath = _this.discoveryUrl;
_this.basePath = _this.url;
}
_ref2 = response.apis;
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {


+ 6
- 6
dist/swagger-ui.js Vedi File

@@ -1384,7 +1384,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
};

SwaggerUi.prototype.updateSwaggerUi = function(data) {
this.options.discoveryUrl = data.discoveryUrl;
this.options.url = data.url;
return this.load();
};

@@ -1393,7 +1393,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
if ((_ref = this.mainView) != null) {
_ref.clear();
}
this.headerView.update(this.options.discoveryUrl);
this.headerView.update(this.options.url);
return this.api = new SwaggerApi(this.options);
};

@@ -1469,13 +1469,13 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials

HeaderView.prototype.showPetStore = function(e) {
return this.trigger('update-swagger-ui', {
discoveryUrl: "http://petstore.swagger.wordnik.com/api/api-docs.json"
url: "http://petstore.swagger.wordnik.com/api/api-docs.json"
});
};

HeaderView.prototype.showWordnikDev = function(e) {
return this.trigger('update-swagger-ui', {
discoveryUrl: "http://api.wordnik.com/v4/resources.json"
url: "http://api.wordnik.com/v4/resources.json"
});
};

@@ -1490,7 +1490,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
e.preventDefault();
}
return this.trigger('update-swagger-ui', {
discoveryUrl: $('#input_baseUrl').val(),
url: $('#input_baseUrl').val(),
apiKey: $('#input_apiKey').val()
});
};
@@ -1503,7 +1503,7 @@ templates['status_code'] = template(function (Handlebars,depth0,helpers,partials
$('#input_apiKey').val(apiKey);
if (trigger) {
return this.trigger('update-swagger-ui', {
discoveryUrl: url,
url: url,
apiKey: apiKey
});
}


+ 1
- 1
dist/swagger-ui.min.js
File diff soppresso perché troppo grande
Vedi File


+ 23
- 14
lib/swagger.js Vedi File

@@ -5,7 +5,7 @@

SwaggerApi = (function() {

SwaggerApi.prototype.discoveryUrl = "http://api.wordnik.com/v4/resources.json";
SwaggerApi.prototype.url = "http://api.wordnik.com/v4/resources.json";

SwaggerApi.prototype.debug = false;

@@ -15,12 +15,21 @@

SwaggerApi.prototype.authorizationScheme = null;

function SwaggerApi(options) {
function SwaggerApi(url, options) {
if (options == null) {
options = {};
}
if (options.discoveryUrl != null) {
this.discoveryUrl = options.discoveryUrl;
if (url) {
if (url.url) {
options = url;
} else {
this.url = url;
}
} else {
options = url;
}
if (options.url != null) {
this.url = options.url;
}
this.supportedSubmitMethods = options.supportedSubmitMethods != null ? options.supportedSubmitMethods : ['get'];
if (options.success != null) {
@@ -37,21 +46,21 @@
SwaggerApi.prototype.build = function() {
var obj,
_this = this;
this.progress('fetching resource list: ' + this.discoveryUrl);
console.log('getting ' + this.discoveryUrl);
this.progress('fetching resource list: ' + this.url);
console.log('getting ' + this.url);
obj = {
url: this.discoveryUrl,
url: this.url,
method: "get",
on: {
error: function(response) {
if (_this.discoveryUrl.substring(0, 4) !== 'http') {
return _this.fail('Please specify the protocol for ' + _this.discoveryUrl);
if (_this.url.substring(0, 4) !== 'http') {
return _this.fail('Please specify the protocol for ' + _this.url);
} else if (error.status === 0) {
return _this.fail('Can\'t read from server. It may not have the appropriate access-control-origin settings.');
} else if (error.status === 404) {
return _this.fail('Can\'t read swagger JSON from ' + _this.discoveryUrl);
return _this.fail('Can\'t read swagger JSON from ' + _this.url);
} else {
return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.discoveryUrl);
return _this.fail(error.status + ' : ' + error.statusText + ' ' + _this.url);
}
},
response: function(rawResponse) {
@@ -83,10 +92,10 @@
} else {
if (response.basePath) {
_this.basePath = response.basePath;
} else if (_this.discoveryUrl.indexOf('?') > 0) {
_this.basePath = _this.discoveryUrl.substring(0, _this.discoveryUrl.lastIndexOf('?'));
} else if (_this.url.indexOf('?') > 0) {
_this.basePath = _this.url.substring(0, _this.url.lastIndexOf('?'));
} else {
_this.basePath = _this.discoveryUrl;
_this.basePath = _this.url;
}
_ref2 = response.apis;
for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {


+ 2
- 2
src/main/coffeescript/SwaggerUi.coffee Vedi File

@@ -34,14 +34,14 @@ class SwaggerUi extends Backbone.Router
# Event handler for when url/key is received from user
updateSwaggerUi: (data) ->
@options.discoveryUrl = data.discoveryUrl
@options.url = data.url
@load()
# Create an api and render
load: ->
# Initialize the API object
@mainView?.clear()
@headerView.update(@options.discoveryUrl)
@headerView.update(@options.url)
@api = new SwaggerApi(@options)
# This is bound to success handler for SwaggerApi


+ 4
- 4
src/main/coffeescript/view/HeaderView.coffee Vedi File

@@ -12,13 +12,13 @@ class HeaderView extends Backbone.View
showPetStore: (e) ->
@trigger(
'update-swagger-ui'
{discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json"}
{url:"http://petstore.swagger.wordnik.com/api/api-docs.json"}
)

showWordnikDev: (e) ->
@trigger(
'update-swagger-ui'
{discoveryUrl:"http://api.wordnik.com/v4/resources.json"}
{url:"http://api.wordnik.com/v4/resources.json"}
)

showCustomOnKeyup: (e) ->
@@ -28,10 +28,10 @@ class HeaderView extends Backbone.View
e?.preventDefault()
@trigger(
'update-swagger-ui'
{discoveryUrl: $('#input_baseUrl').val(), apiKey: $('#input_apiKey').val()}
{url: $('#input_baseUrl').val(), apiKey: $('#input_apiKey').val()}
)

update: (url, apiKey, trigger = false) ->
$('#input_baseUrl').val url
$('#input_apiKey').val apiKey
@trigger 'update-swagger-ui', {discoveryUrl:url, apiKey:apiKey} if trigger
@trigger 'update-swagger-ui', {url:url, apiKey:apiKey} if trigger

+ 1
- 1
src/main/html/index.html Vedi File

@@ -20,7 +20,7 @@
<script type="text/javascript">
$(function () {
window.swaggerUi = new SwaggerUi({
discoveryUrl:"http://localhost:8002/api/api-docs",
url:"http://localhost:8002/api/api-docs",
dom_id:"swagger-ui-container",
supportHeaderParams: false,
supportedSubmitMethods: ['get', 'post', 'put', 'delete'],


+ 2
- 3
src/test/swagger-ui-spec.coffee Vedi File

@@ -1,5 +1,4 @@
window.api_key = 'a2a73e7b926c924fad7001ca3111acd55af2ffabf50eb4ae5'
window.discoveryUrl = "http://api.wordnik.com/v4/resources.json"
window.url = "http://api.wordnik.com/v4/resources.json"

describe 'SwaggerUi', ->
@@ -8,7 +7,7 @@ describe 'SwaggerUi', ->
beforeEach ->
window.ui = new SwaggerUi
api_key: window.api_key
discoveryUrl: window.discoveryUrl
url: window.url
waitsFor ->
ui.ready


Caricamento…
Annulla
Salva