docs(xsschema): add sury (#144)
* Add Sury to xsschema docs * Fix xsschema docs
This commit is contained in:
1 parent
e12999ebd6
commit
2a8532af27
3 files changed
+32
-3
No files matched your search
@@ -19,12 +19,13 @@ Here is the list of libraries that `toJsonSchema` is compatible with:
|
||||
|
||||
| Implementer | Version(s) | Status |
|
||||
|---|---|---|
|
||||
| Zod | 4.0+ | Supported |
|
||||
| Zod Mini | 4.0+ | Supported |
|
||||
| Zod (with `zod-to-json-schema`) | 3.24+ | Supported |
|
||||
| Zod | v4.0+ | Supported |
|
||||
| Zod Mini | v4.0+ | Supported |
|
||||
| Zod (with `zod-to-json-schema`) | v3.24+ | Supported |
|
||||
| Valibot (with `@valibot/to-json-schema`) | v1.0+ | Supported |
|
||||
| ArkType | v2.1+ | Supported |
|
||||
| Effect Schema | v3.14+ | Supported |
|
||||
| Sury | v10+ | Supported |
|
||||
|
||||
## Usage
|
||||
|
||||
@@ -37,6 +38,7 @@ Here is the list of libraries that `toJsonSchema` is compatible with:
|
||||
```ts twoslash
|
||||
import { type } from 'arktype'
|
||||
import { Schema } from 'effect'
|
||||
import * as S from 'sury'
|
||||
import * as v from 'valibot'
|
||||
import { toJsonSchema } from 'xsschema'
|
||||
import { z } from 'zod'
|
||||
@@ -57,6 +59,13 @@ const effectSchema = Schema.standardSchemaV1( // [!code highlight]
|
||||
|
||||
const effectJsonSchema = await toJsonSchema(effectSchema)
|
||||
|
||||
const surySchema = S.schema({
|
||||
myString: S.string,
|
||||
myUnion: S.union([S.number, S.boolean]),
|
||||
}).with(S.meta, { description: 'My neat object schema' })
|
||||
|
||||
const suryJsonSchema = await toJsonSchema(surySchema)
|
||||
|
||||
const valibotSchema = v.pipe(
|
||||
v.object({
|
||||
myString: v.string(),
|
||||
@@ -88,6 +97,7 @@ You can register multiple schema vendors if you need to.
|
||||
```ts twoslash
|
||||
import { type } from 'arktype'
|
||||
import { Schema } from 'effect'
|
||||
import * as S from 'sury'
|
||||
import * as v from 'valibot'
|
||||
import { initToJsonSchemaSyncVendor, toJsonSchemaSync } from 'xsschema'
|
||||
import { z } from 'zod'
|
||||
@@ -110,6 +120,14 @@ const effectSchema = Schema.standardSchemaV1( // [!code highlight]
|
||||
await initToJsonSchemaSyncVendor('effect') // [!code highlight]
|
||||
const effectJsonSchema = toJsonSchemaSync(effectSchema)
|
||||
|
||||
const surySchema = S.schema({
|
||||
myString: S.string,
|
||||
myUnion: S.union([S.number, S.boolean]),
|
||||
}).with(S.meta, { description: 'My neat object schema' })
|
||||
|
||||
await initToJsonSchemaSyncVendor('sury') // [!code highlight]
|
||||
const suryJsonSchema = toJsonSchemaSync(surySchema)
|
||||
|
||||
const valibotSchema = v.pipe(
|
||||
v.object({
|
||||
myString: v.string(),
|
||||
@@ -135,14 +153,20 @@ const zodJsonSchema = toJsonSchemaSync(zodSchema)
|
||||
```ts twoslash
|
||||
import { validate } from 'xsschema'
|
||||
import { type } from 'arktype'
|
||||
import { Schema } from 'effect'
|
||||
import * as S from 'sury'
|
||||
import * as v from 'valibot'
|
||||
import * as z from 'zod'
|
||||
|
||||
const arktypeSchema = type("string")
|
||||
const effectSchema = Schema.standardSchemaV1(Schema.String)
|
||||
const surySchema = S.string
|
||||
const valibotSchema = v.string()
|
||||
const zodSchema = z.string()
|
||||
|
||||
const arktypeResult = await validate(arktypeSchema, '123')
|
||||
const effectResult = await validate(effectSchema, '123')
|
||||
const suryResult = await validate(surySchema, '123')
|
||||
const valibotResult = await validate(valibotSchema, '123')
|
||||
const zodResult = await validate(zodSchema, '123')
|
||||
```
|
||||
@@ -53,6 +53,7 @@
|
||||
"autoprefixer": "^10.4.21",
|
||||
"effect": "catalog:schema",
|
||||
"postcss": "^8.5.3",
|
||||
"sury": "^10.0.0-rc",
|
||||
"tailwindcss": "^4.1.1",
|
||||
"valibot": "catalog:schema",
|
||||
"xsai": "workspace:^",
|
||||
|
||||
Generated
+4
@@ -205,6 +205,9 @@ importers:
|
||||
postcss:
|
||||
specifier: ^8.5.3
|
||||
version: 8.5.3
|
||||
sury:
|
||||
specifier: ^10.0.0-rc
|
||||
version: 10.0.0-rc.4
|
||||
tailwindcss:
|
||||
specifier: ^4.1.1
|
||||
version: 4.1.1
|
||||
@@ -4658,6 +4661,7 @@ packages:
|
||||
|
||||
rspack-resolver@1.3.0:
|
||||
resolution: {integrity: sha512-az/PLDwa1xijNv4bAFBS8mtqqJC1Y3lVyFag4cuyIUOHq/ft5kSZlHbqYaLZLpsQtPWv4ZGDo5ycySKJzUvU/A==}
|
||||
deprecated: Please migrate to the brand new `@rspack/resolver` or `unrs-resolver` instead
|
||||
|
||||
run-parallel@1.2.0:
|
||||
resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==}
|
||||
|
||||
Reference in new issue
Block a user