Skip to content

Releases: BRIKEV/express-oas-validator

v3.0.1

22 Sep 17:45
Compare
Choose a tag to compare

This new release adds Typescript support.

What's changed

🐛 Bugfixes

  • None

☁️ Codeclimate

  • None

✨ Features

  • Add typescript support (#29)

📦 Dependencies

  • Upgrade dependencies

v3.0.0

04 Feb 13:35
Compare
Choose a tag to compare

This new release contains a number of significant changes which are summarized in the "What's changed" section below. Check the referenced PRs or the full changelog for more details.

⚠️ Important warning ⚠️

As this release fixes an important performance issue, updating your projects to use this version is strongly recommended.

Keep in mind, however, that this release also contains breaking changes, as the way to initialize the library and access to its methods is now different. This means that upgrading won't be as straightforward as just updating your package.json files and will require you to make changes into your application's code.

Please, refer to the migration instructions below shall you need more information on how to change your code to work with the latest release.

What's changed

🐛 Bugfixes

  • Fix memory leak issue (#28)

☁️ Codeclimate

  • Remove unneeded parameter in paramsValidator function (#25)

✨ Features

  • Add support for multiple instances (#26)

📦 Dependencies

  • Upgrade openapi-validator-utils to its latest version (#28)

Migration instructions

As stated above, this release includes breaking changes that modify the way in which the library is initialized and how the validation middleware are imported. If you were already using 2.0.2 or other previous version on your project, you'll need to make some changes to the code to adjust to the new way of using the library.

❔ What's the breaking change?

Previously, the library consisted on a singleton instance that was initialized upon the init method execution, and the provided validateRequest and validateResponse methods could be directly imported from the library and used from anywhere else.

There was an issue with this, though, and it's that it was not possible to create multiple instances based upon different open api definition objects within the same project.

In order to cope with this user case and allow for more flexibility, changes introduced in #26 used an entirely different approach: the library will no longer store and handle the validator instances itself. Instead, it's the clients using it who will be in charge of generating and storing as many instances as they need.

As a consequence of this, validateRequest and validateResponse middlewares will no longer be exported at global level. Instead, they'll be provided at instance level.

❌ Compliant code for version 2

In version 2, the init method initialized a validator instance that was stored in the library's inner state.

const { init } = require('express-oas-validator');

init(swaggerDefinition);

This is no longer the case in version 3: init won't be initializing a global instance stored by the library itself, meaning directly importing validateRequest and validateResponse will not work anymore.

const { validateRequest, validateResponse } = require('express-oas-validator');

✔️ Updating our code to work with version 3

  • Step 1: Store validation instance in application state

The init method in this new version returns an instance of the validator. That instance provides both validateRequest and validateResponse methods. This means that, in order to use them, you need to store that instance and make it accessible to any source file where you may need to use the validation middlewares.

The easiest way to go would be to create a global variable to store the instance and export its value, as in the example below:

const { init } = require('express-oas-validator');

// Each instance of the validator will provide two methods to perform validation
const myValidatorInstance = init(swaggerDefinition);

module.exports = myValidatorInstance;

This approach will make it very simple for you to reuse the validateRequest and validateResponse among multiple files, so you'll be able to migrate with hardly no effort to version 3.

  • Step 2: Store validation instance in application state

In order to use validateRequest or validateResponse methods, you'll need to directly get them from your instance. If you followed the example described above, this process should be as simple as replacing your import stataments to reference the file with your instance instead of the library.

const { validateRequest, validateResponse } = require('./my-validator-instance');

v2.0.2

31 May 23:10
Compare
Choose a tag to compare

This release contains:

Bugfixes

  • Error with config parameters (#20)
  • internal express route (#21)

Codeclimate

None

Features

None

Dependencies

None

v2.0.1

16 May 00:03
Compare
Choose a tag to compare

This release contains:

Bugfixes

  • file validation (#17)

Codeclimate

None

Features

None

Dependencies

  • update dependencies (#16)

v2.0.0

30 Apr 12:39
Compare
Choose a tag to compare

This release contains:

Bugfixes

  • Exclude additional options from content type validation (#14)
  • Exclude undefined values from additional props validation (#13)

Codeclimate

None

Features

  • Rename validate methods to validateRequest and validateResponse (#15)

Dependencies

  • Bump openapi-validator-utils to v1.1.4

v1.0.4

27 Apr 22:57
Compare
Choose a tag to compare

This release contains:

Bugfixes

None

Codeclimate

None

Features

None

Dependencies

  • Bump openapi-validator-utils to v1.1.3

v1.0.3

18 Apr 21:30
Compare
Choose a tag to compare

This release contains:

Bugfixes

None

Codeclimate

None

Features

None

Dependencies

  • Bump openapi-validator-utils to v1.0.4

v1.0.2

11 Apr 20:57
Compare
Choose a tag to compare

This release contains:

Bugfixes

None

Codeclimate

None

Features

None

Dependencies

  • Bump openapi-validator-utils to v1.0.3

v1.0.1

11 Apr 19:32
Compare
Choose a tag to compare

This release contains:

Bugfixes

None

Codeclimate

Features

  • improve error messages (#7)

Dependencies

  • Bump openapi-validator-utils to v1.0.2

v1.0.0

09 Apr 12:40
f05f6df
Compare
Choose a tag to compare

express-oas-validator first version of the package.