How to extract brief JSON representation of a type? #1225
-
eg
Is there a way to extract that from a type as a JS/JSON value, rather than as a flattened string? Both
While useful, it would also be great to a representation of arktype's amazing concise syntax out |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Eventually, I'd like to be able to generate a canonical definition from an arbitrary type. Would also be happy to accept contributions on this feature: That said, this kind of definition would be optimized for visual clarity when printed (like the string), but would not be traversable at all (containing unparsed strings etc.). Being able to recreate a def from an arbitrary node would be useful in some cases to pass back into ArkType, especially for testing, but I'd expect its utility to be fairly limited externally? Alternatively, you could use |
Beta Was this translation helpful? Give feedback.
Eventually, I'd like to be able to generate a canonical definition from an arbitrary type. Would also be happy to accept contributions on this feature:
#818
That said, this kind of definition would be optimized for visual clarity when printed (like the string), but would not be traversable at all (containing unparsed strings etc.). Being able to recreate a def from an arbitrary node would be useful in some cases to pass back into ArkType, especially for testing, but I'd expect its utility to be fairly limited externally?
Alternatively, you could use
toJsonSchema
if you want a familiar representation, although it wouldn't be guaranteed to be less verbose.