Patch Changes
-
#3087
d71c192
Thanks @gcanti! - Special caseS.parseJson
to generate JSON Schemas by targeting the "to" side of transformations, closes #3086Resolved an issue where
JSONSchema.make
improperly generated JSON Schemas for schemas defined withS.parseJson(<real schema>)
. Previously, invokingJSONSchema.make
on these transformed schemas produced a JSON Schema corresponding to a string type rather than the underlying real schema.Before
import { JSONSchema, Schema } from "@effect/schema"; // Define a schema that parses a JSON string into a structured object const schema = Schema.parseJson( Schema.Struct({ a: Schema.parseJson(Schema.NumberFromString), // Nested parsing from JSON string to number }), ); console.log(JSONSchema.make(schema)); /* { '$schema': 'http://json-schema.org/draft-07/schema#', '$ref': '#/$defs/JsonString', '$defs': { JsonString: { type: 'string', description: 'a JSON string', title: 'JsonString' } } } */
Now
import { JSONSchema, Schema } from "@effect/schema"; // Define a schema that parses a JSON string into a structured object const schema = Schema.parseJson( Schema.Struct({ a: Schema.parseJson(Schema.NumberFromString), // Nested parsing from JSON string to number }), ); console.log(JSONSchema.make(schema)); /* { '$schema': 'http://json-schema.org/draft-07/schema#', type: 'object', required: [ 'a' ], properties: { a: { type: 'string', description: 'a string', title: 'string' } }, additionalProperties: false } */
-
Updated dependencies [
72638e3
,d7dde2b
,9b2fc3b
]:- effect@3.4.4