Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Schema: JSONSchema should support make(Class) (#2579)
- Loading branch information
Showing
3 changed files
with
58 additions
and
1 deletion.
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,33 @@ | ||
--- | ||
"@effect/schema": patch | ||
--- | ||
|
||
Schema: JSONSchema should support make(Class) | ||
|
||
Before | ||
|
||
```ts | ||
import { JSONSchema, Schema } from "@effect/schema" | ||
|
||
class A extends Schema.Class<A>("A")({ | ||
a: Schema.String | ||
}) {} | ||
|
||
console.log(JSONSchema.make(A)) // throws MissingAnnotation: cannot build a JSON Schema for a declaration without a JSON Schema annotation | ||
``` | ||
|
||
Now | ||
|
||
```ts | ||
console.log(JSONSchema.make(A)) | ||
/* | ||
Output: | ||
{ | ||
'$schema': 'http://json-schema.org/draft-07/schema#', | ||
type: 'object', | ||
required: [ 'a' ], | ||
properties: { a: { type: 'string', description: 'a string', title: 'string' } }, | ||
additionalProperties: false | ||
} | ||
*/ | ||
``` |
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