Skip to content
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

[feature] YAML Schema validation for syntax compatibility check #348

Open
martinrieder opened this issue May 17, 2024 · 3 comments
Open

Comments

@martinrieder
Copy link

martinrieder commented May 17, 2024

With respect to the latest backwards-incompatible changes, input files may require some compatibility check. It is quite common that drawings are revised after many years. May I suggest adding an (optional) "syntax version" tag? How else could it be assured that future versions of WireViz support the syntax of an older one?

Note that following issue was raised by @nanangp for adding versioning checks on the CLI syntax as well:
nanangp/vscode-wireviz-preview#6

Going a bit further, some of the settings given as a command line argument, could also be listed in a header of the YAML file. This could either be a comment or incorporated in the WireViz syntax, like the technical drawing changes require adding some general info for the title block as well.

This suggestion might also be important for #223 YAML parser replacement.

@martinrieder
Copy link
Author

martinrieder commented May 21, 2024

I changed the title because I believe that schema validation provides just what we need here. It allows to check your YAML even before running WireViz.

Example from https://github.com/redhat-developer/yaml-language-server :

Associating a schema in the YAML file
It is possible to specify a yaml schema using a modeline. Schema url can be a relative path. If a relative path is specified, it is calculated from yaml file path, not from workspace root path

# yaml-language-server: $schema=<urlToTheSchema>

@martinrieder
Copy link
Author

martinrieder commented May 28, 2024

Found this file by @cooked as a starting point: wireviz-yaml-schema.json

TODO

  • Implement the WireViz syntax according to the current spec in syntax.md
  • Recognize cable and wire designator through pattern matching
  • Validate that designators in connections exist
  • Recognize special designators and auto-generation syntax in connections
  • Assure the correct order of cables and wires in the connections list

@martinrieder
Copy link
Author

martinrieder commented May 29, 2024

Additional to JSON Schema based validation that is widely supported, there is also 23andMe/Yamale which relies on its own schema defined in YAML itself. It can read data through either PyYAML or Ruamel, so choosing this would depend on the parser choice taken in #223.

I would like to mention that checks like in 9b2b22d will not be needed if schema validation was done programmatically.

Note that the validation should also take effect with the GH action Create Examples once implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant