Gathering detailed insights and metrics for @leoscope/openapi-response-validator
Gathering detailed insights and metrics for @leoscope/openapi-response-validator
Gathering detailed insights and metrics for @leoscope/openapi-response-validator
Gathering detailed insights and metrics for @leoscope/openapi-response-validator
A Monorepo of various packages to power OpenAPI in node
npm install @leoscope/openapi-response-validator
Typescript
Module System
Node Version
NPM Version
JavaScript (64.43%)
TypeScript (35.38%)
Shell (0.19%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
918 Stars
1,374 Commits
239 Forks
13 Watchers
228 Branches
114 Contributors
Updated on Jul 10, 2025
Latest Version
1.0.2
Package Id
@leoscope/openapi-response-validator@1.0.2
Unpacked Size
52.62 kB
Size
16.17 kB
File Count
7
NPM Version
8.1.4
Node Version
17.2.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
Validate a response according to an openapi schema.
$ref
in response schemas i.e. #/definitions/SomeType
.See ./test/data-driven/*.js
for more examples.
1var OpenAPIResponseValidator = require('openapi-response-validator'); 2var responseValidator = new OpenAPIResponseValidator({ 3 responses: { 4 200: { 5 description: 'We found what you were looking for.', 6 schema: { 7 $ref: '#/definitions/ResourceResponse' 8 } 9 }, 10 default: { 11 description: 'Something happened...', 12 schema: { 13 $ref: '#/definitions/SomeErrorResponse' 14 } 15 } 16 }, 17 definitions: { 18 ResourceResponse: { 19 type: 'object', 20 properties: { 21 id: { 22 type: 'integer' 23 }, 24 name: { 25 type: 'string' 26 } 27 }, 28 required: ['id', 'name'] 29 }, 30 SomeErrorResponse: { 31 type: 'object', 32 properties: { 33 errorCode: { 34 type: 'string' 35 }, 36 message: { 37 type: 'string' 38 } 39 } 40 } 41 } 42}); 43 44var someResource = {}; 45var validationError = responseValidator.validateResponse(200, someResource); 46 47/* 48 Validation errors look like this (except for objects in the errors array which 49 may be overridden with errorTransformer): 50 { 51 status: 500, 52 message: 'The response was not valid.', 53 errors: [ 54 { 55 path: 'foo', 56 errorCode: 'type.openapi.responseValidation', 57 message: is not of a type(s) string' 58 } 59 ] 60 } 61*/
Type | Required | Default Value | Description |
---|---|---|---|
Object | Y | N/A | Arguments to configure the middleware. |
Type | Required | Default Value | Description |
---|---|---|---|
String | N | '' | A prefix to use with constructor errors and logging messages. |
Keys may be any HTTP status code or default
(for all HTTP status codes). See
http://swagger.io/specification/#responsesObject.
Type | Required | Default Value | Description |
---|---|---|---|
Object | Y | N/A | A key value pair of response definitions. At least one response definition is to be provided. |
Keys may be any HTTP status code or default
(for all HTTP status codes). See
http://swagger.io/specification/#responsesObject.
Type | Required | Default Value | Description |
---|---|---|---|
Object | N | N/A | A key value pair of type definitions |
This object is used to support $ref
in your responses
Type | Required | Default Value | Description |
---|---|---|---|
Function | N | toOpenapiValidationError (see the source) | A function that receives an error and returns a mapped version of the error. |
This function is passed 2 arguments.
errorTransformer: function(openapiError, ajvError) {
return {
message: openapiError.message
};
}
See the error format in ajv for
ajvError
. openapiError
s have the following properties:
errorCode
- A jsonschema error suffixed with .openapi.responseValidation
.
failed.message
- A detailed message as to why validation failed.path
- The property of the response body that failed validation.Type | Required | Default Value | Description |
---|---|---|---|
Object | N | null | An object of custom formats. |
Each key is the name of the format to be used with the format
keyword. Each value
is a function that accepts an input and returns a boolean value.
See Custom Formats in jsonschema.
The MIT License (MIT)
Copyright (c) 2018 Kogo Software LLC
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 4
Details
Reason
Found 7/20 approved changesets -- score normalized to 3
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
51 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-14
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 More