genson-js icon indicating copy to clipboard operation
genson-js copied to clipboard

additionalProperties, nullable and minItems introduced

Open tg44 opened this issue 1 year ago • 0 comments

Hy!

This got lot bigger than I expected... And it is not fully consistent, but working.

Merging schemas should go two directions. There is a use-case when I have a lot of things, and I want to find the most suitable schema to them. For this, I want to restrict the merge. So if I have a field in one schema that is nullable, and the same field in on other schema is non-nullable, I want to make the merged field non-nullable. But there is an other use-case, when I want to find out if a schema is a subschema of an another or not. In this case I want to merge permissive, so merging a non-nullable with a nullable schould be nullable. I found out this fundamentally easy thing at the end of my last test-case, and I didn't have time to properly refactor the whole thing, so I committed this as-is bcs it is working already, and covers a LOT more functionality than the prev code, and I think it is a good starting point.

I think the test are describing what works and how. I think in most cases this will be the intended behavior.

I'm open for further discussions and cleanups.

tg44 avatar Apr 16 '23 16:04 tg44