diff --git a/src/framework/ajv/index.ts b/src/framework/ajv/index.ts index 067467c4..edbc0404 100644 --- a/src/framework/ajv/index.ts +++ b/src/framework/ajv/index.ts @@ -11,21 +11,21 @@ interface SerDesSchema extends Partial { } export function createRequestAjv( - openApiSpec: OpenAPIV3.Document, + openApiSpec: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, options: Options = {}, ): AjvDraft4 { return createAjv(openApiSpec, options); } export function createResponseAjv( - openApiSpec: OpenAPIV3.Document, + openApiSpec: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, options: Options = {}, ): AjvDraft4 { return createAjv(openApiSpec, options, false); } function createAjv( - openApiSpec: OpenAPIV3.Document, + openApiSpec: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, options: Options = {}, request = true, ): AjvDraft4 { diff --git a/src/framework/index.ts b/src/framework/index.ts index 471d6183..8fe2ceb9 100644 --- a/src/framework/index.ts +++ b/src/framework/index.ts @@ -75,7 +75,7 @@ export class OpenAPIFramework { private loadSpec( filePath: string | object, $refParser: { mode: 'bundle' | 'dereference' } = { mode: 'bundle' }, - ): Promise { + ): Promise { // Because of this issue ( https://github.com/APIDevTools/json-schema-ref-parser/issues/101#issuecomment-421755168 ) // We need this workaround ( use '$RefParser.dereference' instead of '$RefParser.bundle' ) if asked by user if (typeof filePath === 'string') { @@ -87,7 +87,7 @@ export class OpenAPIFramework { $refParser.mode === 'dereference' ? $RefParser.dereference(absolutePath) : $RefParser.bundle(absolutePath); - return doc as Promise; + return doc as Promise; } else { throw new Error( `${this.loggingPrefix}spec could not be read at ${filePath}`, @@ -98,10 +98,10 @@ export class OpenAPIFramework { $refParser.mode === 'dereference' ? $RefParser.dereference(filePath) : $RefParser.bundle(filePath); - return doc as Promise; + return doc as Promise; } - private sortApiDocTags(apiDoc: OpenAPIV3.Document): void { + private sortApiDocTags(apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1): void { if (apiDoc && Array.isArray(apiDoc.tags)) { apiDoc.tags.sort((a, b): number => { return a.name < b.name ? -1 : 1; diff --git a/src/framework/openapi.context.ts b/src/framework/openapi.context.ts index 2df421f0..3f8e654e 100644 --- a/src/framework/openapi.context.ts +++ b/src/framework/openapi.context.ts @@ -6,7 +6,7 @@ export interface RoutePair { openApiRoute: string; } export class OpenApiContext { - public readonly apiDoc: OpenAPIV3.Document; + public readonly apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; public readonly expressRouteMap = {}; public readonly openApiRouteMap = {}; public readonly routes: RouteMetadata[] = []; diff --git a/src/framework/openapi.schema.validator.ts b/src/framework/openapi.schema.validator.ts index b378bd62..81a20f7b 100644 --- a/src/framework/openapi.schema.validator.ts +++ b/src/framework/openapi.schema.validator.ts @@ -56,7 +56,7 @@ export class OpenAPISchemaValidator { this.validator = ajvInstance.compile(schema); } - public validate(openapiDoc: OpenAPIV3.Document): { + public validate(openapiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1): { errors: Array | null; } { const valid = this.validator(openapiDoc); diff --git a/src/framework/openapi.spec.loader.ts b/src/framework/openapi.spec.loader.ts index bc0d075f..07c9ce52 100644 --- a/src/framework/openapi.spec.loader.ts +++ b/src/framework/openapi.spec.loader.ts @@ -6,7 +6,7 @@ import { } from './types'; export interface Spec { - apiDoc: OpenAPIV3.Document; + apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; basePaths: string[]; routes: RouteMetadata[]; } @@ -20,7 +20,7 @@ export interface RouteMetadata { } interface DiscoveredRoutes { - apiDoc: OpenAPIV3.Document; + apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; basePaths: string[]; routes: RouteMetadata[]; } @@ -47,7 +47,7 @@ export class OpenApiSpecLoader { const routes: RouteMetadata[] = []; const toExpressParams = this.toExpressParams; // const basePaths = this.framework.basePaths; - // let apiDoc: OpenAPIV3.Document = null; + // let apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1 = null; // let basePaths: string[] = null; const { apiDoc, basePaths } = await this.framework.initialize({ visitApi(ctx: OpenAPIFrameworkAPIContext): void { @@ -55,34 +55,36 @@ export class OpenApiSpecLoader { const basePaths = ctx.basePaths; for (const bpa of basePaths) { const bp = bpa.replace(/\/$/, ''); - for (const [path, methods] of Object.entries(apiDoc.paths)) { - for (const [method, schema] of Object.entries(methods)) { - if ( - method.startsWith('x-') || - ['parameters', 'summary', 'description'].includes(method) - ) { - continue; - } - const pathParams = new Set(); - const parameters = [...schema.parameters ?? [], ...methods.parameters ?? []] - for (const param of parameters) { - if (param.in === 'path') { - pathParams.add(param.name); + if (apiDoc.paths) { + for (const [path, methods] of Object.entries(apiDoc.paths)) { + for (const [method, schema] of Object.entries(methods)) { + if ( + method.startsWith('x-') || + ['parameters', 'summary', 'description'].includes(method) + ) { + continue; + } + const pathParams = new Set(); + const parameters = [...schema.parameters ?? [], ...methods.parameters ?? []] + for (const param of parameters) { + if (param.in === 'path') { + pathParams.add(param.name); + } } + const openApiRoute = `${bp}${path}`; + const expressRoute = `${openApiRoute}` + .split(':') + .map(toExpressParams) + .join('\\:'); + + routes.push({ + basePath: bp, + expressRoute, + openApiRoute, + method: method.toUpperCase(), + pathParams: Array.from(pathParams), + }); } - const openApiRoute = `${bp}${path}`; - const expressRoute = `${openApiRoute}` - .split(':') - .map(toExpressParams) - .join('\\:'); - - routes.push({ - basePath: bp, - expressRoute, - openApiRoute, - method: method.toUpperCase(), - pathParams: Array.from(pathParams), - }); } } } diff --git a/src/framework/types.ts b/src/framework/types.ts index 201e6fbf..342a434b 100644 --- a/src/framework/types.ts +++ b/src/framework/types.ts @@ -21,7 +21,7 @@ export interface ValidationSchema extends ParametersSchema { } export interface OpenAPIFrameworkInit { - apiDoc: OpenAPIV3.Document; + apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; basePaths: string[]; } export type SecurityHandlers = { @@ -109,7 +109,7 @@ export type SerDesMap = { }; export interface OpenApiValidatorOpts { - apiSpec: OpenAPIV3.Document | string; + apiSpec: OpenAPIV3.DocumentV3 | string; validateApiSpec?: boolean; validateResponses?: boolean | ValidateResponseOpts; validateRequests?: boolean | ValidateRequestOpts; @@ -152,7 +152,7 @@ export interface NormalizedOpenApiValidatorOpts extends OpenApiValidatorOpts { } export namespace OpenAPIV3 { - export interface Document { + export interface DocumentV3 { openapi: string; info: InfoObject; servers?: ServerObject[]; @@ -163,6 +163,13 @@ export namespace OpenAPIV3 { externalDocs?: ExternalDocumentationObject; } + export interface DocumentV3_1 extends Omit { + paths?: DocumentV3['paths'] + webhooks: { + [name: string]: PathItemObject | ReferenceObject + } + } + export interface InfoObject { title: string; description?: string; @@ -474,7 +481,7 @@ export interface OpenAPIFrameworkPathObject { } interface OpenAPIFrameworkArgs { - apiDoc: OpenAPIV3.Document | string; + apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1 | string; validateApiSpec?: boolean; $refParser?: { mode: 'bundle' | 'dereference'; @@ -484,7 +491,7 @@ interface OpenAPIFrameworkArgs { export interface OpenAPIFrameworkAPIContext { // basePaths: BasePath[]; basePaths: string[]; - getApiDoc(): OpenAPIV3.Document; + getApiDoc(): OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; } export interface OpenAPIFrameworkVisitor { diff --git a/src/middlewares/openapi.metadata.ts b/src/middlewares/openapi.metadata.ts index 2dae08a2..c2852cbb 100644 --- a/src/middlewares/openapi.metadata.ts +++ b/src/middlewares/openapi.metadata.ts @@ -15,7 +15,7 @@ import { httpMethods } from './parsers/schema.preprocessor'; export function applyOpenApiMetadata( openApiContext: OpenApiContext, - responseApiDoc: OpenAPIV3.Document, + responseApiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, ): OpenApiRequestHandler { return (req: OpenApiRequest, res: Response, next: NextFunction): void => { // note base path is empty when path is fully qualified i.e. req.path.startsWith('') diff --git a/src/middlewares/openapi.multipart.ts b/src/middlewares/openapi.multipart.ts index 5871ccce..930fed08 100644 --- a/src/middlewares/openapi.multipart.ts +++ b/src/middlewares/openapi.multipart.ts @@ -15,7 +15,7 @@ import { MulterError } from 'multer'; const multer = require('multer'); export function multipart( - apiDoc: OpenAPIV3.Document, + apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, options: MultipartOpts, ): OpenApiRequestHandler { const mult = multer(options.multerOpts); diff --git a/src/middlewares/openapi.request.validator.ts b/src/middlewares/openapi.request.validator.ts index 47748cb2..40efea19 100644 --- a/src/middlewares/openapi.request.validator.ts +++ b/src/middlewares/openapi.request.validator.ts @@ -21,6 +21,7 @@ import { import { BodySchemaParser } from './parsers/body.parse'; import { ParametersSchemaParser } from './parsers/schema.parse'; import { RequestParameterMutator } from './parsers/req.parameter.mutator'; +import { debug } from 'console'; type OperationObject = OpenAPIV3.OperationObject; type SchemaObject = OpenAPIV3.SchemaObject; @@ -31,13 +32,13 @@ type ApiKeySecurityScheme = OpenAPIV3.ApiKeySecurityScheme; export class RequestValidator { private middlewareCache: { [key: string]: RequestHandler } = {}; - private apiDoc: OpenAPIV3.Document; + private apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; private ajv: Ajv; private ajvBody: Ajv; private requestOpts: ValidateRequestOpts = {}; constructor( - apiDoc: OpenAPIV3.Document, + apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, options: RequestValidatorOptions = {}, ) { this.middlewareCache = {}; @@ -267,7 +268,7 @@ export class RequestValidator { } class Validator { - private readonly apiDoc: OpenAPIV3.Document; + private readonly apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; readonly schemaGeneral: object; readonly schemaBody: object; readonly validatorGeneral: ValidateFunction; @@ -275,7 +276,7 @@ class Validator { readonly allSchemaProperties: ValidationSchema; constructor( - apiDoc: OpenAPIV3.Document, + apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, parametersSchema: ParametersSchema, bodySchema: BodySchema, ajv: { @@ -329,7 +330,7 @@ class Validator { class Security { public static queryParam( - apiDocs: OpenAPIV3.Document, + apiDocs: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, schema: OperationObject, ): string[] { const hasPathSecurity = schema.security?.length > 0 ?? false; diff --git a/src/middlewares/openapi.response.validator.ts b/src/middlewares/openapi.response.validator.ts index 6166ca5a..6fdad5bf 100644 --- a/src/middlewares/openapi.response.validator.ts +++ b/src/middlewares/openapi.response.validator.ts @@ -27,14 +27,14 @@ interface ValidateResult { } export class ResponseValidator { private ajvBody: Ajv; - private spec: OpenAPIV3.Document; + private spec: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; private validatorsCache: { [key: string]: { [key: string]: ValidateFunction }; } = {}; private eovOptions: ValidateResponseOpts; constructor( - openApiSpec: OpenAPIV3.Document, + openApiSpec: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, options: Options = {}, eovOptions: ValidateResponseOpts = {}, ) { diff --git a/src/middlewares/openapi.security.ts b/src/middlewares/openapi.security.ts index b3dbfe98..ee163138 100644 --- a/src/middlewares/openapi.security.ts +++ b/src/middlewares/openapi.security.ts @@ -23,7 +23,7 @@ interface SecurityHandlerResult { error?: string; } export function security( - apiDoc: OpenAPIV3.Document, + apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, securityHandlers: SecurityHandlers, ): OpenApiRequestHandler { return async (req, res, next) => { diff --git a/src/middlewares/parsers/req.parameter.mutator.ts b/src/middlewares/parsers/req.parameter.mutator.ts index 00ece3cd..cebe0b05 100644 --- a/src/middlewares/parsers/req.parameter.mutator.ts +++ b/src/middlewares/parsers/req.parameter.mutator.ts @@ -39,14 +39,14 @@ type Schema = ReferenceObject | SchemaObject; * the request is mutated to accomodate various styles and types e.g. form, explode, deepObject, etc */ export class RequestParameterMutator { - private _apiDocs: OpenAPIV3.Document; + private _apiDocs: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; private path: string; private ajv: Ajv; private parsedSchema: ValidationSchema; constructor( ajv: Ajv, - apiDocs: OpenAPIV3.Document, + apiDocs: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, path: string, parsedSchema: ValidationSchema, ) { diff --git a/src/middlewares/parsers/schema.parse.ts b/src/middlewares/parsers/schema.parse.ts index cbd58e47..fb5d380c 100644 --- a/src/middlewares/parsers/schema.parse.ts +++ b/src/middlewares/parsers/schema.parse.ts @@ -17,9 +17,9 @@ type Parameter = OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject; */ export class ParametersSchemaParser { private _ajv: Ajv; - private _apiDocs: OpenAPIV3.Document; + private _apiDocs: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; - constructor(ajv: Ajv, apiDocs: OpenAPIV3.Document) { + constructor(ajv: Ajv, apiDocs: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1) { this._ajv = ajv; this._apiDocs = apiDocs; } diff --git a/src/middlewares/parsers/schema.preprocessor.ts b/src/middlewares/parsers/schema.preprocessor.ts index 283e8d4b..40d0babb 100644 --- a/src/middlewares/parsers/schema.preprocessor.ts +++ b/src/middlewares/parsers/schema.preprocessor.ts @@ -91,12 +91,12 @@ export const httpMethods = new Set([ ]); export class SchemaPreprocessor { private ajv: Ajv; - private apiDoc: OpenAPIV3.Document; - private apiDocRes: OpenAPIV3.Document; + private apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; + private apiDocRes: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1; private serDesMap: SerDesMap; private responseOpts: ValidateResponseOpts; constructor( - apiDoc: OpenAPIV3.Document, + apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, ajvOptions: Options, validateResponsesOpts: ValidateResponseOpts, ) { @@ -108,22 +108,28 @@ export class SchemaPreprocessor { public preProcess() { const componentSchemas = this.gatherComponentSchemaNodes(); - const r = this.gatherSchemaNodesFromPaths(); + let r; + + if (this.apiDoc.paths) { + r = this.gatherSchemaNodesFromPaths(); + } // Now that we've processed paths, clone a response spec if we are validating responses this.apiDocRes = !!this.responseOpts ? cloneDeep(this.apiDoc) : null; const schemaNodes = { schemas: componentSchemas, - requestBodies: r.requestBodies, - responses: r.responses, - requestParameters: r.requestParameters, + requestBodies: r?.requestBodies, + responses: r?.responses, + requestParameters: r?.requestParameters, }; // Traverse the schemas - this.traverseSchemas(schemaNodes, (parent, schema, opts) => + if (r) { + this.traverseSchemas(schemaNodes, (parent, schema, opts) => this.schemaVisitor(parent, schema, opts), ); + } return { apiDoc: this.apiDoc, diff --git a/src/middlewares/parsers/util.ts b/src/middlewares/parsers/util.ts index aa0642e3..0c2119e3 100644 --- a/src/middlewares/parsers/util.ts +++ b/src/middlewares/parsers/util.ts @@ -4,7 +4,7 @@ import ajv = require('ajv'); import { OpenAPIFramework } from '../../framework'; export function dereferenceParameter( - apiDocs: OpenAPIV3.Document, + apiDocs: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, parameter: OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject, ): OpenAPIV3.ParameterObject { // TODO this should recurse or use ajv.getSchema - if implemented as such, may want to cache the result diff --git a/src/openapi.validator.ts b/src/openapi.validator.ts index dd12fed2..4332521f 100644 --- a/src/openapi.validator.ts +++ b/src/openapi.validator.ts @@ -261,26 +261,26 @@ export class OpenApiValidator { private metadataMiddleware( context: OpenApiContext, - responseApiDoc: OpenAPIV3.Document, + responseApiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, ) { return middlewares.applyOpenApiMetadata(context, responseApiDoc); } - private multipartMiddleware(apiDoc: OpenAPIV3.Document) { + private multipartMiddleware(apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1) { return middlewares.multipart(apiDoc, { multerOpts: this.options.fileUploader, ajvOpts: this.ajvOpts.multipart, }); } - private securityMiddleware(apiDoc: OpenAPIV3.Document) { + private securityMiddleware(apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1) { const securityHandlers = (( this.options.validateSecurity ))?.handlers; return middlewares.security(apiDoc, securityHandlers); } - private requestValidationMiddleware(apiDoc: OpenAPIV3.Document) { + private requestValidationMiddleware(apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1) { const requestValidator = new middlewares.RequestValidator( apiDoc, this.ajvOpts.request, @@ -288,7 +288,7 @@ export class OpenApiValidator { return (req, res, next) => requestValidator.validate(req, res, next); } - private responseValidationMiddleware(apiDoc: OpenAPIV3.Document) { + private responseValidationMiddleware(apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1) { return new middlewares.ResponseValidator( apiDoc, this.ajvOpts.response, diff --git a/src/resolvers.ts b/src/resolvers.ts index 3092e3a3..18aba622 100644 --- a/src/resolvers.ts +++ b/src/resolvers.ts @@ -7,7 +7,7 @@ const cache = {}; export function defaultResolver( handlersPath: string, route: RouteMetadata, - apiDoc: OpenAPIV3.Document, + apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, ): RequestHandler { const tmpModules = {}; const { basePath, expressRoute, openApiRoute, method } = route; @@ -51,7 +51,7 @@ export function defaultResolver( export function modulePathResolver( handlersPath: string, route: RouteMetadata, - apiDoc: OpenAPIV3.Document, + apiDoc: OpenAPIV3.DocumentV3 | OpenAPIV3.DocumentV3_1, ): RequestHandler { const pathKey = route.openApiRoute.substring(route.basePath.length); const schema = apiDoc.paths[pathKey][route.method.toLowerCase()]; diff --git a/test/440.spec.ts b/test/440.spec.ts index e105f07e..50960245 100644 --- a/test/440.spec.ts +++ b/test/440.spec.ts @@ -9,7 +9,7 @@ describe(packageJson.name, () => { before(async () => { // Set up the express app - const apiSpec: OpenAPIV3.Document = { + const apiSpec: OpenAPIV3.DocumentV3 = { openapi: '3.0.0', info: { title: 'Api test', version: '1.0.0' }, servers: [{ url: '/api' }], diff --git a/test/478.spec.ts b/test/478.spec.ts index 5825bc22..232ae659 100644 --- a/test/478.spec.ts +++ b/test/478.spec.ts @@ -53,7 +53,7 @@ describe('issue #478', () => { .expect(200)); }); -function apiSpec(): OpenAPIV3.Document { +function apiSpec(): OpenAPIV3.DocumentV3 { return { openapi: '3.0.3', info: { diff --git a/test/535.spec.ts b/test/535.spec.ts index c07beee8..a7dd79bb 100644 --- a/test/535.spec.ts +++ b/test/535.spec.ts @@ -19,7 +19,7 @@ describe('#535 - calling `middleware()` multiple times', () => { }); async function createApp( - apiSpec: OpenAPIV3.Document, + apiSpec: OpenAPIV3.DocumentV3, ): Promise { const app = express(); @@ -39,7 +39,7 @@ async function createApp( return app; } -function createApiSpec(): OpenAPIV3.Document { +function createApiSpec(): OpenAPIV3.DocumentV3 { return { openapi: '3.0.3', info: { diff --git a/test/577.spec.ts b/test/577.spec.ts index 4c9b26fa..a142d45a 100644 --- a/test/577.spec.ts +++ b/test/577.spec.ts @@ -21,7 +21,7 @@ describe('#577 - Exclude response validation that is not in api spec', () => { }); async function createApp( - apiSpec: OpenAPIV3.Document, + apiSpec: OpenAPIV3.DocumentV3, ): Promise { const app = express(); @@ -51,7 +51,7 @@ async function createApp( return app; } -function createApiSpec(): OpenAPIV3.Document { +function createApiSpec(): OpenAPIV3.DocumentV3 { return { openapi: '3.0.3', info: { diff --git a/test/699.spec.ts b/test/699.spec.ts index 2997299b..4e3399e2 100644 --- a/test/699.spec.ts +++ b/test/699.spec.ts @@ -182,7 +182,6 @@ describe('699 serialize response components only', () => { 3005, (app) => { app.get([`${app.basePath}/users/:id?`], (req, res) => { - debugger; if (typeof req.params.id !== 'string') { throw new Error("Should be not be deserialized to ObjectId object"); } diff --git a/test/821.spec.ts b/test/821.spec.ts index 42eda867..5b9bc75d 100644 --- a/test/821.spec.ts +++ b/test/821.spec.ts @@ -30,7 +30,7 @@ describe('issue #821 - serialization inside addiotionalProperties', () => { }); async function createApp( - apiSpec: OpenAPIV3.Document | string, + apiSpec: OpenAPIV3.DocumentV3 | string, ): Promise { const app = express(); diff --git a/test/allow.header.spec.ts b/test/allow.header.spec.ts index 25620c81..04415919 100644 --- a/test/allow.header.spec.ts +++ b/test/allow.header.spec.ts @@ -50,7 +50,7 @@ async function createApp(): Promise { return app; } -function createApiSpec(): OpenAPIV3.Document { +function createApiSpec(): OpenAPIV3.DocumentV3 { return { openapi: '3.0.3', info: { diff --git a/test/invalid.apispec.spec.ts b/test/invalid.apispec.spec.ts index 2b7b02e8..0ded5b10 100644 --- a/test/invalid.apispec.spec.ts +++ b/test/invalid.apispec.spec.ts @@ -41,7 +41,7 @@ async function createApp( return app; } -function createApiSpec(): OpenAPIV3.Document { +function createApiSpec(): OpenAPIV3.DocumentV3 { return { openapi: '3.0.3', info: { diff --git a/test/no.components.spec.ts b/test/no.components.spec.ts index 0373bd3f..866f371b 100644 --- a/test/no.components.spec.ts +++ b/test/no.components.spec.ts @@ -33,7 +33,7 @@ describe('no components', () => { })); }); -function apiDoc(): OpenAPIV3.Document { +function apiDoc(): OpenAPIV3.DocumentV3 { return { openapi: '3.0.1', info: { diff --git a/test/petstore.spec.ts b/test/petstore.spec.ts index 1edf43e7..8588f5b5 100644 --- a/test/petstore.spec.ts +++ b/test/petstore.spec.ts @@ -36,7 +36,7 @@ describe('petstore', () => { request(app).get(`${app.basePath}/pets`).expect(200)); }); -function petstoreSpec(): OpenAPIV3.Document { +function petstoreSpec(): OpenAPIV3.DocumentV3 { return { openapi: '3.0.0', info: { diff --git a/test/user-request-url.router.spec.ts b/test/user-request-url.router.spec.ts index 4bba5dee..d4470ba4 100644 --- a/test/user-request-url.router.spec.ts +++ b/test/user-request-url.router.spec.ts @@ -112,7 +112,7 @@ function defaultResponse(): OpenAPIV3.ResponseObject { type of id in path and id in the response here defined as simple string with minLength */ -const gatewaySpec: OpenAPIV3.Document = { +const gatewaySpec: OpenAPIV3.DocumentV3 = { openapi: '3.0.0', info: { version: '1.0.0', title: 'test bug OpenApiValidator' }, servers: [{ url: 'http://localhost:3000/api' }], @@ -168,7 +168,7 @@ const gatewaySpec: OpenAPIV3.Document = { represents spec of the child router. We route request from main app (gateway) to this router. This router has its own schema, routes and validation formats. In particular, we force id in the path and id in the response to be uuid. */ -const childRouterSpec: OpenAPIV3.Document = { +const childRouterSpec: OpenAPIV3.DocumentV3 = { openapi: '3.0.0', info: { version: '1.0.0', title: 'test bug OpenApiValidator' }, servers: [{ url: 'http://localhost:3000/' }],