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

Generate air.schema.json using schemars #212

Merged
merged 1 commit into from
Feb 10, 2025
Merged

Conversation

DavisVaughan
Copy link
Collaborator

@DavisVaughan DavisVaughan commented Feb 7, 2025

First step of #106

This PR:

  • Adds a "schemars" feature to the settings and workspace crates that optionally derive JsonSchema. Note that schemars is smart enough to respect serde attributes, like rename_all = "kebab-case" and deny_unknown_fields, which is awesome
  • Generates the air.schema.json using a new xtask helper, callable through just gen-schema
    • There are tests here to ensure that we can't accidentally allow our schema to get out of sync with our TomlOptions struct. If the options struct is updated, the schema must also be updated.

This is a first step, we also need to either:

To immediately try this out, you can put this in your settings, then make sure to run Developer: Restart Extension Host

    "evenBetterToml.schema.associations": {
        "^.*air.toml$": "https://raw.githubusercontent.com/posit-dev/air/8049e67080e0976bfe8bcf60efa30912a88ddea1/air.schema.json"
    },

Then open an air.toml and it should do this

Screen.Recording.2025-02-07.at.1.20.54.PM.mov

As you can see in the video, there are some issues with field duplication. I do not believe this is our fault, I think this is this taplo issue tamasfe/taplo#514. Ruff also has the same issues. I do not believe we should let this block us, as this is still quite useful even with the duplication.

@DavisVaughan DavisVaughan merged commit e7eedce into main Feb 10, 2025
4 checks passed
@DavisVaughan DavisVaughan deleted the feature/json-schema branch February 10, 2025 14:23
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

Successfully merging this pull request may close these issues.

2 participants