redoc/src/services/SpecStore.ts

41 lines
949 B
TypeScript
Raw Normal View History

import { OpenAPISpec } from '../types';
2017-10-12 00:01:37 +03:00
import { observable, computed } from 'mobx';
// import { OpenAPIExternalDocumentation, OpenAPIInfo } from '../types';
import { MenuBuilder } from './MenuBuilder';
import { OpenAPIParser } from './OpenAPIParser';
import { ApiInfoModel } from './models/ApiInfo';
/**
* Store that containts all the specification related information in the form of tree
*/
export class SpecStore {
@observable.ref parser: OpenAPIParser;
constructor(spec: OpenAPISpec, specUrl?: string) {
this.parser = new OpenAPIParser(spec, specUrl);
2017-10-12 00:01:37 +03:00
}
@computed
get info(): ApiInfoModel {
2017-10-12 00:01:37 +03:00
return new ApiInfoModel(this.parser);
}
@computed
get externalDocs() {
return this.parser.spec.externalDocs;
2017-10-12 00:01:37 +03:00
}
@computed
get operationGroups() {
return MenuBuilder.buildStructure(this.parser);
}
@computed
get security() {
// TODO: implement security
throw new Error('Not implemented');
}
}