Skip to content

effect@3.10.4

Choose a tag to compare

@github-actions github-actions released this 25 Oct 14:56
· 1512 commits to main since this release
c244666

Patch Changes

  • #3842 2367708 Thanks @gcanti! - add support for Schema.OptionFromUndefinedOr in JSON Schema generation, closes #3839

    Before

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Struct({
      a: Schema.OptionFromUndefinedOr(Schema.Number)
    })
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    throws:
    Error: Missing annotation
    at path: ["a"]
    details: Generating a JSON Schema for this schema requires a "jsonSchema" annotation
    schema (UndefinedKeyword): undefined
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Struct({
      a: Schema.OptionFromUndefinedOr(Schema.Number)
    })
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    Output:
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "object",
      "required": [],
      "properties": {
        "a": {
          "type": "number"
        }
      },
      "additionalProperties": false
    }
    */