![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
openapi-enforcer
Advanced tools
Library for validating, parsing, and formatting data against open api schemas.
Tools for using the Open API Specification (OAS)
Supports OAS 2.0 (formerly Swagger) and OAS 3.x.x
npm install openapi-enforcer
Use the Enforcer to load and resolve all $ref values and then to validate the complete document.
const Enforcer = require('openapi-enforcer')
async function run () {
const [openapi, error, warning] = await Enforcer('./path/to/openapi.yml', {
fullResult: true
})
if (error !== undefined) console.error(error)
if (warning !== undefined) console.warn(warning)
if (openapi !== undefined) console.log('Document is valid')
}
run.catch(console.error)
const Enforcer = require('openapi-enforcer')
async function run () {
// Because we don't specify `fullResult: true`, any errors will throw an exception and
// warnings will be logged to the console.
const openapi = await Enforcer('./path/to/openapi.yml')
// If the request is valid then the req object will contain the parsed and validated request.
// If it is invalid then the error will contain details about what was wrong with the
// request and these details are safe to return to the client that made the request.
const [ req, error ] = openapi.request({
method: 'POST',
path: '/tasks',
// the body should be parsed by a JSON.parse() prior to passing in (if applicable).
body: { task: 'Buy Milk', quantity: 2 }
})
// You can use the req.operation property to look at the properties from your OpenAPI document.
// A good use of this is to look at the operationId you defined there to determine which path
// is being used to handle the request.
if (req.operaton.operationId === 'my-operation-id') {
// ... additional request processing
}
}
run.catch(console.error)
const Enforcer = require('openapi-enforcer')
async function run () {
const openapi = await Enforcer('./path/to/openapi.yml')
const [ req ] = openapi.request({
method: 'POST',
path: '/tasks',
// the body should be parsed by a JSON.parse() prior to passing in (if applicable).
body: { task: 'Buy Milk', quantity: 2 }
})
const body = { id: 1, task: 'Buy Milk', quantity: 2, dateCompleted: null }
const headers = {}
// This will validate the response code, body, and headers. It will also correctly serialize
// the body and headers for sending to the client that made the request. Using this method
// you'll never send back a response that does not match what your OpenAPI document defines.
const [ res, error ] = req.response(200, body, headers)
console.log(res.body, res.headers)
}
run.catch(console.error)
1.18.0
Case Sensitivity Optional For Paths
The default behavior is for paths to be case sensitive. There is now an option Enforcer.config.useCaseSensitivePaths
(defaulting to true
) that when set to false
will change how paths duplicates are validated and how paths are looked up when attempting to match a path to a request.
FAQs
Library for validating, parsing, and formatting data against open api schemas.
The npm package openapi-enforcer receives a total of 0 weekly downloads. As such, openapi-enforcer popularity was classified as not popular.
We found that openapi-enforcer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.