github Effect-TS/effect effect@3.11.7

Patch Changes

  • #4137 2408616 Thanks @gcanti! - Arbitrary: fix bug where refinements in declarations raised an incorrect missing annotation error, closes #4136

  • #4138 cec0b4d Thanks @gcanti! - JSONSchema: ignore never members in unions.

    Before

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Union(Schema.String, Schema.Never)
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "$id": "/schemas/never",
          "not": {},
          "title": "never"
        }
      ]
    }
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Union(Schema.String, Schema.Never)
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "string"
    }
    */
  • #4138 cec0b4d Thanks @gcanti! - JSONSchema: handle the nullable keyword for OpenAPI target, closes #4075.

    Before

    import { OpenApiJsonSchema } from "@effect/platform"
    import { Schema } from "effect"
    
    const schema = Schema.NullOr(Schema.String)
    
    console.log(JSON.stringify(OpenApiJsonSchema.make(schema), null, 2))
    /*
    {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "enum": [
            null
          ]
        }
      ]
    }
    */

    After

    import { OpenApiJsonSchema } from "@effect/platform"
    import { Schema } from "effect"
    
    const schema = Schema.NullOr(Schema.String)
    
    console.log(JSON.stringify(OpenApiJsonSchema.make(schema), null, 2))
    /*
    {
      "type": "string",
      "nullable": true
    }
    */
  • #4128 8d978c5 Thanks @gcanti! - JSONSchema: add type for homogeneous enum schemas, closes #4127

    Before

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Literal("a", "b")
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "enum": [
        "a",
        "b"
      ]
    }
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.Literal("a", "b")
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "type": "string",
      "enum": [
        "a",
        "b"
      ]
    }
    */
  • #4138 cec0b4d Thanks @gcanti! - JSONSchema: use { "type": "null" } to represent the null literal

    Before

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.NullOr(Schema.String)
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "enum": [
            null
          ]
        }
      ]
    }
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    const schema = Schema.NullOr(Schema.String)
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ]
    }
    */
  • #4138 cec0b4d Thanks @gcanti! - JSONSchema: handle empty native enums.

    Before

    import { JSONSchema, Schema } from "effect"
    
    enum Empty {}
    
    const schema = Schema.Enums(Empty)
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "$comment": "/schemas/enums",
      "anyOf": [] // <= invalid schema!
    }
    */

    After

    import { JSONSchema, Schema } from "effect"
    
    enum Empty {}
    
    const schema = Schema.Enums(Empty)
    
    console.log(JSON.stringify(JSONSchema.make(schema), null, 2))
    /*
    {
      "$schema": "http://json-schema.org/draft-07/schema#",
      "$id": "/schemas/never",
      "not": {}
    }
    */

Don't miss a new effect release

NewReleases is sending notifications on new releases.