Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
improve JSON Schema output (#585)
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti authored Nov 28, 2023
1 parent cbc2e3f commit 5b27f03
Show file tree
Hide file tree
Showing 6 changed files with 707 additions and 287 deletions.
12 changes: 12 additions & 0 deletions .changeset/shy-eggs-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@effect/schema": patch
---

improve JSON Schema output:

- rename `dependencies` to `$defs`
- remove `"type"` from const schemas
- use `"oneOf"` for enums and add `"title"`s
- add support for `record(pattern, number)`
- add `"$id"` and `"$comment"` properties
- literals should be converted to `enum` instead of `anyOf`, closes #579
4 changes: 2 additions & 2 deletions docs/modules/JSONSchema.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ Added in v1.0.0

<h2 class="text-delta">Table of contents</h2>

- [JSON Schema](#json-schema)
- [encoding](#encoding)
- [from](#from)
- [to](#to)

---

# JSON Schema
# encoding

## from

Expand Down
3 changes: 3 additions & 0 deletions src/AST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ export const createLiteral = (
*/
export const isLiteral = (ast: AST): ast is Literal => ast._tag === "Literal"

/** @internal */
export const _null = createLiteral(null)

/**
* @category model
* @since 1.0.0
Expand Down
Loading

0 comments on commit 5b27f03

Please sign in to comment.