Skip to content

Adding script for generating Json schema for better maintainability #586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: feat/add-programming-language-tag
Choose a base branch
from

Conversation

BrentBlanckaert
Copy link
Collaborator

@BrentBlanckaert BrentBlanckaert commented Apr 12, 2025

I added a script to generate a new Json schema from the multilingual json schema, used in the DSL translator, that can be used in the IDE.

This can be run by using:

python -m tested.transform_json ./tested/dsl/schema-strict-nat-translation.json

This script can now also generate schema.json and schema-strict.json based of schema-strict-nat-translations.json
For this you would need to run:

python -m tested.transform_json ./tested/dsl/schema-strict-nat-translation.json strict

or

python -m tested.transform_json ./tested/dsl/schema-strict-nat-translation.json not-strict

Now only schema-strict-nat-translations.json and transform_json.py need to be maintained.

@BrentBlanckaert BrentBlanckaert self-assigned this Apr 12, 2025
@BrentBlanckaert BrentBlanckaert added enhancement New feature or request dsl labels Apr 12, 2025
@BrentBlanckaert BrentBlanckaert changed the title Adding script for generating Json schema used in the IDE Adding script for generating Json schema for maintainability Apr 13, 2025
@BrentBlanckaert BrentBlanckaert changed the title Adding script for generating Json schema for maintainability Adding script for generating Json schema for better maintainability Apr 13, 2025
@BrentBlanckaert BrentBlanckaert requested review from Copilot, niknetniko and jorg-vr and removed request for Copilot April 29, 2025 16:19
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new Python script that transforms an existing JSON schema for the DSL translator into alternative schemas usable by the IDE. Key changes include:

  • Adding functions to transform monolingual and multilingual JSON schemas.
  • Implementing a command-line interface for generating different schema variants (strict and non-strict).
Files not reviewed (2)
  • tested/dsl/schema-strict.json: Language not supported
  • tested/dsl/schema.json: Language not supported

Copy link
Contributor

@jorg-vr jorg-vr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I was initially a fan of the idea, this code does not at all seem 'more maintainable' but actually 'more likely to cause unexpected bugs, when we ever update the json schema'

Also keeping the the version with natural translations as the source of truth to be managed in the future, doesn't seem like the best idea. This file is almost twice as long as the other schemas, with mostly duplicate fragments.
So I would assume the result being simpler if you automatically inserted that code in a script instead of automatically removing it

I have been researching better ways to do this (Also to keep the translations schema more manageable). I'll look into this further at a later date, but I am open for suggestions

@BrentBlanckaert
Copy link
Collaborator Author

BrentBlanckaert commented Apr 30, 2025

The intention behind this script was to ensure that only a single JSON Schema and the script itself need to be maintained. In my view, this is still preferable to maintaining four separate schemas.

I also prefer using the more detailed schema because, while it may be longer, it keeps the script significantly cleaner. Handling many specific cases (for example: where to use natural_language maps) in the script would otherwise make the code much harder to manage.

There may be a more efficient way to approach this, but unfortunately, given the limited time I have remaining, I'm unsure if I'll be able to implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dsl enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants