expose JSON schema for inspection (#351)

intending to document more about how our schemas work, i found our code currently buries this somewhere in `/nix/store`.
this change exposes that generated file in the project structure as well, facilitating inspection of our data schema in this more generic format.

Reviewed-on: Fediversity/Fediversity#351
Reviewed-by: Nicolas Jeannerod <nicolas.jeannerod@moduscreate.com>
Co-authored-by: Kiara Grouwstra <kiara@procolix.eu>
Co-committed-by: Kiara Grouwstra <kiara@procolix.eu>
This commit is contained in:
Kiara Grouwstra 2025-06-04 19:15:26 +02:00 committed by kiara Grouwstra
parent afc7ad2b88
commit 69579fea1c
2 changed files with 31 additions and 24 deletions

2
panel/.gitignore vendored
View file

@ -11,5 +11,5 @@ db.sqlite3
src/db.sqlite3 src/db.sqlite3
src/static src/static
src/panel/static/htmx* src/panel/static/htmx*
src/panel/configuration/schema.py src/panel/configuration/schema.*
.credentials .credentials

View file

@ -14,7 +14,7 @@ let
root = ../src; root = ../src;
fileset = intersection (gitTracked ../../.) ../src; fileset = intersection (gitTracked ../../.) ../src;
}; };
pyproject = with lib; fromTOML pyproject-toml; pyproject = fromTOML pyproject-toml;
# TODO: define this globally # TODO: define this globally
name = "panel"; name = "panel";
# TODO: we may want this in a file so it's easier to read statically # TODO: we may want this in a file so it's easier to read statically
@ -29,17 +29,24 @@ let
include-package-data = true include-package-data = true
''; '';
generated = [ generated =
let
jsonschema = callPackage "${sources.clan-core}/lib/jsonschema" { } { };
frontend-options = jsonschema.parseModule ../../deployment/options.nix;
schema = with builtins; toFile "schema.json" (toJSON frontend-options);
in
[
{ {
from = "${sources.htmx}/dist/htmx.min.js"; from = "${sources.htmx}/dist/htmx.min.js";
to = "./panel/static/htmx.min.js"; to = "./panel/static/htmx.min.js";
} }
{
from = schema;
to = "./panel/configuration/schema.json";
}
{ {
from = from =
let let
jsonschema = callPackage "${sources.clan-core}/lib/jsonschema" { } { };
frontend-options = jsonschema.parseModule ../../deployment/options.nix;
schema = with builtins; toFile "schema.json" (toJSON frontend-options);
codegen = "${python3Packages.datamodel-code-generator}/bin/datamodel-codegen"; codegen = "${python3Packages.datamodel-code-generator}/bin/datamodel-codegen";
pydantic = runCommand "schema.py" { } '' pydantic = runCommand "schema.py" { } ''
# replace plain `pydantic` with `drf_pydantic` so we can create forms automatically # replace plain `pydantic` with `drf_pydantic` so we can create forms automatically