import { Document } from './core/models/Document'; import { DocumentType } from './core/models/DocumentType'; import { Node } from './core/models/Node'; import { NodePath } from './core/models/NodePath'; import { ValidationProblem } from './core/models/ValidationProblem'; import { IReferenceResolver } from './core/util/IReferenceResolver'; import { IValidationSeverityRegistry } from './core/validation/IValidationSeverityRegistry'; import { IVisitor } from './core/visitors/IVisitor'; import { TraverserDirection } from './core/visitors/TraverserDirection'; import { Oas20Document } from './openapi/v2/models/Oas20Document'; import { Oas30Document } from './openapi/v3/models/Oas30Document'; /** * The most common entry points into using the data models library. Provides convenience methods * for performing common actions such as i/o, visiting, and validation. * @author eric.wittmann@gmail.com * @author Jakub Senko * @class */ export declare class Library { /** * Adds a reference resolver to the library. The resolver will be used whenever the library * needs to resolve a $ref reference. * @param {*} resolver */ static addReferenceResolver(resolver: IReferenceResolver): void; static removeReferenceResolver(resolver: IReferenceResolver): void; /** * Creates a new, empty document of the given type. * @param {DocumentType} type * @return {Document} */ static createDocument(type: DocumentType): Document; /** * Called to create a node path for a given data model node. * @param {Node} node * @return {NodePath} */ static createNodePath(node: Node): NodePath; /** * Convenience method for visiting a single data model nodel. * @param {Node} node * @param {*} visitor */ static visitNode(node: Node, visitor: IVisitor): void; /** * Convenience method for visiting a data model tree. Supports traversing the data model either * up or down the tree. * @param {Node} node * @param {*} visitor * @param {TraverserDirection} direction */ static visitTree(node: Node, visitor: IVisitor, direction: TraverserDirection): void; /** * Called to validate a data model node. All validation rules will be evaluated and reported. The list * of validation problems found during validation is returned. In addition, validation problems will be * reported on the individual nodes themselves. Validation problem severity is determined by checking * with the included severity registry. If the severity registry is null, a default registry is used. * @param {Node} node * @param {*} severityRegistry * @return {ValidationProblem[]} */ static validate(node: Node, severityRegistry: IValidationSeverityRegistry): Array; /** * Reads an entire document from JSON data. The JSON data (already parsed, not in string format) is * read as a data model {@link Document} and returned. * @param {*} json * @return {Document} */ static readDocument(json: any): Document; /** * Reads an entire document from a JSON formatted string. This will parse the given string into * JSON data and then call Library.readDocument. * @param {string} jsonString * @return {Document} */ static readDocumentFromJSONString(jsonString: string): Document; /** * Call this to do a "partial read" on a given node. You must pass the JSON data for the node * type and an empty instance of the property node class. For example, you could read just an * Operation by passing the JSON data for the operation along with an instance of e.g. * {@link Oas30Operation} and this will read the data and store it in the instance. * @param {*} json * @param {Node} node * @return {Node} */ static readNode(json: any, node: Node): Node; /** * Called to serialize a given data model node to a JSON object. * @param {Node} node * @return {*} */ static writeNode(node: Node): any; /** * Called to serialize a given data model to a JSON formatted string. * @param {Document} document * @return {string} */ static writeDocumentToJSONString(document: Document): string; /** * Called to discover what type of document the given JSON data represents. This method * interrogates the following appropriate top level properties: * * - asyncapi * - openapi * - swagger * * Based on which property is defined, and the value of that property, the correct document * type is determined and returned. * * @param {*} json * @return {DocumentType} */ static discoverDocumentType(json: any): DocumentType; /** * Clones the given document by serializing it to a JS object, and then re-parsing it. * @param {Document} source * @return {Document} */ static cloneDocument(source: Document): Document; /** * Transforms from an OpenAPI 2.0 document into a 3.0 document. * @param {Oas20Document} source * @return {Oas30Document} */ static transformDocument(source: Oas20Document): Oas30Document; /** * Dereferences a document - this will take all external references ($ref) found in * the document and pull them into this document. It will then update any external * reference to instead point to the local copy. The result is a functionally * equivalent document with no external references. * * @param {Document} source * @return {Document} */ static dereferenceDocument(source: Document): Document; }