Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Effect 3: add `~standard.jsonSchema` to `Schema.standardSchemaV1`

クローズ
#9,765 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 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:

https://github.com/Effect-TS/effect/blob/57b747f0cf4ddec47f23c08553c9e7011e31f8a4/packages/effect/src/Schema.ts#L202-L205

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:

https://github.com/Effect-TS/effect/blob/57b747f0cf4ddec47f23c08553c9e7011e31f8a4/packages/effect/package.json#L58

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分
マージ済み PR(30日)
848

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Effect-TS/effect のほかの issue

Effect-TS/effect の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。