Skip to content

Add support to generate resource json schema#1337

Open
bytedream wants to merge 2 commits intomoghtech:mainfrom
bytedream:resource-json-schema
Open

Add support to generate resource json schema#1337
bytedream wants to merge 2 commits intomoghtech:mainfrom
bytedream:resource-json-schema

Conversation

@bytedream
Copy link
Copy Markdown

@bytedream bytedream commented Apr 7, 2026

Adds support to generate a json schema for resource definitions. This allows for suggestions in editors:
image

The schema is generated via the schemars crate, it provides a derive macro which is placed above each struct that is relevant to resource definitions (locked behind the schemars feature). It can be generated by a subcommand of the new created xtask crate: e.g. cargo xtask generate resource-json-schema --pretty --stdout.

Although schemars is 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 to schemars). I've also looked if typeshare can 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_derive2 dependency, the rev points to the PR head) and mbecker20/partial_derive2#2 to include all comments.

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.

1 participant