glideapps / glideapps/quicktype

Prevent merging JSON Schema oneOf union

Open
#2,213 0 comments 16 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
13.9k
Forks
1.2k
Avg merge
8h 53m
Merged PRs (30d)
369

Description

I'm trying to use quicktype generate a libs in many languages from a JSON Schema.

My root schema uses a `oneOf` with refs to my sub elements.

The problem is that using quicktype, all the sub elements are merged into one main type with all the fields of the elements.

If there a way to do not merge this kind of union like it's done by `json-schema-to-typescript` in this project: https://github.com/lenra-io/components-lib-javascript/blob/main/lib/component.ts#L11

I've found those issues that looks linked:
- https://github.com/quicktype/quicktype/issues/493
- https://github.com/quicktype/quicktype/issues/1647

This problem does not seems to be easy to solve for all the target languages, but could it be a way to let the target language define if it can handle it or not and merge those union only if not managed ?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.