Closed Aposhian closed 4 years ago
Any PRs are welcome ;)
Upon further investigation, I was mistaken in stating that alter
and tailor
were being ignored. I was unclear about the behavior of strip()
.
I actually think that joi-to-swagger
is handling this correctly, since strip()
removes the property after validation.
forbidden()
successfully removes the property in the resulting swagger schema, even inside an alter.
So now my question is how to basically strip without validation, but without explicitly forbidding the property. But since that is more of a Joi question, I'm going to close this.
const MySchema = Joi.object({
myProperty: Joi.string().alter({
thisRemovesProperty: schema => schema.forbidden(),
thisKeepsProperty: schema => schema.strip()
})
})
In Joi, you can create subtle variants of a schema using alter and tailor. This is not reflected in the
joi-to-swagger
conversion.For example,
still produces