Skip to content
Docs
Migration Guide

Migration guide

OAS Tools npm package has been renamed from oas-tools to @oas-tools/core. When updating the package take into account that you have to first remove the old package through npm remove oas-tools, install the new with npm install --save @oas-tools/core and modify the imports.

Updating from OAS Tools v2

OAS Tools v3 is backwards compatible with the v2, so no changes need to be made to the code. However, if you want to use exclusive features from the v3, you need to change your code to match the OAS Tools v3 configuration and initialization.

Configuration

Since OAS Tools is backward compatible, the old v2 options are parsed to newer options upon initialization, and for those options that have been moved to external middlewares, the modules are automatically integrated in OAS Tools (but you still need to install them through NPM). The following table relates the configuration options of OAS Tools v2 to those of the new v3:

V2 OptiontypeV3 Optiontype
loglevelStringlogger.levelString
logfileStringlogger.logFile && logger.logFilePathBoolean && String
customLoggerObjectlogger.customLoggerObject
customErrorHandlingBooleanmiddleware.error.disable && middleware.error.customHandlerFunction
controllersStringmiddleware.router.controllersString
checkControllersBoolean* V3 Controllers are always checked for existence-
strictBooleanmiddleware.validator.strictBoolean
routerBooleanmiddleware.router.disableBoolean
validatorBooleanmiddleware.router.requestValidation middleware.router.responseValidationBoolean
oasSecurityBooleanmiddleware.security.disableBoolean
securityFileObjectmiddleware.security.authObject
oasAuthBoolean* Implemented by OAS Auth-
grantsFileObject* Implented by OAS Auth-
docs.apiDocsString* OAS Doc is not exposed in endpoints-
docs.apiDocsPrefixString* OAS Doc is not exposed in endpoints-
docs.swaggerUiStringmiddleware.swagger.pathString
docs.swaggerUiPrefixStringMust be included in middleware.swagger.path-
--packageJSONString
--oasFileString
--useAnnotationsString
--middleware.swagger.disableBoolean
--middleware.swagger.uiObject
--middleware.error.printStackTraceBoolean

Initialization

The intitialization function has been modified in the v3 to return a Promise instead of taking a callback in its arguments. However, the older initialization method is still possible and will get the v2 options parsed to v3. The new OAS Tools v3 initialization takes two arguments: express app, and optionally the configuration object. Check out the Configuration section for more information.

const http = require('http');
const express = require("express");
const oasTools = require("@oas-tools/core");
const app = express();

app.use(express.json());
const serverPort = 8080;

oasTools.initialize(app).then(() => {
    http.createServer(app).listen(serverPort, () => console.log("Server started!"));
})

The above snippet is using CommonJS syntax, but OAS Tools v3 is fully compatible with ESM/import syntax.