You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting Uncaught (in promise) ParseError: Provided JSON Schema must have at least one of the keys 'type', 'enum', 'const', 'allOf', 'anyOf', 'oneOf' and 'not' exception while trying to use $ref.
🔎 Search Terms
$ref, jsonSchemaToType, parseJsonSchema
🧩 Context
ArkType version: 2.1.20
TypeScript version (5.1+): 5.8.3
Other context you think may be relevant (JS flavor, OS, etc.): deno, windows 10
As the person who implemented @ark/json-schema, lack of $ref support was deliberate, in the interest of getting something of value out as soon as possible.
I think the bug here is primarily that it's not listed as a limitation in the README, like dependencies and if/else/then support.
It's an interesting side-effect that this breaks ArkType scopes like the one you provided here. Maybe a nicer error could be provided instead (e.g. "conversion of scopes to json schema is not currently supported") in the interim?
Will leave @ssalbdivad to formally classify this, but fwiw my thoughts are that at its core this is ultimately a feature requests for adding $ref support to @ark/json-schema.
I already have json-schema in a file. I need 1 clarification. Can we use jsonSchemaToType like how we use ajv? I just need validation and get the errors.
Activity
[-]not allowing $ref[/-][+]jsonSchemaToType not allowing $ref[/+][-]jsonSchemaToType not allowing $ref[/-][+]jsonSchemaToType is not allowing $ref[/+]TizzySaurus commentedon Aug 4, 2025
As the person who implemented
@ark/json-schema, lack of$refsupport was deliberate, in the interest of getting something of value out as soon as possible.I think the bug here is primarily that it's not listed as a limitation in the README, like
dependenciesandif/else/thensupport.It's an interesting side-effect that this breaks ArkType scopes like the one you provided here. Maybe a nicer error could be provided instead (e.g. "conversion of scopes to json schema is not currently supported") in the interim?
Will leave @ssalbdivad to formally classify this, but fwiw my thoughts are that at its core this is ultimately a feature requests for adding
$refsupport to@ark/json-schema.SukeshP1995 commentedon Aug 5, 2025
I can understand the lack of support for dependencies or if, else. But why there is no support for $ref? Could you suggest any alternative?
TizzySaurus commentedon Aug 5, 2025
@SukeshP1995 if you're writing the actual JSON Schema yourself, then you can do something like:
sukeshpabolu commentedon Aug 5, 2025
I already have json-schema in a file. I need 1 clarification. Can we use jsonSchemaToType like how we use ajv? I just need validation and get the errors.
TizzySaurus commentedon Aug 5, 2025
@sukeshpabolu Yes,
jsonSchemaToTypecan be used similarly to ajv.Once you have your arktype type (in my example above,
t), you can do either:or:
sukeshpabolu commentedon Aug 5, 2025
This is cool. I just need a way to handle those refs. I may have to use something like this
docs: cite fixed issues and record two missed changes in the package …
ssalbdivad commentedon Nov 18, 2026
Fixed in 3.0.0-beta.0 (#1728). Try it with
npm i arktype@next.