Open TheLox95 opened 2 years ago
hey there, just passing through. seems like i had a similar issue whereby ajv couldn't compile/validate OpenAPI schemas when using ajv-keywords with transform
. if this was the same issue as yours, i was able to work around it by importing the underlying .json for the OpenAPI JSON schema directly, modifying that schema, and then manually passing it into an ajv
instance instead of the validator in openapi-schema-validator
. here's an example:
import Ajv from 'ajv';
import openApiJsonSchema from 'openapi-schema-validator/dist/resources/openapi-3.0.json';
openApiJsonSchema.definitions.schema.properties.transform = {
type: 'array',
items: {type: 'string'},
};
const ajv = new Ajv({
removeAdditional: true,
useDefaults: true,
allErrors: true,
coerceTypes: true,
strict: true,
strictRequired: false,
});
const validate = ajv.compile(openApiJsonSchema);
// ... do validation ...
hope that helps! ✌️
I would like to add an extra property to the
OpenAPIV3.SchemaObject
interface likeWhere
transform
is a custom keyword defined in the ajv-keywords library. How can we do this?