Installations
npm install ajv-openapi
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
12.9.0
NPM Version
6.10.2
Score
77.8
Supply Chain
100
Quality
77.4
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (100%)
Developer
touchifyapp
Download Statistics
Total Downloads
773,685
Last Day
1,183
Last Week
3,311
Last Month
15,402
Last Year
202,095
GitHub Statistics
3 Stars
10 Commits
1 Forks
3 Watching
13 Branches
1 Contributors
Package Meta Information
Latest Version
2.0.0
Package Id
ajv-openapi@2.0.0
Unpacked Size
10.86 kB
Size
3.18 kB
File Count
8
NPM Version
6.10.2
Node Version
12.9.0
Total Downloads
Cumulative downloads
Total Downloads
773,685
Last day
74%
1,183
Compared to previous day
Last week
-7%
3,311
Compared to previous week
Last month
2.2%
15,402
Compared to previous month
Last year
-33.6%
202,095
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
ajv-openapi
Ajv plugin that adds Open API v3 data types (formats: int32, int64, float, double, byte) validation.
Installation
1npm install ajv ajv-openapi
Usage
1const Ajv = require("ajv"); 2const openApi = require("ajv-openapi"); 3 4const ajv = openApi(new Ajv());
Configuration for full OpenAPI compatibility
By default, the plugin only adds missing formats to Ajv validator. To configure Ajv to be fully Open API v3 compliant, you should configure the plugin like this:
1const Ajv = require("ajv"); 2const openApi = require("ajv-openapi"); 3 4const ajvOptions = { 5 schemaId: "auto", 6 format: "full", 7 coerceTypes: true, 8 unknownFormats: "ignore", 9 useDefaults: true, 10 nullable: true 11}; 12 13const openApiOptions = { 14 useDraft04: true 15}; 16 17const ajv = openApi( 18 new Ajv(ajvOptions), 19 openApiOptions 20);
Examples
1console.log(ajv.compile({ type: "integer", format: "int32" })(2147483648)); 2console.log(ajv.compile({ type: "integer", format: "int32" })(-2147483649)); 3console.log(ajv.compile({ type: "integer", format: "int32" })(1.23)); 4console.log(ajv.compile({ type: "integer", format: "int32" })(123)); 5> false 6> false 7> false 8> true 9 10console.log(ajv.compile({ type: "integer", format: "int64" })(Number.MAX_VALUE)); 11console.log(ajv.compile({ type: "integer", format: "int64" })(Number.MIN_VALUE)); 12console.log(ajv.compile({ type: "integer", format: "int64" })(1.23)); 13console.log(ajv.compile({ type: "integer", format: "int64" })(123)); 14> false 15> false 16> false 17> true 18 19console.log(ajv.compile({ type: "number", format: "float" })(Number.MAX_VALUE)); 20console.log(ajv.compile({ type: "number", format: "float" })(Number.MIN_VALUE)); 21console.log(ajv.compile({ type: "number", format: "float" })(1.23)); 22console.log(ajv.compile({ type: "number", format: "float" })(123)); 23> false 24> false 25> true 26> true 27 28console.log(ajv.compile({ type: "number", format: "double" })(Number.MAX_VALUE)); 29console.log(ajv.compile({ type: "number", format: "double" })(Number.MIN_VALUE)); 30console.log(ajv.compile({ type: "number", format: "double" })(1.23)); 31console.log(ajv.compile({ type: "number", format: "double" })(123)); 32> true 33> true 34> true 35> true 36 37console.log(ajv.compile({ type: "string", format: "byte" })("MTIz")); 38console.log(ajv.compile({ type: "string", format: "byte" })("abc")); 39console.log(ajv.compile({ type: "string", format: "byte" })(1)); 40console.log(ajv.compile({ type: "string", format: "byte" })("5L2g5aW95ZWK")); 41> true 42> false 43> false 44> true
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 0/9 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 1 are checked with a SAST tool
Reason
27 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6
- Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-5fw9-fq32-wv5p
- Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-6fc8-4gx4-v693
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
- Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh
Score
1.3
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to ajv-openapi
express-openapi-json
Builds an express-compatible router using OpenAPI with request and response validation.
ajv-openapi-compile
Generate a compiled AJV validation module from an OpenAPI definition.
express-ajv-swagger-validation
Input validation using Swagger (Open API) and ajv
@hckrnews/openapi-model
OpenAPI Model