-
-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Correct Handling of JSON Schema Annotations in Refinements (#3284)
- Loading branch information
Showing
3 changed files
with
110 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
"@effect/schema": patch | ||
--- | ||
|
||
Fix: Correct Handling of JSON Schema Annotations in Refinements | ||
|
||
Fixes an issue where the JSON schema annotation set by a refinement after a transformation was mistakenly interpreted as an override annotation. This caused the output to be incorrect, as the annotations were not applied as intended. | ||
|
||
Before | ||
|
||
```ts | ||
import { JSONSchema, Schema } from "@effect/schema" | ||
|
||
const schema = Schema.Trim.pipe(Schema.nonEmpty()) | ||
|
||
const jsonSchema = JSONSchema.make(schema) | ||
console.log(JSON.stringify(jsonSchema, null, 2)) | ||
/* | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"minLength": 1 | ||
} | ||
*/ | ||
``` | ||
|
||
Now | ||
|
||
```ts | ||
import { JSONSchema, Schema } from "@effect/schema" | ||
|
||
const schema = Schema.Trim.pipe(Schema.nonEmpty()) | ||
|
||
const jsonSchema = JSONSchema.make(schema) | ||
console.log(JSON.stringify(jsonSchema, null, 2)) | ||
/* | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "string" | ||
} | ||
*/ | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters