`Schema.toStandardJSONSchemaV1` output has no `$schema`
I maintainer di solito rispondono entro 1 giorno
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
What is the problem this feature would solve?
Schema.toStandardJSONSchemaV1 returns a schema without a root $schema for both supported targets ([email protected]):
import { Schema } from "effect"
const Point = Schema.Tuple([Schema.String, Schema.Boolean])
const { jsonSchema } = Schema.toStandardJSONSchemaV1(Point)["~standard"]
console.log(JSON.stringify(jsonSchema.input({ target: "draft-2020-12" })))
console.log(JSON.stringify(jsonSchema.input({ target: "draft-07" })))
{"type":"array","prefixItems":[{"type":"string"},{"type":"boolean"}],"maxItems":2,"minItems":2}
{"type":"array","maxItems":2,"minItems":2,"items":[{"type":"string"},{"type":"boolean"}]}
Code that receives one of these schemas later, such as a validator or a document generator that collects schemas from several libraries, can't tell from the schema itself which draft it is. That matters for keywords whose meaning changed between drafts: array-form items is a tuple in draft-07 but invalid in draft 2020-12, where prefixItems replaces it.
The other Standard JSON Schema implementations write $schema for both targets ([email protected], [email protected], [email protected] through toStandardJsonSchema from @valibot/[email protected], [email protected]), here for the same tuple:
arktype draft-2020-12 https://json-schema.org/draft/2020-12/schema
arktype draft-07 http://json-schema.org/draft-07/schema#
sury draft-2020-12 https://json-schema.org/draft/2020-12/schema
sury draft-07 http://json-schema.org/draft-07/schema#
valibot draft-2020-12 https://json-schema.org/draft/2020-12/schema
valibot draft-07 http://json-schema.org/draft-07/schema#
zod draft-2020-12 https://json-schema.org/draft/2020-12/schema
zod draft-07 http://json-schema.org/draft-07/schema#
Effect 3's JSONSchema.make writes it too ([email protected]):
import { JSONSchema, Schema } from "effect"
const Point = Schema.Tuple(Schema.String, Schema.Boolean)
console.log(JSON.stringify(JSONSchema.make(Point, { target: "jsonSchema7" })))
console.log(JSON.stringify(JSONSchema.make(Point, { target: "jsonSchema2020-12" })))
{"$schema":"http://json-schema.org/draft-07/schema#","type":"array","minItems":2,"items":[{"type":"string"},{"type":"boolean"}],"additionalItems":false}
{"$schema":"https://json-schema.org/draft/2020-12/schema","type":"array","minItems":2,"prefixItems":[{"type":"string"},{"type":"boolean"}],"items":false}
It does so in make:
In Effect 4, Schema.toJsonSchemaDocument keeps the draft in Document.dialect, so the information exists. It is lost in the Standard JSON Schema adapter, which returns only document.schema, in toBaseStandardJSONSchemaV1:
What is the feature you are proposing to solve the problem?
Set the root $schema in toBaseStandardJSONSchemaV1, using the URIs effect/JsonSchema already exports as META_SCHEMA_URI_DRAFT_07 and META_SCHEMA_URI_DRAFT_2020_12.
Setting it once on the draft 2020-12 schema may be enough, because JsonSchema.toDocumentDraft07 already rewrites a root draft 2020-12 $schema to the draft-07 URI in convertMetaSchemaKeyword:
import { JsonSchema, Schema } from "effect"
const doc = Schema.toJsonSchemaDocument(Schema.Tuple([Schema.String, Schema.Boolean]))
const withUri = { ...doc, schema: { $schema: JsonSchema.META_SCHEMA_URI_DRAFT_2020_12, ...doc.schema } }
console.log(JSON.stringify(JsonSchema.toDocumentDraft07(withUri).schema))
{"$schema":"http://json-schema.org/draft-07/schema#","type":"array","maxItems":2,"minItems":2,"items":[{"type":"string"},{"type":"boolean"}]}
What alternatives have you considered?
The caller of input / output knows which target it asked for and can add $schema itself. That only helps when the same code later reads the schema; once the schema is passed on, the target is gone.
The Standard JSON Schema spec doesn't require $schema, so this is a request for consistency with Effect 3 and the other implementations rather than a spec violation.
- Lingua principale
- TypeScript
- Stelle
- 16.7k
- Fork
- 808
- Merge medio
- 11h 24m
- PR unite (30g)
- 848
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Effect-TS/effect
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
AI providers: tool results cannot carry images because non-string results are JSON.stringify'dForse già presa @nmnmcc l’ha presa oggi. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
Effect-TS/effect#9857 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
I maintainer di solito rispondono entro 1 giorno
-
`Schema.Literals`: add `omit`, the complement of `pick`Forse già presa @effect-bot l’ha presa 1 giorno fa. Apertaenhancement Needs Evaluation
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
-
Support the `openapi-3.0` target in `Schema.toStandardJSONSchemaV1`Forse già presa @MichaelDeBoey l’ha presa 1 giorno fa. Apertaenhancement Needs Evaluation
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
Effect-TS/effect#9764 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di Effect-TS/effect
Issue simili
-
[Feature]: 建议导入源后,自动切换到新导入的源Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
lyswhut/lx-music-desktop#3026 ·
-
area: ci type: test
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
schlessera/brain-kit#2769 ·
I maintainer di solito rispondono entro 1 giorno
-
Read a vector index's quantization back on Neo4j 2026.10, which reports vector.quantization.typeAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
liberation-data/drivine#231 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
alveusgg/alveusgg#2502 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno