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
I was trying to convert a json schema to suretype and noticed that the "minimum" and "maximum" properties for numbers are not honored in the generated schema.
Digging deeper it seems that code for this is in place, but typeconv chooses to convert jsc to ct to st, even though a shortcut from jsc to st is available (defined in the st writer). In this process, the minimum and maximum information gets lost. On a sidenote, the ct to st conversion actually generates a json schema based on the ct representation, and converts that to suretype. I confirmed that this intermediate json schema does not contain the minimum and maximum information.
One could argue that this validation information should also be present in the core-types representation, so that the conversion from jsc to ct should not be lossy. However, I did not look down that path and focused on the following:
The logic for finding the best conversion path in format-graph.ts, while considering shortcuts, does not work optimally if a format can be directly connected to the writer.
I was able to solve this problem by postulating that every reader has a trivial shortcut to itself (so in my case, "jsc to jsc"), which can then be connected with the "jsc to st" shortcut on the st writer side.
Note that the above solution only partially worked for me; I have some uuid strings and ajv apparently does not have a .format('uuid'). At least not the version installed when installing typeconv. It also complained when a .pattern("^[A-Z]+") was generated.
exportconstschemaEventSessionEgmActiveV1=suretype({name: "EventSessionEgmActiveV1"},v.object({eventHeader: annotate({title: "Enterprise Event Header Model - V1",description: "A quick test of a model and it's generated interface."},v.object({originatorUUID: annotate({title: "originatorId",description: "Lorem ipsum dolor sit amet."},v.string().pattern("^[A-Z]+").format("uuid").required()),}).additional(true).required()),}).additional(true));
Hi! 👋 Thanks again for typeconv!
I was trying to convert a json schema to suretype and noticed that the "minimum" and "maximum" properties for numbers are not honored in the generated schema.
Digging deeper it seems that code for this is in place, but typeconv chooses to convert jsc to ct to st, even though a shortcut from jsc to st is available (defined in the st writer). In this process, the minimum and maximum information gets lost. On a sidenote, the ct to st conversion actually generates a json schema based on the ct representation, and converts that to suretype. I confirmed that this intermediate json schema does not contain the minimum and maximum information.
One could argue that this validation information should also be present in the core-types representation, so that the conversion from jsc to ct should not be lossy. However, I did not look down that path and focused on the following:
The logic for finding the best conversion path in format-graph.ts, while considering shortcuts, does not work optimally if a format can be directly connected to the writer.
I was able to solve this problem by postulating that every reader has a trivial shortcut to itself (so in my case, "jsc to jsc"), which can then be connected with the "jsc to st" shortcut on the st writer side.
Here is the diff that solved my problem:
This issue body was partially generated by patch-package.
The text was updated successfully, but these errors were encountered: