Support `format: "password"` as `Redacted` in JSON Schema import/export and the OpenAPI generator
Los mantenedores suelen responder en 1 día
Evaluación
Este issue todavía no se ha evaluado.
Descripción
Need
Password fields in OpenAPI specs and JSON Schema documents come out as plain string, both from @effect/openapi-generator and from SchemaRepresentation.fromJsonSchemaDocument. That means credentials, API keys and tokens can show up in logs, error messages and traces, and generated schemas have no way to mark them as secrets.
Wrapping them by hand is hard to get right. The httpclient format sends payloads with bodyJsonUnsafe and never encodes them, so if you swap a field to Schema.Redacted, the request carries the literal string "<redacted>". Today the only workaround is a hand-written wrapper module around each affected operation.
Spec
OpenAPI defines password as one of the formats built into the OAS (alongside int32, int64, float and double). It applies to string:
- OAS 3.1.1, §4.4.1 Data Type Format: "A hint to obscure the value."
- OAS 3.0.3, §4.4 Data Types: "A hint to UIs to obscure input."
- OpenAPI Format Registry,
password: "a string that hints to obscure the value."
JSON Schema's own format list doesn't include password. There, format is an annotation, so the value carries over unchanged from OpenAPI specs to the JSON Schema documents produced from them.
Proposal
The mapping is format: "password" ↔ Redacted, in both directions:
- JSON Schema import (
fromJsonSchemaDocument): astringwithformat: "password"becomesSchema.RedactedFromValue(Schema.String). Decoding a JSON value gives aRedacted, encoding gives back the plain string, and checks such asminLengthstill apply to the inner string. Strings used as record keys orpropertyNamesstay plain. - Code generation (
toCodeDocument): printSchema.Redacted(Schema.String)with typeRedacted.Redacted<string>. Generated schemas keep Type and Encoded equal and go throughtoCodecJsonfor JSON, as HttpApi and generated response decoding already do. - JSON Schema export (
toJsonSchemaDocument): strings wrapped bySchema.RedactedorSchema.RedactedFromValueemitformat: "password", unless the inner schema already sets aformat. An HttpApi server's OpenAPI spec would then regenerate into a client with the sameRedactedfields. @effect/openapi-generator:httpapi: works as soon as the schemas useSchema.Redacted.httpclient: operations whose params or payload contain a password field encode them throughSchema.toCodecJsonbefore sending. Every other operation's output stays the same. Multipart bodies can't go through the JSON codec because of their files, so they unwrap their top-levelRedactedfields instead.httpclient-type-only: keeps plainstring, since nothing decodes there.
Open questions
- Default or opt-in? Turning it on by default changes the generated types of existing password fields from
stringtoRedacted<string>. That is a breaking change for those users, so it probably needs a minor release. An option would avoid that, but most users would never find out it exists. - Open objects. A
StructWithRestindex signature also applies to declared keys, so an open object'sRecord(String, Json)rest rejects theRedactedvalue when encoding. One fix is to import open objects that contain a password field as a plainStruct: extra properties are still accepted on decode but stripped instead of kept. Is that acceptable, or should the rest exclude declared keys?
I have a working prototype of all of the above, with tests. I'm happy to open a PR once we agree on the direction.
- Lenguaje dominante
- TypeScript
- Estrellas
- 16.7k
- Forks
- 808
- Merge medio
- 12 h 17 min
- PR fusionados (30 d)
- 805
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Effect-TS/effect
-
From Discord: Return Stream.empty for HTTP requests with an empty bodyPosiblemente ocupada @pujitha24 la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 30/100
Los mantenedores suelen responder en 1 día
-
sql-pg: scoped connection shutdown retains a socket when the peer withholds FINPosiblemente ocupada @effect-bot la tomó hoy. Abierto
Effect-TS/effect#10458 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Schema: a public way to derive a canonical codec, as `toCodecJson` and `toCodecStringTree` doPosiblemente ocupada @effect-bot la tomó hoy. AbiertoNeeds Proposal schema
Effect-TS/effect#10457 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
McpServer.layerHttp: optional legacy GET SSE for idle list-change notificationsPosiblemente ocupada @effect-bot la tomó hace 1 día. Abierto
Effect-TS/effect#10436 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
SqlClient: a fiber forked inside a transaction keeps using its connection after the transaction endsPosiblemente ocupada @effect-bot la tomó hace 1 día. Abiertobug
Effect-TS/effect#10431 · 1 asignado ·
Los mantenedores suelen responder en 1 día
Todos los issues de Effect-TS/effect
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/vscode-containers#655 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
dsh-tauri-desk/deepseek-harness-desktop#1477 · 1 comentario ·
-
[docs] RELEASE.md: wrong branch name, no check that the prepare PR merged with the right subject, manual publish stepPosiblemente ocupada @albertteoh la tomó hoy. Abiertodocumentation
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
jaegertracing/jaeger-ui#4739 ·
Los mantenedores suelen responder en 1 día
-
Add: Shop On TV SDAbiertocheck:passed streams:add
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
Los mantenedores suelen responder en 1 día