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
This would be a large feature allowing JSON schemas as an alternative definition format, that would be statically validated and inferred, similarly to the primary TS-based syntax.
Some additional investigation is needed to determine what roadblocks we might hit (I'm not deeply familiar with JSON schema), but it seems to be structurally quite straightforward, so it should lend itself well to a parse-based approach like ArkType.
Reacted by Travis Fischer, Erik Müller, B. Cedric Cogell, EVA (Entity Value Attribute), hyezb, Johannes Zillmann, Isaac Donoghue, Julian Cataldo, Marco Muser, Drew Powers and 2 more
I think this would be super useful for OpenAPI support, which is where OpenAI Plugins are headed.
For context, I'm considering between zod vs arktype for a framework I'm building, and I'm leaning towards zod because a lot more devs are using it today, but I could definitely see myself using arktype in the future – especially if it played nicely with JSON schema / OpenAPIs.
In my case, I'd ideally want arktype to convert from JSON schema and to JSON schema as an intermediate layer focused on TS DX.
Our new TypeNode system could support something like this in a fairly straightforward way by implementing multiple input output formats.
Something most people probably don't know about ArkType is that it includes a full type system that can compare any two types for assignability, which means its internal representation of your types is richer than what can be represented using JSON schema. You'd lose certain optimizations like being able to validate unions based on a set of discriminants, but I agree it would still be incredibly valuable as an I/O format and a standard.
@thelinuxlich Definitely plan to support an output format as well, but haven't actually documented that yet. Would you be willing to create a new issue so we can track compiling to JSON schema?
Would be great if we could integrate somehow so we don't duplicate work in the ecosystem! Let's make sure to investigate this before we start work on this.
Definitely plan to support an output format as well, but haven't actually documented that yet. Would you be willing to create a new issue so we can track compiling to JSON schema?
Since it hasn't been noted here, ArkType to JSON Schema is being tracked in #776 for anyone interested.
Activity
transitive-bullshit commentedon Apr 28, 2023
I think this would be super useful for OpenAPI support, which is where OpenAI Plugins are headed.
For context, I'm considering between
zodvsarktypefor a framework I'm building, and I'm leaning towardszodbecause a lot more devs are using it today, but I could definitely see myself usingarktypein the future – especially if it played nicely with JSON schema / OpenAPIs.In my case, I'd ideally want arktype to convert from JSON schema and to JSON schema as an intermediate layer focused on TS DX.
Thanks for all your great OSS work btw! 🙏
ssalbdivad commentedon Apr 28, 2023
Our new TypeNode system could support something like this in a fairly straightforward way by implementing multiple input output formats.
Something most people probably don't know about ArkType is that it includes a full type system that can compare any two types for assignability, which means its internal representation of your types is richer than what can be represented using JSON schema. You'd lose certain optimizations like being able to validate unions based on a set of discriminants, but I agree it would still be incredibly valuable as an I/O format and a standard.
We'll do our best to prioritize this!
thelinuxlich commentedon May 26, 2023
Actually what I would love is to convert Arktype to JSON-Schema so I can write Arktype contracts that go straight to swagger
ssalbdivad commentedon May 26, 2023
@thelinuxlich Definitely plan to support an output format as well, but haven't actually documented that yet. Would you be willing to create a new issue so we can track compiling to JSON schema?
ssalbdivad commentedon Jul 8, 2023
@ecyrbe mentioned he built a static JSON Schema parser for TypeMatic🔥
Would be great if we could integrate somehow so we don't duplicate work in the ecosystem! Let's make sure to investigate this before we start work on this.
TizzySaurus commentedon May 24, 2024
Since it hasn't been noted here, ArkType to JSON Schema is being tracked in #776 for anyone interested.
TizzySaurus commentedon Aug 8, 2024
Forgot to mention this, but for tracking purposes my work on this is currently blocked by #1033.
docs(json-schema): add a CHANGELOG entry for type inference