-
-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JSON Schema: handle refinements where the 'from' part includes a tran… (
- Loading branch information
Showing
7 changed files
with
132 additions
and
5 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,39 @@ | ||
--- | ||
"@effect/platform": patch | ||
"@effect/schema": patch | ||
--- | ||
|
||
JSON Schema: handle refinements where the 'from' part includes a transformation, closes #3662 | ||
|
||
Before | ||
|
||
```ts | ||
import { JSONSchema, Schema } from "@effect/schema" | ||
|
||
const schema = Schema.Date | ||
|
||
console.log(JSON.stringify(JSONSchema.make(schema), null, 2)) | ||
/* | ||
throws | ||
Error: Missing annotation | ||
details: Generating a JSON Schema for this schema requires a "jsonSchema" annotation | ||
schema (Refinement): Date | ||
*/ | ||
``` | ||
|
||
After | ||
|
||
```ts | ||
import { JSONSchema, Schema } from "@effect/schema" | ||
|
||
const schema = Schema.Date | ||
|
||
console.log(JSON.stringify(JSONSchema.make(schema), null, 2)) | ||
/* | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "string", | ||
"description": "a string that will be parsed into a Date" | ||
} | ||
*/ | ||
``` |
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,38 @@ | ||
--- | ||
"@effect/schema": patch | ||
--- | ||
|
||
Add description annotation to the encoded part of DateFromString. | ||
|
||
Before | ||
|
||
```ts | ||
import { JSONSchema, Schema } from "@effect/schema" | ||
|
||
const schema = Schema.DateFromString | ||
|
||
console.log(JSON.stringify(JSONSchema.make(schema), null, 2)) | ||
/* | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "string" | ||
} | ||
*/ | ||
``` | ||
|
||
After | ||
|
||
```ts | ||
import { JSONSchema, Schema } from "@effect/schema" | ||
|
||
const schema = Schema.DateFromString | ||
|
||
console.log(JSON.stringify(JSONSchema.make(schema), null, 2)) | ||
/* | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"type": "string", | ||
"description": "a string that will be parsed into a Date" | ||
} | ||
*/ | ||
``` |
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
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
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