Initial commit

This commit is contained in:
2025-03-07 19:22:02 +01:00
commit 4a98255d83
55743 changed files with 5280367 additions and 0 deletions
@@ -0,0 +1,10 @@
import { OpenAPIV3 } from "openapi-types";
import { AdaptiveCard, ArrayElement, ImageElement, TextBlockElement, WarningResult } from "./interfaces";
export declare class AdaptiveCardGenerator {
static generateAdaptiveCard(operationItem: OpenAPIV3.OperationObject, allowMultipleMediaType?: boolean, maxElementCount?: number): [AdaptiveCard, string, any, WarningResult[]];
static generateCardFromResponse(schema: OpenAPIV3.SchemaObject, name: string, parentArrayName?: string, maxElementCount?: number, counter?: {
count: number;
}): Array<TextBlockElement | ImageElement | ArrayElement>;
static getResponseJsonPathFromSchema(schema: OpenAPIV3.SchemaObject): string;
static isImageUrlProperty(schema: OpenAPIV3.NonArraySchemaObject, name: string, parentArrayName: string): boolean;
}
@@ -0,0 +1,16 @@
import { ResponseSemanticsObject } from "@microsoft/teams-manifest";
import { AdaptiveCard, PreviewCardTemplate, WrappedAdaptiveCard } from "./interfaces";
export declare function wrapAdaptiveCard(card: AdaptiveCard, jsonPath: string): WrappedAdaptiveCard;
export declare function wrapResponseSemantics(card: AdaptiveCard, jsonPath: string): ResponseSemanticsObject;
/**
* Infers the preview card template from an Adaptive Card and a JSON path.
* The preview card template includes a title and an optional subtitle and image.
* It populates the preview card template with the first text block that matches
* each well-known name, in the order of title, subtitle, and image.
* If no text block matches the title or subtitle, it uses the first two text block as the title and subtitle.
* If the title is still empty and the subtitle is not empty, it uses subtitle as the title.
* @param card The Adaptive Card to infer the preview card template from.
* @param jsonPath The JSON path to the root object in the card body.
* @returns The inferred preview card template.
*/
export declare function inferPreviewCardTemplate(card: AdaptiveCard): PreviewCardTemplate;
+53
View File
@@ -0,0 +1,53 @@
export declare class ConstantString {
static readonly CancelledMessage = "Operation is cancelled.";
static readonly NoServerInformation = "No server information is found in the OpenAPI description document.";
static readonly RemoteRefNotSupported = "Remote reference is not supported: %s.";
static readonly MissingOperationId = "Missing operationIds: %s.";
static readonly NoSupportedApi = "No supported API is found in the OpenAPI description document: only GET and POST methods are supported, additionally, there can be at most one required parameter, and no auth is allowed.";
static readonly AdditionalPropertiesNotSupported = "'additionalProperties' is not supported, and will be ignored.";
static readonly SchemaNotSupported = "'oneOf', 'allOf', 'anyOf', and 'not' schema are not supported: %s.";
static readonly UnknownSchema = "Unknown schema: %s.";
static readonly UrlProtocolNotSupported = "Server url is not correct: protocol %s is not supported, you should use https protocol instead.";
static readonly RelativeServerUrlNotSupported = "Server url is not correct: relative server url is not supported.";
static readonly ResolveServerUrlFailed = "Unable to resolve the server URL: please make sure that the environment variable %s is defined.";
static readonly OperationOnlyContainsOptionalParam = "Operation %s contains multiple optional parameters. The first optional parameter is used for this command.";
static readonly ConvertSwaggerToOpenAPI = "The Swagger 2.0 file has been converted to OpenAPI 3.0.";
static readonly SwaggerNotSupported = "Swagger 2.0 is not supported. Please convert to OpenAPI 3.0 manually before proceeding.";
static readonly SpecVersionNotSupported = "Unsupported OpenAPI version %s. Please use version 3.0.x.";
static readonly MultipleAuthNotSupported = "Multiple authentication methods are unsupported. Ensure all selected APIs use identical authentication.";
static readonly OperationIdContainsSpecialCharacters = "Operation id '%s' in OpenAPI description document contained special characters and was renamed to '%s'.";
static readonly UnsupportedSchema = "Unsupported schema in %s %s: %s";
static readonly FuncDescriptionTooLong = "The description of the function '%s' is too long. The current length is %s characters, while the maximum allowed length is %s characters.";
static readonly GenerateJsonDataFailed = "Failed to generate JSON data for api: %s due to %s.";
static readonly WrappedCardVersion = "devPreview";
static readonly WrappedCardSchema = "https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.ResponseRenderingTemplate.schema.json";
static readonly WrappedCardResponseLayout = "list";
static readonly GetMethod = "get";
static readonly PostMethod = "post";
static readonly AdaptiveCardVersion = "1.5";
static readonly AdaptiveCardSchema = "http://adaptivecards.io/schemas/adaptive-card.json";
static readonly AdaptiveCardType = "AdaptiveCard";
static readonly TextBlockType = "TextBlock";
static readonly ImageType = "Image";
static readonly ContainerType = "Container";
static readonly RegistrationIdPostfix: {
[key: string]: string;
};
static readonly ResponseCodeFor20X: string[];
static readonly AllOperationMethods: string[];
static readonly WellknownResultNames: string[];
static readonly WellknownTitleName: string[];
static readonly WellknownSubtitleName: string[];
static readonly WellknownImageName: string[];
static readonly ShortDescriptionMaxLens = 80;
static readonly FullDescriptionMaxLens = 4000;
static readonly CommandDescriptionMaxLens = 128;
static readonly ParameterDescriptionMaxLens = 128;
static readonly ConversationStarterMaxLens = 50;
static readonly CommandTitleMaxLens = 32;
static readonly ParameterTitleMaxLens = 32;
static readonly SMERequiredParamsMaxNum = 5;
static readonly FunctionDescriptionMaxLens = 100;
static readonly DefaultPluginId = "plugin_1";
static readonly PluginManifestSchema = "https://developer.microsoft.com/json-schemas/copilot/plugin/v2.2/schema.json";
}
+7
View File
@@ -0,0 +1,7 @@
export { SpecParser } from "./specParser.browser";
export { SpecParserError } from "./specParserError";
export { ValidationStatus, WarningType, ErrorType, ListAPIResult } from "./interfaces";
export type { ErrorResult, APIInfo, ValidateResult, WarningResult, ParseOptions, AdaptiveCard, ProjectType, } from "./interfaces";
export { ConstantString } from "./constants";
export { Utils } from "./utils";
export { AdaptiveCardGenerator } from "./adaptiveCardGenerator";
+6
View File
@@ -0,0 +1,6 @@
export { SpecParser } from "./specParser";
export { SpecParserError } from "./specParserError";
export { ValidationStatus, WarningType, ErrorType, WarningResult, ErrorResult, ListAPIResult, APIInfo, ValidateResult, ParseOptions, AdaptiveCard, ProjectType, InvalidAPIInfo, AuthType, } from "./interfaces";
export { ConstantString } from "./constants";
export { Utils } from "./utils";
export { AdaptiveCardGenerator } from "./adaptiveCardGenerator";
+286
View File
@@ -0,0 +1,286 @@
import { IParameter } from "@microsoft/teams-manifest";
import { OpenAPIV3 } from "openapi-types";
/**
* An interface that represents the result of validating an OpenAPI specification file.
*/
export interface ValidateResult {
/**
* The validation status of the OpenAPI specification file.
*/
status: ValidationStatus;
/**
* An array of warning results generated during validation.
*/
warnings: WarningResult[];
/**
* An array of error results generated during validation.
*/
errors: ErrorResult[];
specHash?: string;
}
export interface SpecValidationResult {
/**
* An array of warning results generated during validation.
*/
warnings: WarningResult[];
/**
* An array of error results generated during validation.
*/
errors: ErrorResult[];
}
/**
* An interface that represents a warning result generated during validation.
*/
export interface WarningResult {
/**
* The type of warning.
*/
type: WarningType;
/**
* The content of the warning.
*/
content: string;
/**
* data of the warning.
*/
data?: any;
}
/**
* An interface that represents an error result generated during validation.
*/
export interface ErrorResult {
/**
* The type of error.
*/
type: ErrorType;
/**
* The content of the error.
*/
content: string;
/**
* data of the error.
*/
data?: any;
}
export interface GenerateResult {
allSuccess: boolean;
warnings: WarningResult[];
}
/**
* An enum that represents the types of errors that can occur during validation.
*/
export declare enum ErrorType {
SpecNotValid = "spec-not-valid",
RemoteRefNotSupported = "remote-ref-not-supported",
NoServerInformation = "no-server-information",
UrlProtocolNotSupported = "url-protocol-not-supported",
RelativeServerUrlNotSupported = "relative-server-url-not-supported",
NoSupportedApi = "no-supported-api",
NoExtraAPICanBeAdded = "no-extra-api-can-be-added",
AddedAPINotInOriginalSpec = "added-api-not-in-original-spec",
ResolveServerUrlFailed = "resolve-server-url-failed",
SwaggerNotSupported = "swagger-not-supported",
MultipleAuthNotSupported = "multiple-auth-not-supported",
SpecVersionNotSupported = "spec-version-not-supported",
CircularReferenceNotSupported = "circular-reference-not-supported",
ListFailed = "list-failed",
listSupportedAPIInfoFailed = "list-supported-api-info-failed",
FilterSpecFailed = "filter-spec-failed",
UpdateManifestFailed = "update-manifest-failed",
GenerateAdaptiveCardFailed = "generate-adaptive-card-failed",
GenerateFailed = "generate-failed",
ValidateFailed = "validate-failed",
GetSpecFailed = "get-spec-failed",
AuthTypeIsNotSupported = "auth-type-is-not-supported",
MissingOperationId = "missing-operation-id",
PostBodyContainMultipleMediaTypes = "post-body-contain-multiple-media-types",
ResponseContainMultipleMediaTypes = "response-contain-multiple-media-types",
ResponseJsonIsEmpty = "response-json-is-empty",
PostBodySchemaIsNotJson = "post-body-schema-is-not-json",
PostBodyContainsRequiredUnsupportedSchema = "post-body-contains-required-unsupported-schema",
ParamsContainRequiredUnsupportedSchema = "params-contain-required-unsupported-schema",
ParamsContainsNestedObject = "params-contains-nested-object",
RequestBodyContainsNestedObject = "request-body-contains-nested-object",
ExceededRequiredParamsLimit = "exceeded-required-params-limit",
NoParameter = "no-parameter",
NoAPIInfo = "no-api-info",
MethodNotAllowed = "method-not-allowed",
UrlPathNotExist = "url-path-not-exist",
Cancelled = "cancelled",
Unknown = "unknown"
}
/**
* An enum that represents the types of warnings that can occur during validation.
*/
export declare enum WarningType {
OperationIdMissing = "operationid-missing",
GenerateCardFailed = "generate-card-failed",
OperationOnlyContainsOptionalParam = "operation-only-contains-optional-param",
ConvertSwaggerToOpenAPI = "convert-swagger-to-openapi",
FuncDescriptionTooLong = "function-description-too-long",
OperationIdContainsSpecialCharacters = "operationid-contains-special-characters",
GenerateJsonDataFailed = "generate-json-data-failed",
Unknown = "unknown"
}
/**
* An enum that represents the validation status of an OpenAPI specification file.
*/
export declare enum ValidationStatus {
Valid = 0,
Warning = 1,
Error = 2
}
export interface TextBlockElement {
type: string;
text: string;
wrap: boolean;
}
export interface ImageElement {
type: string;
url: string;
$when: string;
}
export declare type AdaptiveCardBody = Array<TextBlockElement | ImageElement | ArrayElement>;
export interface ArrayElement {
type: string;
$data: string;
items: AdaptiveCardBody;
}
export interface AdaptiveCard {
type: string;
$schema: string;
version: string;
body: AdaptiveCardBody;
}
export interface PreviewCardTemplate {
title: string;
subtitle?: string;
image?: {
url: string;
alt?: string;
$when?: string;
};
}
export interface WrappedAdaptiveCard {
version: string;
$schema?: string;
jsonPath?: string;
responseLayout: string;
responseCardTemplate: AdaptiveCard;
previewCardTemplate: PreviewCardTemplate;
}
export interface CheckParamResult {
requiredNum: number;
optionalNum: number;
isValid: boolean;
reason: ErrorType[];
}
export interface ParseOptions {
/**
* If true, the parser will not throw an error if an ID is missing the spec file.
*/
allowMissingId?: boolean;
/**
* If true, the parser will allow parsing of Swagger specifications.
*/
allowSwagger?: boolean;
/**
* If true, the parser will allow API Key authentication in the spec file.
*/
allowAPIKeyAuth?: boolean;
/**
* If true, the parser will allow Bearer Token authentication in the spec file.
*/
allowBearerTokenAuth?: boolean;
/**
* If true, the parser will allow multiple parameters in the spec file. Teams AI project would ignore this parameters and always true
*/
allowMultipleParameters?: boolean;
/**
* If true, the parser will allow OAuth2 authentication in the spec file. Currently only support OAuth2 with auth code flow.
*/
allowOauth2?: boolean;
/**
* An array of HTTP methods that the parser will allow in the spec file.
*/
allowMethods?: string[];
/**
* If true, the parser will allow conversation starters in plugin file. Only take effect in Copilot project
*/
allowConversationStarters?: boolean;
/**
* If true, the parser will allow response semantics in plugin file. Only take effect in Copilot project
*/
allowResponseSemantics?: boolean;
/**
* If true, the paser will allow confirmation in plugin file. Only take effect in Copilot project
*/
allowConfirmation?: boolean;
/**
* The type of project that the parser is being used for.
* Project can be SME/Copilot/TeamsAi
*/
projectType?: ProjectType;
/**
* If true, we will generate files of plugin for GPT (Declarative Extensions in a Copilot Extension). Otherwise, we will generate files of plugin for Copilot.
*/
isGptPlugin?: boolean;
}
export declare enum ProjectType {
Copilot = 0,
SME = 1,
TeamsAi = 2
}
export interface APIInfo {
method: string;
path: string;
title: string;
id: string;
parameters: IParameter[];
description: string;
warning?: WarningResult;
}
export interface ListAPIInfo {
api: string;
server: string;
operationId: string;
isValid: boolean;
reason: ErrorType[];
auth?: AuthInfo;
}
export interface APIMap {
[key: string]: {
operation: OpenAPIV3.OperationObject;
isValid: boolean;
reason: ErrorType[];
};
}
export interface APIValidationResult {
isValid: boolean;
reason: ErrorType[];
}
export interface ListAPIResult {
allAPICount: number;
validAPICount: number;
APIs: ListAPIInfo[];
}
export declare type AuthType = OpenAPIV3.SecuritySchemeObject | {
type: "multipleAuth";
};
export interface AuthInfo {
authScheme: AuthType;
name: string;
}
export interface InvalidAPIInfo {
api: string;
reason: ErrorType[];
}
export interface InferredProperties {
title?: string;
subtitle?: string;
imageUrl?: string;
}
export interface ExistingPluginManifestInfo {
manifestPath: string;
specPath: string;
}
@@ -0,0 +1,6 @@
import { OpenAPIV3 } from "openapi-types";
export declare class JsonDataGenerator {
private static visitedSchemas;
static generate(schema: OpenAPIV3.SchemaObject): any;
static generateMockData(schema: OpenAPIV3.SchemaObject): any;
}
+15
View File
@@ -0,0 +1,15 @@
import { OpenAPIV3 } from "openapi-types";
import { AuthInfo, ExistingPluginManifestInfo, ParseOptions, WarningResult } from "./interfaces";
import { IMessagingExtensionCommand, TeamsAppManifest, PluginManifestSchema } from "@microsoft/teams-manifest";
export declare class ManifestUpdater {
static updateManifestWithAiPlugin(manifestPath: string, outputSpecPath: string, apiPluginFilePath: string, spec: OpenAPIV3.Document, options: ParseOptions, authInfo?: AuthInfo, existingPluginManifestInfo?: ExistingPluginManifestInfo): Promise<[TeamsAppManifest, PluginManifestSchema, WarningResult[]]>;
static updateManifestDescription(manifest: TeamsAppManifest, spec: OpenAPIV3.Document): void;
static checkSchema(schema: OpenAPIV3.SchemaObject, method: string, pathUrl: string): void;
static generatePluginManifestSchema(spec: OpenAPIV3.Document, specRelativePath: string, apiPluginFilePath: string, appName: string, authInfo: AuthInfo | undefined, options: ParseOptions, existingPluginManifestInfo?: ExistingPluginManifestInfo): Promise<[PluginManifestSchema, WarningResult[]]>;
static updateManifest(manifestPath: string, outputSpecPath: string, spec: OpenAPIV3.Document, options: ParseOptions, adaptiveCardFolder?: string, authInfo?: AuthInfo): Promise<[TeamsAppManifest, WarningResult[]]>;
static generateCommands(spec: OpenAPIV3.Document, manifestPath: string, options: ParseOptions, adaptiveCardFolder?: string): Promise<[IMessagingExtensionCommand[], WarningResult[]]>;
static getRelativePath(from: string, to: string): string;
static removeEnvs(str: string): string;
static removeAllSpecialCharacters(str: string): string;
static getConfirmationBodyItem(paramName: string): string;
}
+5
View File
@@ -0,0 +1,5 @@
import { OpenAPIV3 } from "openapi-types";
import { ParseOptions } from "./interfaces";
export declare class SpecFilter {
static specFilter(filter: string[], unResolveSpec: OpenAPIV3.Document, resolvedSpec: OpenAPIV3.Document, options: ParseOptions): OpenAPIV3.Document;
}
+18
View File
@@ -0,0 +1,18 @@
import { OpenAPIV3 } from "openapi-types";
export interface OptimizerOptions {
removeUnusedComponents: boolean;
removeUnusedTags: boolean;
removeUserDefinedRootProperty: boolean;
removeUnusedSecuritySchemas: boolean;
}
export declare class SpecOptimizer {
private static defaultOptions;
static optimize(spec: OpenAPIV3.Document, options?: OptimizerOptions): OpenAPIV3.Document;
private static removeUnusedSecuritySchemas;
private static removeUnusedTags;
private static removeUserDefinedRootProperty;
private static removeUnusedComponents;
private static getComponentReferences;
private static getComponent;
private static addComponent;
}
@@ -0,0 +1,60 @@
import SwaggerParser from "@apidevtools/swagger-parser";
import { OpenAPIV3 } from "openapi-types";
import { APIInfo, GenerateResult, ParseOptions, ValidateResult, ListAPIResult } 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 spec;
private validator;
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, 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.
* @param isMe Boolean that indicates whether the project is an Messaging Extension. For Messaging Extension, composeExtensions will be added in Teams app manifest.
*/
generate(manifestPath: string, filter: string[], outputSpecPath: string, adaptiveCardFolder?: string, signal?: AbortSignal): Promise<GenerateResult>;
private loadSpec;
private getAPIs;
private getValidator;
}
+61
View File
@@ -0,0 +1,61 @@
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;
}
@@ -0,0 +1,5 @@
import { ErrorType } from "./interfaces";
export declare class SpecParserError extends Error {
readonly errorType: ErrorType;
constructor(message: string, errorType: ErrorType);
}
+30
View File
@@ -0,0 +1,30 @@
import { OpenAPIV3 } from "openapi-types";
import { AuthInfo, AuthType, ErrorResult, ParseOptions } from "./interfaces";
import { IMessagingExtensionCommand, IParameter } from "@microsoft/teams-manifest";
export declare class Utils {
static hasNestedObjectInSchema(schema: OpenAPIV3.SchemaObject): boolean;
static isObjectSchema(schema: OpenAPIV3.SchemaObject): boolean;
static containMultipleMediaTypes(bodyObject: OpenAPIV3.RequestBodyObject | OpenAPIV3.ResponseObject): boolean;
static isBearerTokenAuth(authScheme: AuthType): boolean;
static isAPIKeyAuth(authScheme: AuthType): boolean;
static isOAuthWithAuthCodeFlow(authScheme: AuthType): boolean;
static getAuthArray(securities: OpenAPIV3.SecurityRequirementObject[] | undefined, spec: OpenAPIV3.Document): AuthInfo[][];
static getAuthInfo(spec: OpenAPIV3.Document): AuthInfo | undefined;
static updateFirstLetter(str: string): string;
static getResponseJson(operationObject: OpenAPIV3.OperationObject | undefined, allowMultipleMediaType?: boolean): {
json: OpenAPIV3.MediaTypeObject;
multipleMediaType: boolean;
};
static convertPathToCamelCase(path: string): string;
static getUrlProtocol(urlString: string): string | undefined;
static resolveEnv(str: string): string;
static checkServerUrl(servers: OpenAPIV3.ServerObject[]): ErrorResult[];
static validateServer(spec: OpenAPIV3.Document, options: ParseOptions): ErrorResult[];
static isWellKnownName(name: string, wellknownNameList: string[]): boolean;
static generateParametersFromSchema(schema: OpenAPIV3.SchemaObject, name: string, allowMultipleParameters: boolean, isRequired?: boolean): [IParameter[], IParameter[]];
static updateParameterWithInputType(schema: OpenAPIV3.SchemaObject, param: IParameter): void;
static parseApiInfo(operationItem: OpenAPIV3.OperationObject, options: ParseOptions): IMessagingExtensionCommand;
static format(str: string, ...args: string[]): string;
static getSafeRegistrationIdEnvName(authName: string): string;
static getServerObject(spec: OpenAPIV3.Document, method: string, path: string): OpenAPIV3.ServerObject | undefined;
}