47 Commits

Author SHA1 Message Date
Johannes Kirschbauer
80bc3daf96 lib/jsonschema: remove unused arguments 2025-09-16 17:11:19 +02:00
pinpox
cdd241d8ff Replace funky utf-8 singlequotes with decent ones 2025-08-25 11:56:29 +02:00
Michael Hoang
a71a5880c1 treewide: reformat 2025-08-08 15:28:37 +10:00
Johannes Kirschbauer
1019911b20 feat(jsonschema): filter out $exportedModuleInfo by default 2025-06-04 20:22:54 +02:00
Johannes Kirschbauer
7a7bcf68c6 feat(jsonschema): remove 'default' if 'defaultText' is present
default is likely to contain an error thunk if defaultText is set
including it into $exportedModuleInfo makes it non-serializable
2025-06-04 20:22:32 +02:00
Johannes Kirschbauer
dad55040ba Feat(jsonschema): simplify isRequired, look into default and defaultText 2025-06-04 19:57:39 +02:00
Johannes Kirschbauer
7a0665da6d Feat(jsonschema): convert deferredModule to unknown 2025-05-20 15:48:28 +02:00
Valentin Gagarin
c8b305c437 fixup(jsonschema): test attrsOf submodules with valid value 2025-04-16 16:55:50 +02:00
Valentin Gagarin
af7915a564 lib/jsonschema: render defaults for submodule options
this relaxes the constraint that options of type `submodule` are always
required, and will render benign default values.
2025-04-16 16:55:46 +02:00
Johannes Kirschbauer
15fe06fbf5 feat(jsonschema): add test for attrsof submodule 2025-04-16 14:48:49 +02:00
Valentin Gagarin
06e27c84de lib/jsonschema: make attrs required
Before the change, modules of the form

```nix
{ lib, ... }: {
  foo.bar = lib.mkOption {
    # ...
  };
}
```

or

```nix
{ lib, ... }: {
  foo = lib.mkOption {
    type = lib.types.subModule {
      bar = lib.mkOption {
        # ...
      };
    };
  };
}
```

would not render with `foo` as required, which is not faithful to the
module system's semantics.

This change also tests that fields with defaults are not marked required.
Note that submodule options cannot have their defaults rendered to JSON
schema, and are therefore always marked required.

Architecturally this change is rather unfortunate: So far the checks for
defaults happen in the rendering (using `isDefault`) and not in the parsing,
but here we're adding a field to `$exportedModuleInfo`. While strictly
speaking we probably don't want to consider requiredness as module-level
information, it seems more reasonable to me to do it that way since at
the JSON schema level we have lost the distinction between `attrs`,
`attrsOf`, `submodule`.
2025-04-16 13:20:00 +02:00
Michael Hoang
ce85aebc17 tests: add --show-trace to nix-unit tests 2025-04-08 08:53:29 +02:00
Michael Hoang
c2eaf74df5 lib/jsonschema: fix enum support 2025-04-08 08:53:27 +02:00
lassulus
3ae82f3efc *: nix fmt 2024-12-02 15:14:40 +01:00
Johannes Kirschbauer
a1915fa26b jsonschema: dont export defaultText as default 2024-11-21 15:38:17 +00:00
Johannes Kirschbauer
5c63ce0058 jsonschema: migrate tests 2024-11-12 13:23:31 +01:00
Johannes Kirschbauer
0e2b519731 jsonschema: Add exportfield for module internals 2024-11-12 12:48:45 +01:00
Johannes Kirschbauer
a67f42ee7a Jsonschema: clean up tests 2024-11-08 13:22:58 +01:00
Johannes Kirschbauer
4994b5acb5 Inventory: init inventory.tags for globally defined static and dynamic tags 2024-11-08 12:48:03 +01:00
danjujan
7a1e952c54 lib: fix typos 2024-10-29 12:37:34 +00:00
Johannes Kirschbauer
7a4a4cea95 lib/jsonSchema: handle defaults for defaultText 2024-10-22 12:59:44 +02:00
Johannes Kirschbauer
a8bf83e849 Jsonschema: fix tests 2024-07-18 22:04:11 +02:00
Johannes Kirschbauer
b752d2eb67 Init: Autogenerate classes from nix interfaces 2024-07-18 19:14:12 +02:00
Johannes Kirschbauer
c43c4ef067 Fix schema test 2024-07-14 15:02:32 +02:00
Johannes Kirschbauer
d49a23b890 Inventory: generate exact schema for validation & documentation 2024-07-14 13:30:02 +02:00
Johannes Kirschbauer
77577a9f27 Json-schema: extend interface by header to allow schema spec and arbitrary extensions 2024-07-14 13:29:19 +02:00
Johannes Kirschbauer
c77230e3b6 Json-schema tests: add schema specifier to test 2024-06-24 16:00:46 +02:00
Johannes Kirschbauer
bcb7152c9f schema improvements: add additionalProperties: false to ensure closed types 2024-06-24 15:55:48 +02:00
Johannes Kirschbauer
b222c98a54 Inventory: add concrete use-case examples 2024-06-24 14:35:41 +02:00
DavHau
66f06a484b lib.jsonschema: parse some more types 2024-05-23 16:12:49 +02:00
Qubasa
86ae5d8fac Fix invalid jsonschema testcase 2024-05-04 14:11:28 +02:00
Qubasa
fa51b82cfb jsonschema: Filter out 'invisible' options, that are there to throw errors on define 2024-05-03 19:40:42 +02:00
Qubasa
83f07816a3 Add jsonschema test case 2024-05-03 19:40:42 +02:00
Qubasa
edcc92c75b Add package function-schema and module-schema. Add check for module jsonschema. 2024-05-01 23:16:17 +02:00
Jörg Thalheim
ede4d3f6e5 re-format with nixfmt 2024-03-17 19:48:49 +01:00
Jörg Thalheim
41b5e88808 use nix-unit from nixpkgs 2023-12-15 12:36:07 +01:00
DavHau
f38cc8a209 jsonschema: support mdDoc description 2023-11-21 17:29:22 +07:00
DavHau
96bd6855e9 lib/jsonschema: add more types and excludes
- Complete the types to cover almost everything
- exclude specific types like functionTo or package
2023-11-20 19:40:27 +07:00
DavHau
a656b5e83e lib/jsonschema: support listOf unspecified 2023-11-20 17:03:42 +07:00
Jörg Thalheim
f4d1c098ef jsonschema: fix eval 2023-09-27 13:08:24 +00:00
lassulus
acf1c0b87a lib jsonschema: add path 2023-09-15 12:17:07 +00:00
DavHau
c9bfd0a5b5 clanCore: add example options 2023-09-02 19:15:29 +02:00
DavHau
fb76ad45e8 webui: implement /api/machines/{name}/schema 2023-08-25 21:26:30 +02:00
Jörg Thalheim
4d183fff58 apply prettier to source tree 2023-08-24 14:13:02 +02:00
DavHau
52d6798315 clan-config: stop using jsonschema at all for CLI
- instead use options.json coming from nixosOptionsDoc
2023-08-15 15:48:17 +02:00
DavHau
cd048c2114 lan-config: handle nested options 2023-08-09 18:19:43 +02:00
DavHau
7262208a4c clanLib.jsonschema: move tests from pkgs/clan-cli 2023-08-09 16:05:33 +02:00