Move the func.yaml schema generator off the archived alecthomas/jsonschema

Abierto
#4,190 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 2 días

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
42/100
Tipo de issue
Refactorización
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
go, json, yaml
Área
tooling

Línea de trabajo

Start in schema/generator/main.go, where the reflector is built from github.com/alecthomas/jsonschema, and in pkg/functions/function_options.go, where the jsonschema and jsonschema_extras tags and the scale minimum workaround live. Swap the import to github.com/invopop/jsonschema, regenerate schema/func_yaml-schema.json, and diff it. Done when the schema is regenerated, make check-schema passes, and the draft-04 output decision is recorded.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

schema/generator builds schema/func_yaml-schema.json with github.com/alecthomas/jsonschema, which was archived in 2022 ("Maintenance has moved to https://github.com/invopop/jsonschema"). Its limits now show up as workarounds in our own code:

  • minimum is an int parsed with strconv.Atoi, so a fractional minimum such as scale.kpa.target's 0.01 silently becomes 0. #4067 patches that one field after reflection.
  • A zero minimum is omitted, which is why the scale fields declare minimum through jsonschema_extras (see the comment above the scale tags in pkg/functions/function_options.go).
  • Tag descriptions can't contain commas (another comment in function_options.go).

The maintained successor, github.com/invopop/jsonschema (v0.14.0), keeps the same shape: Reflector, AddGoComments, and the jsonschema / jsonschema_extras tags. It represents minimum/maximum as numbers, so fractional and zero bounds work from the tag directly. The generator is the only Go code that imports the library, so the change is contained.

Possible path:

  1. Swap the import in schema/generator/main.go, regenerate, and diff the schema.
  2. Move minimum back into the jsonschema tag where jsonschema_extras only worked around zero being dropped. Remove the generator patch from #4067.
  3. Decide on the draft version. invopop emits 2020-12 with $defs, where we publish draft-04 with definitions. Either keep draft-04 output, or confirm the YAML language server and editors that consume the schema handle 2020-12 before switching. exclusiveMinimum also changes from a boolean to a number between those drafts.
  4. make check-schema keeps the committed schema in step.

Not urgent: the published schema is only looser than the runtime validation in a few edge cases, and the deploy still rejects invalid values with a clear error.

Lenguaje dominante
Go
Estrellas
366
Forks
231
Merge medio
2 d 23 h
PR fusionados (30 d)
50

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de knative/func

Todos los issues de knative/func

Issues similares

Más issues de Go

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.