Вы можете определить свойство как строку и установить максимальную длину равной нулю. Там нет ничего, что конкретно говорит additionalProperties: true, except for passwordHash
.
type: object
properties:
passwordHash:
type: string
format: password
maxLength: 0
В качестве альтернативы вы можете просто пройти объект перед отправкой и удалить нежелательное свойство. Например:
function removeProperty(property, value) {
if (Array.isArray(value)) {
return value.map(item => removeProperty(property, item))
} else if (value && typeof value === 'object') {
const result = {}
Object.keys(value)
.forEach(key => {
if (key !== property) {
result[key] = removeProperty(property, value[key])
}
})
return result
} else {
return value
}
}
const object = {
x: {
y: {
z: 1,
secret: 'password'
}
}
}
const clean = removeProperty('secret', object)
console.log(clean) // => { x: { y: { z: 1 } } }