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
It would be useful to turn on enum inference for certain fields in types, like "index" fields, since they may become numerous but are often short and unique. At the moment if there are too many unique values then at some point it will not generate enums, which is not desired in my case of using indexes.
I have a large JSON array of many objects, all of them following this format:
{
"index": "foo",
...
}
There are a lot of elements in this array (100s), but it would be very useful to force an enum to be created for the index field specifically, since all relevant queries and code against the data will use index as the identifier.
Current Behaviour / Output
Right now it seems to cut off at some point where if there are too many items then index is just assumed to be a generic string, but I'd like to force an enum for index fields specifically.
Proposed Behaviour / Output
An output would be generated with certain specified fields guaranteed to be a zod (or other language equivalent) enum.
Solution
I'm generating these types through the TypeScript NPM library, so maybe an additional option like "forceEnumOnFields" like so:
constqt=awaitquicktype({
inputData,lang: "typescript",// if this is false, then only generate fields on enums specified by the below array// if this is true, do the normal behavior but also guarantee enums on the fields in the below arrayinferEnums: false,// existing optionforceEnumOnFields: [// proposed additional option"index",],});
Alternatives
A flag to also tweak the ceiling of amount of unique items before Quicktype stops trying to infer enums would be useful as well (this might be related to #757), but would not solve this particular issue very well and would lead to too much data becoming an enum.
Context
N/A
The text was updated successfully, but these errors were encountered:
It would be useful to turn on enum inference for certain fields in types, like "index" fields, since they may become numerous but are often short and unique. At the moment if there are too many unique values then at some point it will not generate enums, which is not desired in my case of using indexes.
Context (Input, Language)
Input Format: JSON
Output Language: Any, but mainly Typescript (with Zod)
Description
I have a large JSON array of many objects, all of them following this format:
There are a lot of elements in this array (100s), but it would be very useful to force an enum to be created for the index field specifically, since all relevant queries and code against the data will use index as the identifier.
Current Behaviour / Output
Right now it seems to cut off at some point where if there are too many items then index is just assumed to be a generic string, but I'd like to force an enum for index fields specifically.
Proposed Behaviour / Output
An output would be generated with certain specified fields guaranteed to be a zod (or other language equivalent) enum.
Solution
I'm generating these types through the TypeScript NPM library, so maybe an additional option like "forceEnumOnFields" like so:
Alternatives
A flag to also tweak the ceiling of amount of unique items before Quicktype stops trying to infer enums would be useful as well (this might be related to #757), but would not solve this particular issue very well and would lead to too much data becoming an enum.
Context
N/A
The text was updated successfully, but these errors were encountered: