import { SchemaValidateIssue } from "../swaggerValidator/schemaValidator"; import { RuntimeException } from "../util/validationError"; import { ApiValidationErrorCode } from "../util/errorDefinitions"; import { LiveValidatorLoaderOption } from "./liveValidatorLoader"; import { OperationSearcher } from "./operationSearcher"; import { LiveRequest, LiveResponse, OperationContext, ValidationRequest } from "./operationValidator"; export interface LiveValidatorOptions extends LiveValidatorLoaderOption { swaggerPaths: string[]; git: { shouldClone: boolean; url?: string; branch?: string; }; useRelativeSourceLocationUrl?: boolean; directory: string; swaggerPathsPattern: string[]; excludedSwaggerPathsPattern: string[]; isPathCaseSensitive: boolean; loadValidatorInBackground: boolean; loadValidatorInInitialize: boolean; enableRoundTripValidator?: boolean; isArmCall?: boolean; } export interface RequestResponsePair { readonly liveRequest: LiveRequest; readonly liveResponse: LiveResponse; } export interface LiveValidationResult { readonly isSuccessful?: boolean; readonly operationInfo: OperationContext; readonly errors: LiveValidationIssue[]; readonly runtimeException?: RuntimeException; } export interface RequestResponseLiveValidationResult { readonly requestValidationResult: LiveValidationResult; readonly responseValidationResult: LiveValidationResult; readonly runtimeException?: RuntimeException; } export type LiveValidationIssue = { code: ApiValidationErrorCode; pathsInPayload: string[]; resourceIds?: string[]; documentationUrl?: string; } & Omit; /** * Additional data to log. */ interface Meta { [key: string]: any; } /** * Options for a validation operation. * If `includeErrors` is missing or empty, all error codes will be included. */ export interface ValidateOptions { readonly includeErrors?: ApiValidationErrorCode[]; readonly includeOperationMatch?: boolean; } export declare enum LiveValidatorLoggingLevels { error = "error", warn = "warn", info = "info", verbose = "verbose", debug = "debug", silly = "silly" } export declare enum LiveValidatorLoggingTypes { trace = "trace", perfTrace = "perfTrace", error = "error", incomingRequest = "incomingRequest", specTrace = "specTrace" } /** * @class * Live Validator for Azure swagger APIs. */ export declare class LiveValidator { options: LiveValidatorOptions; operationSearcher: OperationSearcher; swaggerList: string[]; private logFunction?; private loader?; private loadInBackgroundComplete; private validateRequestResponsePair?; /** * Constructs LiveValidator based on provided options. * * @param {object} ops The configuration options. * @param {callback function} logCallback The callback logger. * * @returns CacheBuilder Returns the configured CacheBuilder object. */ constructor(options?: Partial, logCallback?: (message: string, level: string, meta?: Meta) => void); /** * Initializes the Live Validator. */ initialize(): Promise; isLoadInBackgroundCompleted(): boolean; private loadAllSpecValidatorInBackground; /** * Validates live request. */ validateLiveRequest(liveRequest: LiveRequest, options?: ValidateOptions, operationInfo?: OperationContext): Promise; /** * Validates live response. */ validateLiveResponse(liveResponse: LiveResponse, specOperation: { url: string; method: string; }, options?: ValidateOptions, operationInfo?: OperationContext): Promise; /** * Validates live request and response. */ validateLiveRequestResponse(requestResponseObj: RequestResponsePair, options?: ValidateOptions): Promise; private transformResponseStatusCode; getOperationInfo(request: { url: string; method: string; headers?: { [propertyName: string]: string; }; }, operationInfo?: OperationContext): { info: OperationContext; error?: any; }; getResolvedOperationInfo(request: { url: string; method: string; headers?: { [propertyName: string]: string; }; }, operationInfo?: OperationContext): { info: OperationContext; error?: any; }; private getMatchedPaths; validateRoundTrip(requestResponseObj: RequestResponsePair): Promise; private getSwaggerPaths; private getSwaggerInitializer; private logging; } /** * OAV expects the url that is sent to match exactly with the swagger path. For this we need to keep only the part after * where the swagger path starts. Currently those are '/subscriptions' and '/providers'. */ export declare function formatUrlToExpectedFormat(requestUrl: string): string; /** * Parse the validation request information. * * @param requestUrl The url of service api call. * * @param requestMethod The http verb for the method to be used for lookup. * * @param correlationId The id to correlate the api calls. * * @param activityId The id maps to request id, used by RPaaS. * * @returns parsed ValidationRequest info. * * @deprecated use parseValidationRequest instead. */ export declare const legacyParseValidationRequest: (requestUrl: string, requestMethod: string | undefined | null, correlationId: string, activityId: string) => ValidationRequest; /** * Parse the validation request information. * * @param requestUrl The url of service api call. * * @param requestMethod The http verb for the method to be used for lookup. * * @param headers Optional headers * * @returns parsed ValidationRequest info. */ export declare const parseValidationRequest: (requestUrl: string, requestMethod: string, headers?: { [propertyName: string]: string; }) => ValidationRequest; export {}; //# sourceMappingURL=liveValidator.d.ts.map