-
Notifications
You must be signed in to change notification settings - Fork 94
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
Json schemas for VSCode YAML Support #497
Conversation
libraries/core/dora-schema.json
Outdated
"nodes" | ||
], | ||
"properties": { | ||
"_unstable_deploy": { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to have this (and other) _unstable_*
fields in the schema? If not, we should be able to ignore them using a #[schemars(skip)]
attribute.
I'm also fine with keeping them in, as the field names makes it clear that they are unstable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, in the end I have removed unstable features as to not overcrowd: autocomplete and push people on features not yet complete.
let raw_schema = raw_schema.replace( | ||
"\"additionalProperties\": false", | ||
"\"additionalProperties\": true", | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this replace needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Add additional properties to True, as #[derive(transparent)] of enums are not well handled.
//
// 'OneOf' such as Custom Nodes, Operators and Single Operators overwrite property values of the initial struct `Nodes`.`
// which make the original properties such as `id` and `name` not validated by IDE extensions.
I have added documentation but basically its because we use #[derive(transparent)] on an enum, and the parent properties get forgotten in the JSON Schema.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
In an effort to address, developers difficulty in discovering dora-rs functionality, I'm adding a way to:
schemars
redhat.vscode-yaml
This enables:
Edge cases
Failure to auto-generate schema
Some auto-generation of some of our rust struct definition did not work. They are the one that are using
serde(from=
such as:dora/libraries/core/src/descriptor/mod.rs
Lines 270 to 280 in 558fa14
In those case I had to remove the validation so that our current dataflow passes.
Failure to manage #[serde(flatten)] with additional properties
In our Nodes definition, we are using #[serde(flatten)] of an enum with some additional properties.
In order to validate those additional properties, I had to set
additionalproperties
to true.Demo
2024-05-15.15-43-22.mp4