Effect 3: add `~standard.jsonSchema` to `Schema.standardSchemaV1`
维护者通常 1 天内回复
@effect-bot 已经在做这个了。
开始于 2026年10月22日。
评估
这个 Issue 还没有评估数据。
描述
What is the problem this feature would solve?
Effect 4 implements Standard JSON Schema through Schema.toStandardJSONSchemaV1. On Effect 3 ([email protected]), Schema.standardSchemaV1 only implements Standard Schema validation:
import { Schema } from "effect"
const Note = Schema.Struct({ title: Schema.String, pinnedAt: Schema.NumberFromString })
const standard = Schema.standardSchemaV1(Note)["~standard"]
console.log(Object.keys(standard).join(", "))
console.log(standard.jsonSchema)
version, vendor, validate
undefined
Tools that accept Standard JSON Schema can't derive JSON Schema from Effect 3 schemas, even though JSONSchema.make already generates draft-07 and draft 2020-12 on 3.x. The ~standard object is built in standardSchemaV1:
The README says Effect 3 lives on the v3 branch and that Effect 3 issues and pull requests should target it, and that branch still receives fixes. It doesn't say whether new features are accepted there, so if 3.x only takes fixes, feel free to close this.
What is the feature you are proposing to solve the problem?
Add jsonSchema to the ~standard object returned by Schema.standardSchemaV1, mapping draft-07 to jsonSchema7 and draft-2020-12 to jsonSchema2020-12, and throwing for other targets as the spec asks. In userland:
import { JSONSchema, Schema } from "effect"
const targets = { "draft-07": "jsonSchema7", "draft-2020-12": "jsonSchema2020-12" }
const converter = (schema) => ({ target }) => {
if (!Object.hasOwn(targets, target)) {
throw new Error(`Unsupported target: ${target}`)
}
return JSONSchema.make(schema, { target: targets[target] })
}
const standardJSONSchemaV1 = (schema) => {
const standard = Schema.standardSchemaV1(schema)
standard["~standard"].jsonSchema = {
input: converter(Schema.encodedSchema(schema)),
output: converter(Schema.typeSchema(schema)),
}
return standard
}
const Note = Schema.Struct({ title: Schema.String, pinnedAt: Schema.NumberFromString })
const { jsonSchema } = standardJSONSchemaV1(Note)["~standard"]
console.log(JSON.stringify(jsonSchema.input({ target: "draft-2020-12" })))
console.log(JSON.stringify(jsonSchema.output({ target: "draft-07" })))
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","required":["title","pinnedAt"],"properties":{"title":{"type":"string"},"pinnedAt":{"type":"string","description":"a string to be decoded into a number"}},"additionalProperties":false}
{"$schema":"http://json-schema.org/draft-07/schema#","type":"object","required":["title","pinnedAt"],"properties":{"title":{"type":"string"},"pinnedAt":{"type":"number"}},"additionalProperties":false}
The StandardJSONSchemaV1 types arrived in @standard-schema/[email protected], while effect 3.x declares ^1.0.0, so the range would need a bump:
What alternatives have you considered?
- The userland wrapper above, which every project on 3.x would have to copy.
- Upgrading to Effect 4, the long-term path, which isn't always possible right away for an existing 3.x codebase.
- 主要语言
- TypeScript
- 星标
- 16.7k
- 派生
- 808
- 平均合并
- 11 小时 24 分钟
- 30 天内合并 PR
- 848
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Effect-TS/effect 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 35/100
维护者通常 1 天内回复
-
AI providers: tool results cannot carry images because non-string results are JSON.stringify'd可能已有人在做 @nmnmcc 今天认领。 未关闭
难度 5/5 一周以上 新手友好度 35/100
Effect-TS/effect#9857 · 2 条评论 ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
-
`Schema.Literals`: add `omit`, the complement of `pick`可能已有人在做 @effect-bot 今天认领。 未关闭enhancement Needs Evaluation
难度 3/5 1-2 天 新手友好度 35/100
维护者通常 1 天内回复
-
Support the `openapi-3.0` target in `Schema.toStandardJSONSchemaV1`可能已有人在做 @MichaelDeBoey 于 1 天前认领。 未关闭enhancement Needs Evaluation
难度 4/5 3-5 天 新手友好度 48/100
Effect-TS/effect#9764 · 3 条评论 ·
维护者通常 1 天内回复
相似的 Issue
-
level/task type/bug
难度 2/5 1-3 小时 新手友好度 75/100
wazuh/wazuh-dashboard-plugins#9508 ·
维护者通常 1 天内回复
-
Testnet EOL page links Zonescan mainnet可能已有人在做 @napelvs 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 76/100
-
难度 2/5 1-3 小时 新手友好度 78/100
Azure-Samples/azure-search-openai-demo#3249 ·
维护者通常 1 天内回复
-
[Docs] docs/architecture.mermaid leaves out 21 of the 51 src/ directories可能已有人在做 @uyg7x 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 1 天内回复
-
enhancement status:needs-triage
难度 2/5 1-3 小时 新手友好度 68/100
dongdongbh/Mindwtr#1438 ·
维护者通常 1 天内回复