Remove TypeBox#136
Conversation
|
Will the result of As long as the result of |
|
@colinhacks Hello, Ref: sinclairzx81/typebox#1384 (comment)
The Compile and StandardSchema functions are both Adapters (by this definition) const C = Compile({ type: 'string' }) // C: Validator<...>
// │ │ │
// │ │ └────────> Json Schema
// │ │
// │ └──────────────────> Adapter
// │
// └──────────────────────> Validator
const S = StandardSchema({ type: 'string' }) // S: StandardSchemaV1<...>
// │ │ │
// │ │ └───> Json Schema
// │ │
// │ └──────────────────> Adapter
// │
// └──────────────────────> StandardSchema One function is more descriptive, doesn't require a "Validator" to be considered a "Schema" and separates concerns related to runtime Result and Issue mapping (as mandated by this specification). Also Effect
For the purposes of system integration, we have the same goals ... no adapters
The problem is that Standard Schema encodes Zod-like design patterns (schema / validator coupling) while presenting this design as the "Standard". This will negatively impact users of alternative software design patterns (including users of the Json Schema specification) which now need adapters to be considered "Standard" with diminished DX. The broader concern is that Standard Schema adoption will lockout alternative software design when that doesn't need to be the case. Should Json Schema see standardization under Ecma International, developers wanting to target the specification will need adapters through Standard Schema to use it (as is the case for TB) Adapters do provide clear explicit transformation (they are fine, fwiw) const A = z.toJSONSchema(z.string()) // Standard Schema > Json Schema
const B = StandardSchema(A) // Json Schema > Standard Schema Standard Json Schema looks like it is trying to turn this server.post('/', { // 2. server compiles json schema
body: { type: 'string' } // 1. caller passes json schema
}, (...) => {...})into this ... server.post('/', {
body: { type: 'string' } // error: "Json Schema" is not "Standard Json Schema"
}, (...) => {...}) // (i.e. use Zod, Valibot, ArkType)What should I make of this? I am open to continued discussion, but my preference is to have TypeBox removed from the "Implementer" list as I do not provide direct support for this specification. I only provide a reference / example adapter to it (which is not published with the library) https://github.com/sinclairzx81/typebox/tree/main/example/standard I will take a look at the spec again next year once Json Schema has been added. |
|
Here's the PR for the upcoming Standard JSON Schema spec: main...json-schema "Standard JSON Schema" is orthogonal to "Standard Schema". To use your parlance, "Standard Schema" is for "validators" and Standard JSON Schema is for "schemas". In scenarios where these are unified in one construct (e.g. Zod schemas), then both specs can be implemented. In your scenario, the intended pattern would be:
Both specs include a standard mechanism for statically tracking inferred types.
Effect's implementation is also against the spirit of the spec. I think it was a poor choice. You are free to provide an adapter for JSON Schema. But I strongly recommend you also implement the spec in the result of compile. I do not understand your rationale here. It kind of sounds like you'd happily implement the spec in
Anyone can support regular JSON Schema schema alongside Standard JSON Schema. Standard JSON Schema provides a representation that unifies runtime type information (JSON Schema) with static type information (inferred types). The value of this is self-evident, I hope. And again, it's trivial for any tool/framework to continue accepting plain untyped JSON Schema objects and to differentiate between plan JSON Schema and Standard JSON Schema by checking for the |
TypeBox dropped support for Standard Schema back in October. Standard Json Schema (#134) may prove more promising, but will review next year.
PR: sinclairzx81/typebox#1384