Add support to generate resource json schema#1337
Open
bytedream wants to merge 2 commits intomoghtech:mainfrom
Open
Add support to generate resource json schema#1337bytedream wants to merge 2 commits intomoghtech:mainfrom
bytedream wants to merge 2 commits intomoghtech:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support to generate a json schema for resource definitions. This allows for suggestions in editors:

The schema is generated via the
schemarscrate, it provides a derive macro which is placed above each struct that is relevant to resource definitions (locked behind theschemarsfeature). It can be generated by a subcommand of the new createdxtaskcrate: e.g.cargo xtask generate resource-json-schema --pretty --stdout.Although
schemarsis serde compatible in most parts, it's currently unable to create schema definitions for aliases. I've manually renamed fields where an alias is more understandable than the rust field name (via field attributes, the renames are exclusive toschemars). I've also looked iftypesharecan generate a json schema, but it doesn't seem so.If the PR gets accepted, it would be nice if the schema could be hosted on the komodo website, so users can directly include the url in their config files / LSPs and don't have to manually download / generate it.
It might also be possible to generate parts of the resource docs on the komodo website by the json schema, but I haven't looked further into it.
Relies on mbecker20/partial_derive2#1 to compile (hence the changed
partial_derive2dependency, the rev points to the PR head) and mbecker20/partial_derive2#2 to include all comments.