62 lines
3.7 KiB
TypeScript
62 lines
3.7 KiB
TypeScript
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
import { OpenAPIV3 } from "openapi-types";
|
|
import { APIInfo, GenerateResult, ListAPIResult, ParseOptions, ValidateResult } from "./interfaces";
|
|
/**
|
|
* A class that parses an OpenAPI specification file and provides methods to validate, list, and generate artifacts.
|
|
*/
|
|
export declare class SpecParser {
|
|
readonly pathOrSpec: string | OpenAPIV3.Document;
|
|
readonly parser: SwaggerParser;
|
|
readonly options: Required<ParseOptions>;
|
|
private validator;
|
|
private spec;
|
|
private unResolveSpec;
|
|
private isSwaggerFile;
|
|
private defaultOptions;
|
|
/**
|
|
* Creates a new instance of the SpecParser class.
|
|
* @param pathOrDoc The path to the OpenAPI specification file or the OpenAPI specification object.
|
|
* @param options The options for parsing the OpenAPI specification file.
|
|
*/
|
|
constructor(pathOrDoc: string | OpenAPIV3.Document, options?: ParseOptions);
|
|
/**
|
|
* Validates the OpenAPI specification file and returns a validation result.
|
|
*
|
|
* @returns A validation result object that contains information about any errors or warnings in the specification file.
|
|
*/
|
|
validate(): Promise<ValidateResult>;
|
|
listSupportedAPIInfo(): Promise<APIInfo[]>;
|
|
/**
|
|
* Lists all the OpenAPI operations in the specification file.
|
|
* @returns A string array that represents the HTTP method and path of each operation, such as ['GET /pets/{petId}', 'GET /user/{userId}']
|
|
* according to copilot plugin spec, only list get and post method without auth
|
|
*/
|
|
list(): Promise<ListAPIResult>;
|
|
/**
|
|
* Generate specs according to the filters.
|
|
* @param filter An array of strings that represent the filters to apply when generating the artifacts. If filter is empty, it would process nothing.
|
|
*/
|
|
getFilteredSpecs(filter: string[], signal?: AbortSignal): Promise<[OpenAPIV3.Document, OpenAPIV3.Document]>;
|
|
/**
|
|
* Generates and update artifacts from the OpenAPI specification file. Generate Adaptive Cards, update Teams app manifest, and generate a new OpenAPI specification file.
|
|
* @param manifestPath A file path of the Teams app manifest file to update.
|
|
* @param filter An array of strings that represent the filters to apply when generating the artifacts. If filter is empty, it would process nothing.
|
|
* @param outputSpecPath File path of the new OpenAPI specification file to generate. If not specified or empty, no spec file will be generated.
|
|
* @param pluginFilePath File path of the api plugin file to generate.
|
|
*/
|
|
generateForCopilot(manifestPath: string, filter: string[], outputSpecPath: string, pluginFilePath: string, existingPluginFilePath?: string, signal?: AbortSignal): Promise<GenerateResult>;
|
|
/**
|
|
* Generates and update artifacts from the OpenAPI specification file. Generate Adaptive Cards, update Teams app manifest, and generate a new OpenAPI specification file.
|
|
* @param manifestPath A file path of the Teams app manifest file to update.
|
|
* @param filter An array of strings that represent the filters to apply when generating the artifacts. If filter is empty, it would process nothing.
|
|
* @param outputSpecPath File path of the new OpenAPI specification file to generate. If not specified or empty, no spec file will be generated.
|
|
* @param adaptiveCardFolder Folder path where the Adaptive Card files will be generated. If not specified or empty, Adaptive Card files will not be generated.
|
|
*/
|
|
generate(manifestPath: string, filter: string[], outputSpecPath: string, adaptiveCardFolder?: string, signal?: AbortSignal): Promise<GenerateResult>;
|
|
private loadSpec;
|
|
private getAPIs;
|
|
private getValidator;
|
|
private saveFilterSpec;
|
|
private resolveEnvForSpec;
|
|
}
|