mbox series

[RFC,v1,0/1] dts: separate allowed values from json schema

Message ID 20240807140831.27558-2-npratte@iol.unh.edu (mailing list archive)
Headers
Series dts: separate allowed values from json schema |

Message

Nicholas Pratte Aug. 7, 2024, 2:08 p.m. UTC
I started discussions with Juraj about potentially taking all of the
'test_suite' enums in the framework's json schema and putting them into
its own smaller json file that can easily be referenced. The thought
being that doing so might make it easier for outside developers to
navigate when writing their own test suites in the future, and it might
help to keep the schema clean in the long term as the list inevitably
gets larger. We took the idea one step further and discussed the idea of
putting all enum/allowed values within the schema into a different
location.

This is a pretty simple change that doesn't require much effort, but
separating the schema is not so graceful insofar that you cannot use
'$ref' tags like you might expect; the only way to do this reasonably
using Warlock is to merge the dictionaries together before creating a
Warlock model, hence the use of '$defs' instead of references to a local
file.

Nicholas Pratte (1):
  dts: split enums from primary json schema

 dts/framework/config/__init__.py              |   4 +
 dts/framework/config/conf_allowed_values.json | 131 ++++++++++++++++++
 dts/framework/config/conf_yaml_schema.json    | 111 ++-------------
 3 files changed, 143 insertions(+), 103 deletions(-)
 create mode 100644 dts/framework/config/conf_allowed_values.json
  

Comments

Luca Vizzarro Aug. 7, 2024, 3:01 p.m. UTC | #1
Hi Nicholas,

Thank you for the proposal. The way I see it is that JSON schema can be 
very developer unfriendly to read, therefore I would not rely on it for 
this purpose. Adding $refs as well could start making it more 
complicated for this purpose. It's helpful for structuring and 
maintaining the files though.

Normally, a schema is meant for validation purposes. And docs should 
provide the developer with the right information.

Nonetheless, I am getting started in replacing Warlock with Pydantic. 
And basing the Python classes on Pydantic models. Unfortunately, this 
will nullify this work altogether, as Pydantic provides an automatic 
facility for generating the JSON schema, thus removing the need for 
manual maintenance.

Best,
Luca
  
Juraj Linkeš Sept. 10, 2024, 9:34 a.m. UTC | #2
On 7. 8. 2024 17:01, Luca Vizzarro wrote:
> Hi Nicholas,
> 
> Thank you for the proposal. The way I see it is that JSON schema can be 
> very developer unfriendly to read, therefore I would not rely on it for 
> this purpose. Adding $refs as well could start making it more 
> complicated for this purpose. It's helpful for structuring and 
> maintaining the files though.
> 
> Normally, a schema is meant for validation purposes. And docs should 
> provide the developer with the right information.
> 
> Nonetheless, I am getting started in replacing Warlock with Pydantic. 
> And basing the Python classes on Pydantic models. Unfortunately, this 
> will nullify this work altogether, as Pydantic provides an automatic 
> facility for generating the JSON schema, thus removing the need for 
> manual maintenance.
> 
> Best,
> Luca

What Luca says makes a lot of sense. Let's not bother improving the 
schema since it'll be obsolete soon with the Pydantic changes.