Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
983b9be
Add JSON Schema source spec
colinhacks Aug 7, 2025
77f843e
Add draft-06
colinhacks Aug 7, 2025
c4773ca
Extract targets. Move WithJSONSchemaSource into StandardSchemaV1
colinhacks Aug 8, 2025
63ed7a1
Extract params
colinhacks Aug 8, 2025
e371de3
Extract StandardJSONSchemaSourceV1 namespace
colinhacks Aug 8, 2025
8e12345
Standardize on ~standard
colinhacks Aug 11, 2025
9c1968b
Remove unused generics
colinhacks Aug 11, 2025
790edc6
WIP
colinhacks Oct 17, 2025
a4dc8a0
WIP
colinhacks Oct 20, 2025
9dfe2a5
WIP
colinhacks Oct 20, 2025
db3100a
WIP
colinhacks Oct 20, 2025
bf1d604
WIP
colinhacks Oct 21, 2025
3d7c646
WIP
colinhacks Oct 21, 2025
bcc2bfa
Update examples
colinhacks Oct 22, 2025
3195c84
Remove tool
colinhacks Oct 22, 2025
2a24c27
Updates
colinhacks Nov 4, 2025
d6cef33
Add converter proposal
colinhacks Nov 4, 2025
5395210
Drop converter
colinhacks Nov 18, 2025
d076546
Clarify openapi 3.0 specifier
colinhacks Nov 18, 2025
d7a60b4
Tweak
colinhacks Nov 18, 2025
beb8bbb
Examples
colinhacks Nov 18, 2025
22acddf
Flesh out faq
colinhacks Nov 18, 2025
c8dea44
FAQ
colinhacks Nov 18, 2025
bf67141
WIP
colinhacks Nov 18, 2025
f7a2a1a
Tweak
colinhacks Nov 18, 2025
c082c55
Tweak
colinhacks Nov 18, 2025
3415c88
Condense
colinhacks Nov 18, 2025
ef312ea
Tweak
colinhacks Nov 18, 2025
c395014
Drop rfc
colinhacks Nov 18, 2025
13205ca
Clean up unnecessary changes
colinhacks Nov 18, 2025
0c47ca7
Update packages/spec/src/index.ts
colinhacks Nov 28, 2025
22b9de3
Apply suggestions from code review
colinhacks Nov 28, 2025
b51c326
Add empty export block
colinhacks Nov 28, 2025
a32d8ae
Format
colinhacks Nov 28, 2025
a3fad15
Formatting
colinhacks Nov 28, 2025
4beebb4
Update lock
colinhacks Nov 28, 2025
c203aa2
Update JSON integrate example
fabian-hiller Nov 29, 2025
616deb6
Update JSON implement example
fabian-hiller Nov 29, 2025
8dc9589
Address reviews
colinhacks Dec 1, 2025
47d12e8
Clean up examples
colinhacks Dec 1, 2025
68e12d2
Set up custom conditions, clean up examples
colinhacks Dec 1, 2025
8d256bf
Update website
colinhacks Dec 1, 2025
cf98e66
Update website
colinhacks Dec 1, 2025
25996be
README updates
ssalbdivad Dec 2, 2025
d45f967
Update schema.md
colinhacks Dec 2, 2025
3097314
Updates
colinhacks Dec 2, 2025
deb6c18
Rebase
colinhacks Dec 2, 2025
fddcc15
update umbrella org overview
ssalbdivad Dec 3, 2025
727c24a
update arktype implementation version and pr
ssalbdivad Dec 3, 2025
ea2436d
Update JSON Schema compatibility table with Valibot details
fabian-hiller Dec 12, 2025
f16ef72
Update website
colinhacks Dec 13, 2025
3a1b9ea
Add examples table
colinhacks Dec 15, 2025
b081dbb
Update site
colinhacks Dec 15, 2025
1dbb6d2
Improve docs
colinhacks Dec 15, 2025
1a5ccf3
Improve json-integrate
colinhacks Dec 15, 2025
395ee95
Add json-integrate
colinhacks Dec 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions biome.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"root": true,
"$schema": "https://biomejs.dev/schemas/2.1.3/schema.json",
"root": true,
"assist": { "actions": { "source": { "organizeImports": "on" } } },
"formatter": {
"indentStyle": "space",
Expand Down Expand Up @@ -31,4 +31,4 @@
}
}
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "standard-schema",
"description": "A standard interface for TypeScript schema validation libraries",
"description": "A family of specs for interoperable TypeScript",
"version": "0.0.0",
"license": "MIT",
"author": "Colin McDonnell",
Expand Down
74 changes: 74 additions & 0 deletions packages/examples/json-implement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/**
* This example shows how to implement the Standard JSON Schema interface.
* It demonstrates creating schemas that support both validation and JSON Schema generation.
*/

import type {
StandardJSONSchemaV1,
StandardSchemaV1,
} from "@standard-schema/spec";

interface CombinedProps<Input = unknown, Output = Input>
extends StandardSchemaV1.Props<Input, Output>,
StandardJSONSchemaV1.Props<Input, Output> {}

/**
* An interface that combines StandardJSONSchema and StandardSchema.
* */
interface StandardSchemaWithJSONSchema<Input = unknown, Output = Input> {
"~standard": CombinedProps<Input, Output>;
}

interface MySchema extends StandardSchemaWithJSONSchema<string, string> {
type: "string";
}

export function stringWithJSON(): MySchema {
return {
type: "string",
"~standard": {
version: 1,
vendor: "example-lib",
validate(value) {
return typeof value === "string"
? { value }
: { issues: [{ message: "Invalid string", path: [] }] };
},
jsonSchema: {
input(params) {
const schema: Record<string, unknown> = {
type: "string",
};

// Add schema version based on target
if (params.target === "draft-2020-12") {
schema.$schema = "https://json-schema.org/draft/2020-12/schema";
} else if (params.target === "draft-07") {
schema.$schema = "http://json-schema.org/draft-07/schema#";
} else {
throw new Error(`Unsupported target: ${params.target}`);
}

return schema;
},
Comment thread
fabian-hiller marked this conversation as resolved.
output(params) {
// input and output are the same in this example
return this.input(params);
Comment thread
colinhacks marked this conversation as resolved.
},
},
},
};
}

// usage example
const stringSchema = stringWithJSON();

stringSchema["~standard"].jsonSchema.input({
target: "draft-2020-12",
});
// => { $schema: "https://json-schema.org/draft/2020-12/schema", type: "string" }

stringSchema["~standard"].jsonSchema.input({
target: "draft-07",
});
// => { $schema: "http://json-schema.org/draft-07/schema#", type: "string" }
19 changes: 19 additions & 0 deletions packages/examples/json-integrate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { StandardJSONSchemaV1 } from "@standard-schema/spec";

// Function that accepts any compliant `StandardJSONSchemaV1`
// and converts it to a JSON Schema.
export function acceptSchema(schema: StandardJSONSchemaV1): unknown {
// do stuff, e.g.
return schema["~standard"].jsonSchema.input({
target: "draft-2020-12",
});
}

export function parseData<T extends StandardJSONSchemaV1>(
schema: T,
data: StandardJSONSchemaV1.InferInput<T>, // extract input type
) {
// @ts-expect-error - replace doStuff with your own logic
const result = doStuff(schema, data);
return result as StandardJSONSchemaV1.InferOutput<T>; // extract output type
}
3 changes: 2 additions & 1 deletion packages/examples/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"scripts": {
"lint": "pnpm biome lint .",
"format": "pnpm biome format --write .",
"check": "pnpm biome check ."
"check": "pnpm biome check .",
"build": "tsup"
},
"devDependencies": {
"@standard-schema/spec": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions packages/examples/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"allowImportingTsExtensions": true,
"customConditions": ["standard-schema-spec"],
"declaration": true,
"exactOptionalPropertyTypes": true,
"isolatedDeclarations": true,
Expand Down
382 changes: 122 additions & 260 deletions packages/spec/README.md

Large diffs are not rendered by default.

Loading