lukeed / tschema

A tiny (500b) utility to build JSON schema types.
MIT License
700 stars 1 forks source link

Schema Compositions #2

Closed lukeed closed 3 months ago

lukeed commented 3 months ago

https://json-schema.org/understanding-json-schema/reference/combining

lukeed commented 3 months ago

The names I'm thinking of now:

Option 1

Use the key names as method names (meh)

t.anyOf()
t.oneOf()
t.allOf()
t.not()

Option 2

Use the actions that the docs use to describe what anyOf, allOf, etc are. (see link above)

t.or() -> anyOf
t.xor() -> oneOf
t.and() -> allOf
t.not() -> not

Option 3

Use custom/mixed naming patterns. AKA, what makes sense to me

t.any() -> anyOf ... but NOT `any` type
t.one() -> oneOf
t.all() -> allOf
t.not() -> not

I lean for Option 2 and Option 3

Thoughts?