Support JSON Schema 2019-09 deprecated value
Prerequisites
- [X] I have written a descriptive issue title
- [X] I have searched existing issues to ensure the feature has not already been requested
🚀 Feature Proposal
Add support to deprecated values as stated in the JSON Schema 2019-09 paragraph.
Motivation
Be able to deprecate properties without raw().
Example
S.object().prop('myDeprecatedProperty', S.string()).deprecated();
Current workaround:
S.object().prop('myDeprecatedProperty', S.string()).raw({ deprecated: true });
Would you like to send a Pull Request to address this feature? Remember to add unit tests.
the actual syntax: S.object().prop('myDeprecatedProperty', S.string().deprecated());
I tried to address it on #161 but I'm not sure about handling this property inheritance.
Should array properties with a single schema item inherit 'deprecated' property?
Which one should resolve?
expect(
S.object()
.prop('foo', S.string())
.prop('bar', S
.array()
.items(S.number().deprecated())
)
.valueOf()
).toEqual({
$schema: 'http://json-schema.org/draft-07/schema#',
type: 'object',
properties: {
foo: { type: 'string' },
bar: {
type: 'array',
deprecated: true,
items: { type: 'number' }
}
},
})
expect(
S.object()
.prop('foo', S.string())
.prop('bar', S
.array()
.items(S.number().deprecated())
)
.valueOf()
).toEqual({
$schema: 'http://json-schema.org/draft-07/schema#',
type: 'object',
properties: {
foo: { type: 'string' },
bar: {
type: 'array',
items: { type: 'number', deprecated: true, }
}
},
})
Is the same valid for single property objects? Any ideas on this?
Is the same valid for single property objects?
I think the latter is right and the former is not: items may contain an array and you may want to deprecate just one type.