redoc/src/services/SpecStore.ts

32 lines
1.1 KiB
TypeScript
Raw Normal View History

2018-07-26 17:34:44 +03:00
import { OpenAPIExternalDocumentation, OpenAPISpec } from '../types';
2017-10-12 00:01:37 +03:00
2018-07-26 17:34:44 +03:00
import { ContentItemModel, MenuBuilder } from './MenuBuilder';
2017-10-12 00:01:37 +03:00
import { ApiInfoModel } from './models/ApiInfo';
2017-11-23 00:38:38 +03:00
import { SecuritySchemesModel } from './models/SecuritySchemes';
2018-01-22 21:30:53 +03:00
import { OpenAPIParser } from './OpenAPIParser';
import { RedocNormalizedOptions } from './RedocNormalizedOptions';
2017-10-12 00:01:37 +03:00
/**
* Store that containts all the specification related information in the form of tree
*/
export class SpecStore {
2018-07-26 17:34:44 +03:00
parser: OpenAPIParser;
info: ApiInfoModel;
externalDocs?: OpenAPIExternalDocumentation;
operationGroups: ContentItemModel[];
securitySchemes: SecuritySchemesModel;
2017-10-12 00:01:37 +03:00
2017-11-21 14:00:33 +03:00
constructor(
spec: OpenAPISpec,
specUrl: string | undefined,
private options: RedocNormalizedOptions,
) {
2017-11-21 17:33:22 +03:00
this.parser = new OpenAPIParser(spec, specUrl, options);
2018-07-26 17:34:44 +03:00
this.info = new ApiInfoModel(this.parser);
this.externalDocs = this.parser.spec.externalDocs;
this.operationGroups = MenuBuilder.buildStructure(this.parser, this.options);
2017-10-12 00:01:37 +03:00
2018-07-26 17:34:44 +03:00
this.securitySchemes = new SecuritySchemesModel(this.parser);
2017-10-12 00:01:37 +03:00
}
}