github Effect-TS/effect @effect/schema@0.68.16

latest releases: @effect/typeclass@0.29.14, @effect/vitest@0.13.14, @effect/sql-sqlite-wasm@0.20.5...
4 months ago

Patch Changes

  • #3143 d006cec Thanks @gcanti! - Enhance JSON Schema Support for Refinements in Record Parameters.

    Enhanced JSONSchema.make to properly support refinements as record parameters. Previously, using refinements with Schema.Record resulted in errors when generating JSON schemas.

    Before

    import { JSONSchema, Schema } from "@effect/schema";
    
    const schema = Schema.Record(
      Schema.String.pipe(Schema.minLength(1)),
      Schema.Number,
    );
    
    console.log(JSONSchema.make(schema));
    /*
    throws
    Error: Unsupported index signature parameter
    schema (Refinement): a string at least 1 character(s) long
    */

    Now

    import { JSONSchema, Schema } from "@effect/schema";
    
    const schema = Schema.Record(
      Schema.String.pipe(Schema.minLength(1)),
      Schema.Number,
    );
    
    console.log(JSONSchema.make(schema));
    /*
    Output:
    {
      '$schema': 'http://json-schema.org/draft-07/schema#',
      type: 'object',
      required: [],
      properties: {},
      patternProperties: { '': { type: 'number' } },
      propertyNames: {
        type: 'string',
        description: 'a string at least 1 character(s) long',
        minLength: 1
      }
    }
    */
  • #3149 cb22726 Thanks @tim-smart! - add Serializable.WithResult.Success/Error inference helpers

  • #3139 e911cfd Thanks @gcanti! - Optimize JSON Schema output for homogeneous tuples (such as non empty arrays).

    This change corrects the JSON Schema generation for S.NonEmptyArray to eliminate redundant schema definitions. Previously, the element schema was unnecessarily duplicated under both items and additionalItems.

Don't miss a new effect release

NewReleases is sending notifications on new releases.