-
-
Notifications
You must be signed in to change notification settings - Fork 59
Closed
Description
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure it has not already been reported
Fastify version
3.6
Node.js version
12
Operating system
Windows
Operating system version (i.e. 20.04, 11.3, 10)
20H2
Description
fluent-json-schema version: 3.0.0
When using .raw({ nullable: true }) with a type object schema, the generated schema is wrong.
Steps to Reproduce
I created the following unit test to reproduce the bug:
import S from 'fluent-json-schema';
describe('parent', () => {
expect(
S.object()
.required(['symbol', 'productType'])
.prop('symbol', S.string())
.prop('productType', S.string())
.raw({ nulllable: true })
.valueOf(),
).toEqual({
$schema: 'http://json-schema.org/draft-07/schema#',
type: 'object',
nullable: true,
required: ['symbol', 'productType'],
properties: {
symbol: {
type: 'string',
},
productType: {
type: 'string',
},
},
});
});
Expected Behavior
Expected output:
{
$schema: 'http://json-schema.org/draft-07/schema#',
type: 'object',
nullable: true,
required: ['symbol', 'productType'],
properties: {
symbol: {
type: 'string',
},
productType: {
type: 'string',
},
},
}
Received:
{
$schema: 'http://json-schema.org/draft-07/schema#',
type: 'object',
required: ['symbol', 'productType'],
properties: {
symbol: {
type: 'string',
},
productType: {
nullable: true, // nullable is being inserted here
type: 'string',
},
},
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels