Effect-TS / effect

An ecosystem of tools to build robust applications in TypeScript

Home Page:https://effect.website

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

From Discord: Annotation Issues with Transformation and JSON Schema Generation

effect-bot opened this issue · comments

Summary

Summary

  1. 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.
  2. 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.
  3. Expected Behavior:

    • The user expects the annotations to be merged with those from ast.from with some kind of priority.
  4. Observation:

    • Another user, datner_, confirmed that omitting .optional restores the title in the JSON schema.

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 of Schema.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