json-model-compiler 2.0.64__tar.gz → 2.0.65__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/BACKLOG.md +0 -1
- {json_model_compiler-2.0.64/json_model_compiler.egg-info → json_model_compiler-2.0.65}/PKG-INFO +1 -1
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/SPEC.md +119 -83
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/VERSION.md +13 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/about.sh +1 -1
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/analyze.py +4 -0
- json_model_compiler-2.0.65/json_model/data/VERSION +1 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/model.py +31 -12
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65/json_model_compiler.egg-info}/PKG-INFO +1 -1
- json_model_compiler-2.0.64/json_model/data/VERSION +0 -1
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/.github/workflows/docs.yml +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/.github/workflows/sanity.yml +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/.gitignore +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/.gitmodules +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/API.md +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/BENCH.md +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/COMP.md +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/DESIGN.md +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/DEV.md +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/DOC.md +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/HOWTO.md +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/INTEGRATION.md +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/MANIFEST.in +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/Makefile +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/PUBS.md +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/README.md +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/TUTO.md +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/bench.sh +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/README.md +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/__init__.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/clang.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/convert.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/clang_entry.c +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/clang_free.c +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/clang_init.c +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/clang_pcre2_fun.c +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/clang_re2_fun.c +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/java_free.java +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/java_init.java +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/javascript_exe.js +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/javascript_foot.js +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/javascript_free.js +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/javascript_head.js +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/javascript_init.js +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/javascript_main.js +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/jmc.pod +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/perl_entry.pl +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/perl_exe.pl +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/perl_free.pl +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/perl_init.pl +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/perl_main.pl +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/perl_pkg.pl +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/plpgsql_entry.sql +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/python_entry.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/python_exe.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/python_free.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/python_init.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/python_main.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/export.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/irep.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/iroptim.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/java.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/javascript.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/language.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/mtypes.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/objops.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/optim.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/perl.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/plpgsql.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/predefs.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/python.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/recurse.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/regex.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/resolver.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/Makefile +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/__init__.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/c/Makefile +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/c/json-model.c +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/c/json-model.h +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/c/main.c +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/java/.gitignore +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/java/Makefile +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/java/README.md +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/java/env.sh +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/java/json_model/Checker.java +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/java/json_model/GSON.java +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/java/json_model/JSON.java +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/java/json_model/JSONP.java +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/java/json_model/Jackson.java +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/java/json_model/Main.java +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/java/json_model/ModelChecker.java +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/java/json_model/Path.java +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/java/json_model/Report.java +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/java/json_model/Runtime.java +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/java/pom.xml +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/js/README.md +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/js/index.js +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/js/main.js +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/js/package.json +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/.gitignore +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/Changes +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/LICENSE +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/MANIFEST +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/Makefile.PL +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/README +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/env.sh +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/ignore.txt +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/lib/JSON/JsonModel.pm +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/t/00-load.t +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/t/manifest.t +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/t/pod-coverage.t +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/t/pod.t +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/xt/boilerplate.t +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/sql/META.json +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/sql/Makefile +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/sql/json_model--2.0.sql +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/sql/json_model.control +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/support.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/types.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/script.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/submodel.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/ts_export.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/url_cache.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/utils.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/xstatic.py +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model_compiler.egg-info/SOURCES.txt +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model_compiler.egg-info/dependency_links.txt +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model_compiler.egg-info/entry_points.txt +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model_compiler.egg-info/not-zip-safe +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model_compiler.egg-info/requires.txt +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model_compiler.egg-info/top_level.txt +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/package.json +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/pyproject.toml +0 -0
- {json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/setup.cfg +0 -0
|
@@ -146,7 +146,7 @@ for all possible values for that type.
|
|
|
146
146
|
- `"$IP6"`: an ipv6, eg _0::0_
|
|
147
147
|
- `"$ETH"`: an ethernet (mac) address, eg _De:ad:Be:ef:01:23_
|
|
148
148
|
- `"$CARD"`: a credit card number with a Luhn checksum, eg _1234567890123452_
|
|
149
|
-
- `"$JSONPT"`: an RFC6901 json pointer, eg _/http
|
|
149
|
+
- `"$JSONPT"`: an RFC6901 json pointer, eg _/http:\~1\~1json-model.org_
|
|
150
150
|
- `"$TIMETZ"`: time with timezone
|
|
151
151
|
- `"$SEMVER"`: semantic versioning 2.0
|
|
152
152
|
|
|
@@ -458,111 +458,147 @@ A reference is a string which begins with the `$` character.
|
|
|
458
458
|
|
|
459
459
|
Implementation should detect external reference cycles which are errors and should be rejected.
|
|
460
460
|
|
|
461
|
-
## (EXPERIMENTAL) Model Transformations
|
|
461
|
+
## (EXPERIMENTAL) Type Edition (aka Model Transformations)
|
|
462
462
|
|
|
463
|
-
|
|
463
|
+
Type edition allows to transform models by editing nodes inside a model.
|
|
464
|
+
It comes in two forms:
|
|
465
|
+
|
|
466
|
+
1. Global Type Edition with special keyword `%` at the root of the model.
|
|
467
|
+
2. Local Type Edition within `$`-definitions.
|
|
468
|
+
|
|
469
|
+
The are executed when the model is loaded, as an initial syntactic step,
|
|
470
|
+
before any interpretation of the model beside considering its definitions `$`
|
|
471
|
+
and editions `%`.
|
|
472
|
+
|
|
473
|
+
### Global Type Editions
|
|
474
|
+
|
|
475
|
+
Symbol `%` at the root of the model defines a global type edition object, which
|
|
464
476
|
may include symbol renamings, model importations and model editions.
|
|
477
|
+
Inside the type edition objects, `#...` properties are comments to be ignored.
|
|
478
|
+
Other allowed properties are imports (`<`) and references (`$...`).
|
|
479
|
+
Any other property is an error.
|
|
465
480
|
|
|
466
|
-
- **
|
|
481
|
+
- **Importation**
|
|
467
482
|
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
483
|
+
Special property `<` inside a edition object expects a reference to an external model,
|
|
484
|
+
or a list of such references, and imports all **definitions** of the targets into the
|
|
485
|
+
local scope, as local **definitions**.
|
|
471
486
|
|
|
472
|
-
|
|
473
|
-
{
|
|
474
|
-
"%": { ".com": "#", ".or": "|", ".merge": "+" }
|
|
475
|
-
}
|
|
476
|
-
```
|
|
487
|
+
While importing, homonymous definitions are invalid and must be rejected.
|
|
477
488
|
|
|
478
|
-
|
|
489
|
+
- **Model Removal, Addition and Edition**
|
|
479
490
|
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
491
|
+
Model editions are specified with properties which are references (`$...`) possibly followed
|
|
492
|
+
by a JSON path, allowing to point to a JSON element in the model, and either a value
|
|
493
|
+
with special properties `/ *` to remove or add sub elements, `:` to rename properties.
|
|
494
|
+
Anything else taken as-is, but which must not be an object with any of the special properties.
|
|
483
495
|
|
|
484
|
-
|
|
496
|
+
- If the reference ends with `#`, it designates the model _definitions_ on which the
|
|
497
|
+
editions are performed. The reference object must be a root model, eg imported with
|
|
498
|
+
a URL (`{ "model": "$https://json-model/models/json-model" }`). `$#` is a reference
|
|
499
|
+
to a model's own definitions. A reference may designate an indirectly imported model,
|
|
500
|
+
eg `$openapi#schema#` where `schema` is a definition inside `openapi`.
|
|
501
|
+
If the referenced object does not exist, this is an error.
|
|
485
502
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
```
|
|
503
|
+
The target value may contains any of `/ * ~` properties, this is a type edition object,
|
|
504
|
+
which is interpreted as follow, in this order, when they exist:
|
|
489
505
|
|
|
490
|
-
|
|
491
|
-
|
|
506
|
+
`/` must be a string or list of strings, the corresponding definitions must exist and
|
|
507
|
+
are removed.
|
|
492
508
|
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
This feature allow the localization of the model syntax.
|
|
509
|
+
`*` is a object containing new definitions to be added to the name space. If
|
|
510
|
+
the name already exists, this is an error.
|
|
496
511
|
|
|
497
|
-
-
|
|
512
|
+
`~` is a string-to-string map to rename definitions, which the source must exist
|
|
513
|
+
and the target must not.
|
|
514
|
+
The renaming occurs simultaneously, i.e. `{"a": "b", "b": "a"}` inverts `a`
|
|
515
|
+
and `b` values and is allowed.
|
|
498
516
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
local scope.
|
|
517
|
+
The target object may also include comments (`# ...` properties) which are ignored.
|
|
518
|
+
It cannot include anything else.
|
|
502
519
|
|
|
503
|
-
|
|
520
|
+
- If the reference does **not** end with a `#`, this is interpreted as a `$` reference
|
|
521
|
+
possibly followed by a simple `.`-separated JSON Path: `$Foo.?bla` is definition `Foo`
|
|
522
|
+
and within this definition property `?bla`. As expected, `$.foo` refer to property
|
|
523
|
+
`foo` at the root of the model itself.
|
|
504
524
|
|
|
505
|
-
-
|
|
525
|
+
- If the reference is a name without a path, it designates a definition.
|
|
506
526
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
527
|
+
If the definition does not exist, it is created and the value is associated
|
|
528
|
+
to the definition, which may be a model **or** a local type edition.
|
|
529
|
+
|
|
530
|
+
- If the definition exists, or if the reference is a name with an existing path:
|
|
531
|
+
|
|
532
|
+
- If the target value is an object which contains any of contains `/ * ~` properties
|
|
533
|
+
and possibly some comments, this is an edition, interpreted as follow:
|
|
534
|
+
|
|
535
|
+
`/` is a scalar or list of stuff and the referenced model is an array,
|
|
536
|
+
the values are removed from the array; if it is an object, the scalar or stuffs
|
|
537
|
+
must be strings, and the corresponding properties are removed. Other cases are errors.
|
|
511
538
|
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
mandatory properties to optional, or upgrade optional properties to mandatory.
|
|
536
|
-
- if the target is a JSON array (not necessarily a model for an array):
|
|
537
|
-
- `/`: may be value or a list of values.
|
|
538
|
-
Array items equal to these values are removed.
|
|
539
|
-
If a value is not found, this is an error and must be rejected.
|
|
540
|
-
- `*`: if the value is an array, append its items to the target array.
|
|
541
|
-
If the value is something else, appends to the array.
|
|
542
|
-
- `~`: currently invalid
|
|
543
|
-
- if the target is a JSON scalar: this is an error and must be rejected.
|
|
544
|
-
- if the transformation value is a model (i.e. an object without any `/ *` property),
|
|
545
|
-
the target value is _replaced_ by this value, in place.
|
|
546
|
-
|
|
547
|
-
Moreover, operations can also apply on model definitions when the path ends with `#` and
|
|
548
|
-
must designate a _head_ model, not a submodel:
|
|
549
|
-
|
|
550
|
-
- `/`: remove one (scalar) or several (array) definitions
|
|
551
|
-
- `*`: add or override definitions
|
|
552
|
-
- `~`: Rename, and possibly override, existing definitions
|
|
553
|
-
|
|
554
|
-
These additions and editions are performed _after_ property renamings and imports,
|
|
555
|
-
and _before_ merge pre-processing.
|
|
556
|
-
|
|
557
|
-
Symbols `<`, `/`, `*`, `~` inside a _definition_ define a local transformation.
|
|
558
|
-
|
|
559
|
-
- `<` must be a local reference `$name`, the target model is **copied** inside the definition.
|
|
539
|
+
`*` interpretation is also type dependent:
|
|
540
|
+
If a scalar and the target a list, the item must exist and is removed;
|
|
541
|
+
If a list of stuff and the target a list, the items must exist and are removed;
|
|
542
|
+
If a list of strings and the target is an objects, keep only those properties;
|
|
543
|
+
If an object and the target an object, both objects are merged,
|
|
544
|
+
with property collisions considered as errors.
|
|
545
|
+
All other cases are errors.
|
|
546
|
+
|
|
547
|
+
`~` is a string-to-string map, the target must be an object, the sources
|
|
548
|
+
must exist as properties and are renamed to the target, which must not exist.
|
|
549
|
+
The renaming occurs simultaneously, i.e. `{"a": "b", "b": "a"}` inverts `a`
|
|
550
|
+
and `b` value and is allowed.
|
|
551
|
+
|
|
552
|
+
- Otherwise the target is assumed to be a model and replaces initial definition
|
|
553
|
+
or value at the path.
|
|
554
|
+
|
|
555
|
+
- If the reference is a name with a non existing path, this is an error.
|
|
556
|
+
|
|
557
|
+
### Local Type Editions
|
|
558
|
+
|
|
559
|
+
Symbols `<`, `/`, `*`, `~` inside a _definition_ constitute a local type edition.
|
|
560
|
+
|
|
561
|
+
- `<` must be a simple local reference `$name`, the target model is **copied** inside the definition.
|
|
560
562
|
- `/`, `*` and `~` define local editions inside the definition, as describe above.
|
|
561
563
|
|
|
562
564
|
What is the _right_ balance between features, syntax and ease-of-use for a type transformation
|
|
563
565
|
language is an on-going investigation: should it allow renaming, moving or copying attributes?
|
|
564
566
|
Should it allow to remove definitions? Should imports allow to define a namespace?
|
|
565
567
|
|
|
568
|
+
Local editions are executed _after_ global editions, which may add new definitions with
|
|
569
|
+
such local editions.
|
|
570
|
+
|
|
571
|
+
## (EXPERIMENTAL) Symbol Names
|
|
572
|
+
|
|
573
|
+
Within the `%` object at the root, properties beginning with a `.` introduce new symbol names.
|
|
574
|
+
The value is the symbol string which is replaced, in `# ~ $ % @ = != <= < >= > ! | ^ & + / *`.
|
|
575
|
+
For instance:
|
|
576
|
+
|
|
577
|
+
```json
|
|
578
|
+
{
|
|
579
|
+
"%": { ".com": "#", ".or": "|", ".merge": "+" }
|
|
580
|
+
}
|
|
581
|
+
```
|
|
582
|
+
|
|
583
|
+
Declares property substitutions, which translate this model:
|
|
584
|
+
|
|
585
|
+
```json
|
|
586
|
+
{ ".merge": [ {"a": 0}, {".or": [ {"b": 0}, {"c": 0} ] } ] }
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
Into:
|
|
590
|
+
|
|
591
|
+
```json
|
|
592
|
+
{ "+": [ {"a": 0}, {"|": [ {"b": 0}, {"c": 0} ] } ] }
|
|
593
|
+
```
|
|
594
|
+
|
|
595
|
+
These substitutions can be carried out by a separate preprocessor which generates
|
|
596
|
+
the resulting standard model without any renamed symbol.
|
|
597
|
+
|
|
598
|
+
When declaring the model meta-model with `"~"` at the root, any renaming section specified
|
|
599
|
+
in the meta-model **must** be applied to the current model before further processing.
|
|
600
|
+
This feature allow the localization of the model syntax.
|
|
601
|
+
|
|
566
602
|
## Static Typing Lattice
|
|
567
603
|
|
|
568
604
|
In the above specification, there are several requirements for having _one_ known type
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# JSON Model Compiler Versions
|
|
2
2
|
|
|
3
|
+
## 2.0.65 on 2026-11-01
|
|
4
|
+
|
|
5
|
+
- models: json schema drafts as a diff (4, 6, 7, 8, 9)
|
|
6
|
+
- tests: also check json schema diff versions
|
|
7
|
+
- tests: add more trafo tests
|
|
8
|
+
- tests: update trafo support in model schema used by some tests
|
|
9
|
+
- models: add for openapi overlay spec
|
|
10
|
+
- models: add json patch spec (RFC6902) and tests
|
|
11
|
+
- model: allow comments in trafo
|
|
12
|
+
- model: fix missing resolver forwarding
|
|
13
|
+
- pr: rewrite trafo spec
|
|
14
|
+
- tests: add sanity assertion about xdist parallel pytest runs
|
|
15
|
+
|
|
3
16
|
## 2.0.64 on 2026-10-26
|
|
4
17
|
|
|
5
18
|
- bench: do not link same version and message artifacts, keep first encountered
|
|
@@ -158,7 +158,7 @@ on a set of test vectors.
|
|
|
158
158
|
- Number of test vector JSON values: _${n_values}_
|
|
159
159
|
- All tested JSON values (including models, generated schemas and IR, and test suite schemas): _${all_values}_
|
|
160
160
|
|
|
161
|
-
Over
|
|
161
|
+
Over _180,000_ assertion checks are performed when running non-regression tests:
|
|
162
162
|
generated files, values validated in various languages…
|
|
163
163
|
|
|
164
164
|
[Example models](https://json-model.org/MODELS) cover typical use cases and demonstrate
|
|
@@ -106,6 +106,10 @@ def valid(jm: JsonModel,
|
|
|
106
106
|
finite = not jm._isRef(ref) or ref == "$#" # Hmmm…
|
|
107
107
|
if not finite:
|
|
108
108
|
log.debug(f"infinite recursion on {smodel}: {recref} ({recid})")
|
|
109
|
+
if jm._debug >= 3:
|
|
110
|
+
log.debug(f"{jm._id}: {jm._model}")
|
|
111
|
+
for name, j in jm._defs.items():
|
|
112
|
+
log.debug(f"{jm._id}: {name} -> {j._id} ({j._model})")
|
|
109
113
|
return finite
|
|
110
114
|
|
|
111
115
|
def validFlt(model: ModelType, path: ModelPath) -> bool:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.0.65
|
|
@@ -294,7 +294,7 @@ class JsonModel:
|
|
|
294
294
|
|
|
295
295
|
# extract actual definitions
|
|
296
296
|
self._defs.update({
|
|
297
|
-
n: JsonModel(m,
|
|
297
|
+
n: JsonModel(m, self._resolver, url=self._url + "#" + n,
|
|
298
298
|
head=self._head, scope=self._defs, debug=self._debug,
|
|
299
299
|
loose_int=self._loose_int, loose_float=self._loose_float,
|
|
300
300
|
dname=n, single_line=self._single_line)
|
|
@@ -1023,22 +1023,26 @@ class JsonModel:
|
|
|
1023
1023
|
else:
|
|
1024
1024
|
name, xpath = tpath, []
|
|
1025
1025
|
log.debug(f"{self._id}: parsePath name={name} xpath={xpath}")
|
|
1026
|
+
# log.debug(f"{self._id}: defs={list(self._defs.keys())}")
|
|
1026
1027
|
jm = self.resolveRef(name, path, True)
|
|
1027
1028
|
log.debug(f"{self._id}: {name} resolved to {jm._id}")
|
|
1028
1029
|
return (jm, xpath)
|
|
1029
1030
|
|
|
1030
1031
|
def _isTrafo(self, trafo: ModelTrafo):
|
|
1031
1032
|
"""Tell whether trafo is a transformation object."""
|
|
1032
|
-
return isinstance(trafo, dict) and
|
|
1033
|
+
return isinstance(trafo, dict) and \
|
|
1034
|
+
set(filter(lambda p: not p.startswith("#"), trafo.keys())).issubset({"/", "*", "~"})
|
|
1033
1035
|
|
|
1034
1036
|
def _applyTrafo(self, j: Jsonable, trafo: ModelTrafo, path: ModelPath):
|
|
1035
1037
|
"""Apply this transformation on j."""
|
|
1036
1038
|
|
|
1039
|
+
if self._debug:
|
|
1040
|
+
log.debug(f"{self._id}: IN applyTrafo trafo={trafo} on j={j} at {path}")
|
|
1041
|
+
|
|
1042
|
+
# replace
|
|
1037
1043
|
if not self._isTrafo(trafo):
|
|
1038
1044
|
return trafo
|
|
1039
1045
|
assert isinstance(trafo, dict) # pyright hint
|
|
1040
|
-
if self._debug:
|
|
1041
|
-
log.debug(f"{self._id}: applyTrafo trafo={trafo} on j={j} [{path}]")
|
|
1042
1046
|
|
|
1043
1047
|
if "/" in trafo:
|
|
1044
1048
|
sub = trafo["/"]
|
|
@@ -1071,14 +1075,15 @@ class JsonModel:
|
|
|
1071
1075
|
# keep only those props, as well as comments
|
|
1072
1076
|
for prop in list(j.keys()):
|
|
1073
1077
|
if prop.startswith("#") or prop in add:
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
del j[prop]
|
|
1078
|
+
continue
|
|
1079
|
+
del j[prop]
|
|
1077
1080
|
else:
|
|
1078
1081
|
raise ModelError(f"cannot add list to {tname(j)} at {path}")
|
|
1079
1082
|
elif isinstance(add, dict):
|
|
1080
1083
|
if isinstance(j, dict):
|
|
1081
1084
|
for k, v in add.items():
|
|
1085
|
+
if k.startswith("#"):
|
|
1086
|
+
continue
|
|
1082
1087
|
if k in j:
|
|
1083
1088
|
log.warning(f"overwriting property {k} at {path}")
|
|
1084
1089
|
j[k] = v
|
|
@@ -1128,6 +1133,7 @@ class JsonModel:
|
|
|
1128
1133
|
pn = p[1:]
|
|
1129
1134
|
new[pn] = v
|
|
1130
1135
|
del j[p]
|
|
1136
|
+
# else skip
|
|
1131
1137
|
j.update(**new)
|
|
1132
1138
|
new = {}
|
|
1133
1139
|
# simple changes
|
|
@@ -1141,6 +1147,9 @@ class JsonModel:
|
|
|
1141
1147
|
else:
|
|
1142
1148
|
raise ModelError(f"unexpected rename type at {path}")
|
|
1143
1149
|
|
|
1150
|
+
if self._debug >= 3:
|
|
1151
|
+
log.debug(f"{self._id}: OUT applyTrafo is j={j} {path}")
|
|
1152
|
+
|
|
1144
1153
|
return j
|
|
1145
1154
|
|
|
1146
1155
|
def _applyModelTrafoAtPath(self,
|
|
@@ -1152,7 +1161,9 @@ class JsonModel:
|
|
|
1152
1161
|
"""Apply a transformation into a JSON Model."""
|
|
1153
1162
|
|
|
1154
1163
|
if self._debug:
|
|
1155
|
-
log.debug(f"{jm._id}: {trafo} at {path}: {tpath}")
|
|
1164
|
+
log.debug(f"{jm._id}: applying {trafo} at {path}: {tpath}")
|
|
1165
|
+
if self._debug >= 3:
|
|
1166
|
+
log.debug(f"{jm._id}: model = {jm._model}")
|
|
1156
1167
|
|
|
1157
1168
|
j = jm._model
|
|
1158
1169
|
|
|
@@ -1208,9 +1219,11 @@ class JsonModel:
|
|
|
1208
1219
|
if not isinstance(names, list) or not all(isinstance(s, str) for s in names):
|
|
1209
1220
|
raise ModelError(f"namespace remove must be a list of names at {path}")
|
|
1210
1221
|
for name in names:
|
|
1222
|
+
if name.startswith("#"):
|
|
1223
|
+
continue
|
|
1211
1224
|
if name not in jm._defs:
|
|
1212
1225
|
raise ModelError(f"missing {name} definition in model {jm._id} at {path}")
|
|
1213
|
-
#
|
|
1226
|
+
# NOTE this may not be enough!
|
|
1214
1227
|
del jm._defs[name]
|
|
1215
1228
|
# add new definitions
|
|
1216
1229
|
if "*" in trafo:
|
|
@@ -1218,8 +1231,10 @@ class JsonModel:
|
|
|
1218
1231
|
if not isinstance(defs, dict):
|
|
1219
1232
|
raise ModelError(f"expecting definitions at {path}")
|
|
1220
1233
|
for name, model in defs.items():
|
|
1234
|
+
if name.startswith("#"):
|
|
1235
|
+
continue
|
|
1221
1236
|
# log.warning(f"{jm._id}: adding {name}")
|
|
1222
|
-
#
|
|
1237
|
+
# NOTE this may not be enough!
|
|
1223
1238
|
jm._defs[name] = JsonModel(
|
|
1224
1239
|
model, jm._resolver, head=jm._head, scope=jm._defs,
|
|
1225
1240
|
loose_int=jm._loose_int, loose_float=jm._loose_float,
|
|
@@ -1235,6 +1250,8 @@ class JsonModel:
|
|
|
1235
1250
|
# build update
|
|
1236
1251
|
updates = {}
|
|
1237
1252
|
for po, pn in renames.items():
|
|
1253
|
+
if po.startswith("#"):
|
|
1254
|
+
continue
|
|
1238
1255
|
if po not in self._defs:
|
|
1239
1256
|
raise ModelError(f"missing definition {po} at {path}")
|
|
1240
1257
|
updates[pn] = self._defs[po]
|
|
@@ -1250,14 +1267,16 @@ class JsonModel:
|
|
|
1250
1267
|
|
|
1251
1268
|
# NOTE transformation specs may be empty
|
|
1252
1269
|
for tpath, trafo in rules.items():
|
|
1253
|
-
|
|
1270
|
+
if self._debug:
|
|
1271
|
+
log.debug(f"{self._id}: tpath={tpath} trafo={trafo}")
|
|
1254
1272
|
lpath = ["%", tpath] # FIXME
|
|
1255
1273
|
# typing issue, cannot assign list[str] to list[str|int] !?
|
|
1256
1274
|
jm, path = self._parsePath(tpath, lpath) # type: ignore
|
|
1275
|
+
# log.debug(f"{self._id}: {jm._id} is {jm._model}")
|
|
1257
1276
|
if tpath.endswith("#"): # model namespace
|
|
1258
1277
|
self._applyRootTrafoAtPath(jm, path, trafo, lpath)
|
|
1259
1278
|
else:
|
|
1260
1279
|
self._applyModelTrafoAtPath(jm, path, trafo, lpath) # type: ignore
|
|
1261
1280
|
|
|
1262
1281
|
if self._debug >= 2:
|
|
1263
|
-
log.debug(f"edited model
|
|
1282
|
+
log.debug(f"{self._id}: edited model {self._model} ({self._defs})")
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
2.0.64
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/javascript_foot.js
RENAMED
|
File without changes
|
{json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/javascript_free.js
RENAMED
|
File without changes
|
{json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/javascript_head.js
RENAMED
|
File without changes
|
{json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/javascript_init.js
RENAMED
|
File without changes
|
{json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/data/javascript_main.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/java/.gitignore
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/js/package.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/t/manifest.t
RENAMED
|
File without changes
|
{json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/t/pod-coverage.t
RENAMED
|
File without changes
|
|
File without changes
|
{json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/pl/xt/boilerplate.t
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/sql/json_model--2.0.sql
RENAMED
|
File without changes
|
{json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model/runtime/sql/json_model.control
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model_compiler.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model_compiler.egg-info/not-zip-safe
RENAMED
|
File without changes
|
{json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model_compiler.egg-info/requires.txt
RENAMED
|
File without changes
|
{json_model_compiler-2.0.64 → json_model_compiler-2.0.65}/json_model_compiler.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|