Skip to content

Json Inference #562

@BarryThePenguin

Description

@BarryThePenguin

Hi, I'm looking for ways to infer a schema from some sample Json documents.

Something like https://app.quicktype.io is able to infer a Json Schema from multiple documents, while also detecting enums and objects with similar keys. But they don't expose any underlying AST, so you're limited to the output formats they provide.

I've played around with @traversable/json and @traversable/json-schema with Json.fold<() => JsonSchema>.
I've also used the resulting JsonSchema and @traversable/valibot with JsonSchema.fold<vx.AnyValibotSchema>.
I'm having a few issues handling JsonSchema.Ref correctly, but it's probably just an issue on my part 😅

Ideally I'd like to go from @traversable/json -> @traversable/schema -> @traversable/valibot rather than using JsonSchema as an in-between step.

Do you have any advice as to how I might do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions