Repository navigation
feat: support JSON Schema as input for a Type - #1159
Conversation
ssalbdivad
left a comment
There was a problem hiding this comment.
TBH lost track of a couple comments so submitting them now haha
| ).type.errors.snap( | ||
| `Argument of type '{ type: "object"; propertyNames: { type: "number"; }; }' is not assignable to parameter of type 'JsonSchemaOrBoolean'.` + | ||
| `The types of 'propertyNames.type' are incompatible between these types.` + | ||
| `Type '"number"' is not assignable to type '"string"'.` |
There was a problem hiding this comment.
Just to make these slightly less fragile, I often just extract the snippet that most captures the error like:
.type.errors(
`Type '"number"' is not assignable to type '"string"'.`
)(passing a value directly to .errors or .toString allows regex or partial matches)
There was a problem hiding this comment.
Yeah, it works on other places, just not here for some reason 🤷
…queItems' unit test for failure scenario
813cb25 to
a628be9
Compare
a628be9 to
b31364f
Compare
884224c to
825d78e
Compare
90c9ca5 to
98687a0
Compare
ssalbdivad
left a comment
There was a problem hiding this comment.
Just want https://github.com/arktypeio/arktype/pull/1159/files#r2011203523 fixed and we're good to ship 🙌🙌🙌🙌
Amazing work on this. You know you were thorough when you wanted to handle so many edge cases you ended up adding new type reductions to ArkType in mutliple cases 😊
| ).type.errors.snap( | ||
| `Argument of type '{ type: "object"; propertyNames: { type: "number"; }; }' is not assignable to parameter of type 'JsonSchemaOrBoolean'.` + | ||
| `The types of 'propertyNames.type' are incompatible between these types.` + | ||
| `Type '"number"' is not assignable to type '"string"'.` |
| export type Branch = Constrainable | Const | String | Numeric | Object | Array | ||
| type Composition = Union | OneOf | Intersection | Not | ||
|
|
||
| type NonBooleanBranch = |
There was a problem hiding this comment.
I know, but intuitively I think of it as meaning JsonObject | JsonArray | string | number | null.
…les regexes internally, so don't have to do it here as well)
|
Wow, this is huge -- amazing work you two, thanks so much for getting this landed! |


Closes #729.
What
This PR adds
@ark/jsonschema, which is a library enabling users to convert a valid JSON Schema schema into an ArkType type.API
Below is a basic sample-use of
@ark/jsonschema:Known Limitations (things I didn't implement from JSON Schema spec)
dependencieskeyword on objects.if/else/then.any/oneOf/allOf/not.multipleOfon numbers only supports integer divisors, due to ArkType only supporting integer divisors.