github Effect-TS/effect @effect/platform@0.71.2

Patch Changes

  • #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"
        }
      ]
    }
    */
  • Updated dependencies [2408616, cec0b4d, cec0b4d, 8d978c5, cec0b4d, cec0b4d]:

    • effect@3.11.7

Don't miss a new effect release

NewReleases is sending notifications on new releases.