mirror of
https://github.com/moghtech/komodo.git
synced 2026-05-07 19:35:38 -05:00
[PR #1337] Add support to generate resource json schema #3022
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/moghtech/komodo/pull/1337
Author: @bytedream
Created: 4/7/2026
Status: 🔄 Open
Base:
main← Head:resource-json-schema📝 Commits (2)
15636adadd support to generate resource json schemaffbc65fremove unnecessary renames📊 Changes
39 files changed (+393 additions, -15 deletions)
View changed files
📝
.cargo/config.toml(+4 -1)📝
Cargo.lock(+41 -7)📝
Cargo.toml(+4 -1)📝
client/core/rs/Cargo.toml(+2 -0)📝
client/core/rs/src/api/execute/action.rs(+2 -0)📝
client/core/rs/src/api/execute/alerter.rs(+2 -0)📝
client/core/rs/src/api/execute/build.rs(+3 -0)📝
client/core/rs/src/api/execute/deployment.rs(+10 -0)📝
client/core/rs/src/api/execute/maintenance.rs(+5 -0)📝
client/core/rs/src/api/execute/mod.rs(+2 -0)📝
client/core/rs/src/api/execute/procedure.rs(+2 -0)📝
client/core/rs/src/api/execute/repo.rs(+7 -0)📝
client/core/rs/src/api/execute/server.rs(+21 -0)📝
client/core/rs/src/api/execute/stack.rs(+14 -0)📝
client/core/rs/src/api/execute/swarm.rs(+10 -0)📝
client/core/rs/src/api/execute/sync.rs(+1 -0)📝
client/core/rs/src/api/write/sync.rs(+1 -0)📝
client/core/rs/src/entities/action.rs(+4 -0)📝
client/core/rs/src/entities/alert.rs(+5 -0)📝
client/core/rs/src/entities/alerter.rs(+10 -0)...and 19 more files
📄 Description
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 https://github.com/mbecker20/partial_derive2/pull/1 to compile (hence the changed
partial_derive2dependency, the rev points to the PR head) and https://github.com/mbecker20/partial_derive2/pull/2 to include all comments.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.