Procházet zdrojové kódy

added support for swagger-spec 1.2

bubble
Tony Tam před 11 roky
rodič
revize
9efb0a798e
2 změnil soubory, kde provedl 12 přidání a 2 odebrání
  1. +1
    -1
      dist/index.html
  2. +11
    -1
      dist/lib/swagger.js

+ 1
- 1
dist/index.html Zobrazit soubor

@@ -19,7 +19,7 @@
<script type="text/javascript">
$(function () {
window.swaggerUi = new SwaggerUi({
discoveryUrl:"http://petstore.swagger.wordnik.com/api/api-docs.json",
discoveryUrl:"http://localhost:8002/api/api-docs",
apiKey:"special-key",
dom_id:"swagger-ui-container",
supportHeaderParams: false,


+ 11
- 1
dist/lib/swagger.js Zobrazit soubor

@@ -63,7 +63,11 @@
}
_this.basePath = _this.basePath.replace(/\/$/, '');
} else {
_this.basePath = _this.discoveryUrl.substring(0, _this.discoveryUrl.lastIndexOf('/'));
if (_this.discoveryUrl.indexOf('?') > 0) {
_this.basePath = _this.discoveryUrl.substring(0, _this.discoveryUrl.lastIndexOf('?'));
} else {
_this.basePath = _this.discoveryUrl;
}
log('derived basepath from discoveryUrl as ' + _this.basePath);
}
_this.apis = {};
@@ -201,6 +205,7 @@
parts = this.path.split("/");
this.name = parts[parts.length - 1].replace('.{format}', '');
this.basePath = this.api.basePath;
console.log('bp: ' + this.basePath);
this.operations = {};
this.operationsArray = [];
this.modelsArray = [];
@@ -215,6 +220,8 @@
this.api.fail("SwaggerResources must have a path.");
}
this.url = this.api.suffixApiKey(this.api.basePath + this.path.replace('{format}', 'json'));
console.log('basePath: ' + this.api.basePath);
console.log('url: ' + this.url);
this.api.progress('fetching resource ' + this.name + ': ' + this.url);
jQuery.getJSON(this.url, function(response) {
var endpoint, _i, _len, _ref;
@@ -279,6 +286,9 @@
if (o.errorResponses) {
errorResponses = o.errorResponses;
}
if (o.method) {
o.httpMethod = o.method;
}
op = new SwaggerOperation(o.nickname, resource_path, o.httpMethod, o.parameters, o.summary, o.notes, o.responseClass, errorResponses, this, o.consumes, o.produces);
this.operations[op.nickname] = op;
_results.push(this.operationsArray.push(op));


Načítá se…
Zrušit
Uložit