Skip to content

Commit

Permalink
type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
Carmine DiMascio committed Dec 29, 2019
1 parent 4b30ba3 commit dcf3846
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/framework/ajv/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ function createAjv(
return function validate(data, path, obj, propName) {
const isValid = !(sch === true && data != null);
delete obj[propName];
(<any>validate).errors = [
(<ajv.ValidateFunction>validate).errors = [
{
keyword: 'readOnly',
schemaPath: data,
dataPath: path,
message: `is read-only`,
params: { readOnly: propName },
Expand All @@ -68,10 +69,11 @@ function createAjv(
if (sch) {
return function validate(data, path, obj, propName) {
const isValid = !(sch === true && data != null);
(<any>validate).errors = [
(<ajv.ValidateFunction>validate).errors = [
{
keyword: 'writeOnly',
dataPath: path,
schemaPath: path,
message: `is write-only`,
params: { writeOnly: propName },
},
Expand All @@ -86,11 +88,9 @@ function createAjv(
}

if (openApiSpec.components?.schemas) {
Object.entries(openApiSpec.components.schemas).forEach(
([id, schema]: any[]) => {
ajv.addSchema(schema, `#/components/schemas/${id}`);
},
);
Object.entries(openApiSpec.components.schemas).forEach(([id, schema]) => {
ajv.addSchema(schema, `#/components/schemas/${id}`);
});
}

return ajv;
Expand Down

0 comments on commit dcf3846

Please sign in to comment.