Skip to content

effect@3.18.4

Choose a tag to compare

@github-actions github-actions released this 06 Oct 17:45
· 5262 commits to main since this release
bcef21f

Patch Changes

  • #5617 6ae2f5d Thanks @gcanti! - JSONSchema: Fix issue where invalid defaults were included in the output.

    Now they are ignored, similar to invalid examples.

    Before

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.NonEmptyString.annotations({
      default: ""
    })
    
    const jsonSchema = JSONSchema.make(schema)
    
    console.log(JSON.stringify(jsonSchema, null, 2))
    /*
    Output:
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "string",
      "description": "a non empty string",
      "title": "nonEmptyString",
      "default": "",
      "minLength": 1
    }
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.NonEmptyString.annotations({
      default: ""
    })
    
    const jsonSchema = JSONSchema.make(schema)
    
    console.log(JSON.stringify(jsonSchema, null, 2))
    /*
    Output:
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "string",
      "description": "a non empty string",
      "title": "nonEmptyString",
      "minLength": 1
    }
    */