Prepend api url to paths

This commit is contained in:
Roman Hotsiy 2015-11-17 00:03:09 +02:00
parent bd40107e56
commit 540a050eaa
3 changed files with 8 additions and 1 deletions

View File

@ -3,7 +3,7 @@
<h2>{{data.methodInfo.summary}}</h2>
<h3>
<span class="http-method" [ng-class]="data.method">{{data.method}}</span>
<span class="path">{{data.path}}</span>
<span class="api-url">{{data.apiUrl}}</span> <span class="path">{{data.path}}</span>
</h3>
<div class="method-tags"> Tags:
<a *ng-for="#tag of data.methodInfo.tags" attr.href="#{{tag}}"> {{tag}} </a>

View File

@ -20,6 +20,7 @@ export default class Method extends BaseComponent {
prepareModel() {
this.data = {};
this.data.apiUrl = this.schemaMgr.apiUrl;
this.data.method = JsonPointer.baseName(this.pointer);
this.data.path = JsonPointer.baseName(this.pointer, 2);
this.data.methodInfo = this.componentSchema;

View File

@ -27,6 +27,7 @@ export default class SchemaManager {
(schema) => {
this._schema = schema;
resolve(this._schema);
this.init();
},
(err) => reject(err)
);
@ -35,6 +36,11 @@ export default class SchemaManager {
return promise;
}
/* calculate common used values */
init() {
this.apiUrl = this._schema.schemes[0] + "://" + this._schema.host + this._schema.basePath;
}
get schema() {
// TODO: consider returning promise
return this._schema;