Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 4x 4x 1x 4x 4x 1x | import Ajv from "ajv-draft-04";
const ajv = new Ajv({
strict: true,
validateFormats: false,
});
// Removed the checking of formats, as AWS API Gateway has additional formats, and
// will delegate to specific rules to make easier to spot compatible/incompatible formats.
//addFormats(ajv, ["date-time","email","hostname","ipv4","ipv6","uri"])
ajv.addKeyword("example"); // Added 'example' keyword as picked up by `aws-example-tag` rule.
// function validate_json() {
// };
var draft4 = (targetVal, _opts, context) => {
let openapi = JSON.parse(JSON.stringify(targetVal));
const results = [];
Eif (openapi.components.schemas) {
const schemaList = openapi.components.schemas;
for (const property in schemaList) {
Eif (Object.prototype.hasOwnProperty.call(schemaList, property)) {
const schema_model = schemaList[property];
schema_model.id = `#/components/schemas/${property}`;
try {
let schema = schemaList[property];
ajv.addSchema(schema);
} catch (error) {
console.log(`${property} failed to add due to ${error}`);
}
}
}
for (const property in schemaList) {
try {
ajv.compile(schemaList[property]);
} catch (error) {
results.push({
message: `${error}`,
path: ["components", "schemas", property],
});
}
}
}
return results;
};
export default draft4;
|