Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE]: Option to forcibly combine elements of the same name even if dissimilar #2682

Open
jwarner112 opened this issue Feb 4, 2025 · 0 comments

Comments

@jwarner112
Copy link

Context (Input, Language)

I'm working with JSON payloads for which the schema provided by the spec is massive and kind of vague in a lot of places. So, I wanted to derive my own schema from a large sample of actual payloads and attempted to use QuickType to achieve that.

Input Format: JSON (one file, or multiple tiles)
Output Language: JSON Schema

Description

As described in the context, I have many JSON files and want to derive a common schema that strictly applies to and validates all of them. This means elements may vary widely within themselves, but the goal being that the schema applies because it's based on a massive sample of real data.

Current Behaviour / Output

What I got was a very very wide schema with many, many simpler types with randomized names. Where the source spec defines a Folder type, I'm getting schema types like Folder813 and PurpleFolder and RamshackleFolder, obviously cases where the tool determined "these are named the same thing, but look so wildly different" and did its own naming from there on. It's an understandable decision to make, but I'd love to have a flag that forces it to never do that.

Proposed Behaviour / Output

What I had hope for was that I'd provide the tool with a folder of files (or, alternatively, one massive file with {"data":[(members...)]}, as the many files proved to run suuuuuper slowly) and that it would ultimately produce one grand unified schema where, okay, each element CAN be a wide range of things, but at least it's based entirely on what's been actually observed. I expected a very deep schema of relatively few but complex top-level compound types.

Solution

The help menu suggests there's no controls for how to output schema files, and I'd like to suggest that one be added with a flag along the lines of --[no-]forcibly-combine-types-by-name. Default can be no-, so long as the flag exists for me.

Alternatives

The alternative is my own purpose-build schema parser, or the manual plodding around and use of JSONpath to get a sense of what an element actually looks like in the real world. Doable, but QuickType is so close to being my next-level solution.

@jwarner112 jwarner112 changed the title [FEATURE]: Option to NOT forcibly combine same-name elements [FEATURE]: Option to forcibly combine elements of the same name even if dissimilar Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant