github Effect-TS/effect effect@3.14.20

latest releases: @effect/platform@0.90.7, effect@3.17.13, @effect/sql-sqlite-node@0.45.2...
4 months ago

Patch Changes

  • #4832 17e2f30 Thanks @gcanti! - JSONSchema: respect annotations on declarations.

    Previously, annotations added with .annotations(...) on Schema.declare(...) were not included in the generated JSON Schema output.

    Before

    import { JSONSchema, Schema } from "effect"
    
    class MyType {}
    
    const schema = Schema.declare<MyType>((x) => x instanceof MyType, {
      jsonSchema: {
        type: "my-type"
      }
    }).annotations({
      title: "My Title",
      description: "My Description"
    })
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "my-type"
    }
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    class MyType {}
    
    const schema = Schema.declare<MyType>((x) => x instanceof MyType, {
      jsonSchema: {
        type: "my-type"
      }
    }).annotations({
      title: "My Title",
      description: "My Description"
    })
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "description": "My Description",
      "title": "My Title",
      "type": "my-type"
    }
    */

Don't miss a new effect release

NewReleases is sending notifications on new releases.