var swaggerParser = require("swagger-parser")
var schema = {
"openapi": "3.0.0",
"info": {
"version": "1.2.3",
"title": "test api",
},
"paths": {
"/": {
"get": {
"responses": {
"888": { // <---- Invalid HTTP response code
"description": "response"
}
}
}
}
}
}
try {
let validated = await swaggerParser.validate(schema)
console.log('Successfully validated')
}
catch (error) {
console.error('Validation failed', error)
}