Remove non-spec boolean required and nullable keys from properties#85
Remove non-spec boolean required and nullable keys from properties#85jphastings wants to merge 3 commits intotylersayshi:mainfrom
Conversation
They aren't *explicitly* excluded in the spec, but there's no indication that they *should* be present, the bsky lexicons don't have them (https://lexicon.garden/lexicon/did:plc:4v4y5r3lwsbtmsxhile2ljac/app.bsky.feed.searchPosts), `required` and `nullable` are called out as being canonically defined elsewhere (https://atproto.com/specs/lexicon#object), and JSON Schema (on which the lexicon spec is based) doesn't include these fields in this way either. I think these were accidentally included because the code can be a lot neater if they're left in!
This commit resolves the issues illustrated by the previous commit. Now the required and nullable values are hoisted to the parent, but are also removed from inside the properties themselves. Has special handling for nested objects, where the `require` property pulls double duty (as prototypey's boolean indicator of the parent, and as the lexicon's array on the child)
c824f37 to
dfa1d06
Compare
|
This is good for review now too @tylersayshi! Let me know if you have any concerns |
this is essentially right. I left them in because the library can stay simpler in that case. It was intentional though. I'm open to changing this position, but I think there'd need to be a reason to remove the fields beyond just that they're non-functional in being there. If anything, I'd lean towards stripping these in the Please push back on any or all of this, but this is where I'm at for now. |
|
Hey Tyler, I definitely believe we should remove the Additionally, as I was trying to make a demonstration of the issue, I realized that I there's no way to specify that an object is required when using prototypey's syntax: I think you intended to make I'm going to keep exploring to see if I can get that working, which I think would be a good addition to this PR, to get |
I noticed that
required: trueandnullable: truewere being left on the JSON lexicon definitions as well as being hoisted to therequired: […], nullable: […]arrays.I did some research, and while they aren't explicitly excluded in the spec, there's no indication that they should be present that I can find.
I'm almost convinced they shouldn't be there, as the bsky lexicons don't have them,, they're both canonically defined as being the arrays prototypey already hoists to (as per the spec), and JSON Schema (on which the lexicon spec is based) doesn't include these fields in this way either.
I think these were accidentally included because the code is a lot neater if they're left in 😅
I've updated the tests to exclude these fields (first commit), and created a function to do the extraction (second commit).
Do let me know if you have any questions!