effect
effect copied to clipboard
From Discord: Annotation Issues with Transformation and JSON Schema Generation
Summary
Summary
-
Issue Description:
- The user is experiencing an issue where annotations on a
Transformation
are not being taken into account when generating a JSON schema. - Specifically, when using
Schema.optional
, the root JSON schema does not reflect the expected title and description annotations.
- The user is experiencing an issue where annotations on a
-
Code Example:
- The user provided a TypeScript example where a
Schema.Struct
is annotated with a title and description. - Without
Schema.optional
, the annotations work as expected. - With
Schema.optional
, the produced JSON schema does not include the expected title and description.
- The user provided a TypeScript example where a
-
Expected Behavior:
- The user expects the annotations to be merged with those from
ast.from
with some kind of priority.
- The user expects the annotations to be merged with those from
-
Observation:
- Another user, datner_, confirmed that omitting
.optional
restores the title in the JSON schema.
- Another user, datner_, confirmed that omitting
Key Takeaways
-
Annotation Handling: Annotations on
Transformation
should ideally be taken into account and merged appropriately when generating JSON schemas. -
Impact of
Schema.optional
: The use ofSchema.optional
seems to interfere with the expected behavior of annotations in the JSON schema. -
Expected vs. Actual Output: There is a discrepancy between the expected title and description in the JSON schema and what is actually produced when
Schema.optional
is used.
Next Steps
- Investigate why
Schema.optional
affects the annotations and find a way to ensure annotations are correctly merged and prioritized. - Consider providing a workaround or fix to ensure consistent behavior regardless of the use of
Schema.optional
.
Discord thread
https://discord.com/channels/795981131316985866/1242072450263679128