Closed loganripplinger closed 1 month ago
I will look into this bug - thanks for reporting! I didn't know oneOf could be represented this way tbh, haha! I see this is valid, but usually I would do this (I wonder if this also isn't working?)
{
$schema: 'http://json-schema.org/draft-04/schema#',
properties: {
foo: {
oneOf: [
{
type: 'object',
additionalProperties: false,
properties: {
number: {
type: 'integer',
},
},
{
type: 'null'
},
],
},
},
additionalProperties: false,
oneOf: [
{
type: 'null',
},
{
type: 'object',
},
],
}
but your generated schema def is also valid. I will see what I can do, starting with some tests!
this one is going to take some time because it requires rewriting some of our pointer functions to pick up the root #
as a pointer, which ends up breaking a lot of functionality that as it turns out was based on skipping #
accidentally.
@imolorhe what do you think of making the object root a pointer - i think it will solve issues like these ultimately, and thus we can be in compatibility with some major json schema specs that have top level complex types or refs (top level $ref
or top level complex types)
No issues there from me.
Repro steps
I am using schemas generated from protobufs via protoc-gen-jsonschema.
I am using JSON4 not JSON5.
Use this schema to reproduce the problem show below:
I further narrowed it down to this schema (in JS/JSON5 instead of JSON4, though I am still using the JSON4 plugin):
Of note if you remove
properties.oneOf
and instead just usetype: 'object'
it will correctly show the error:Expected Behavior
An error should appear.
Actual Behavior
No error appears.