[PR #1337] Add support to generate resource json schema #5762

Open
opened 2026-04-22 00:51:08 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/moghtech/komodo/pull/1337
Author: @bytedream
Created: 4/7/2026
Status: 🔄 Open

Base: mainHead: resource-json-schema


📝 Commits (2)

  • 15636ad add support to generate resource json schema
  • ffbc65f remove 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:
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 https://github.com/mbecker20/partial_derive2/pull/1 to compile (hence the changed partial_derive2 dependency, 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.

## 📋 Pull Request Information **Original PR:** https://github.com/moghtech/komodo/pull/1337 **Author:** [@bytedream](https://github.com/bytedream) **Created:** 4/7/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `resource-json-schema` --- ### 📝 Commits (2) - [`15636ad`](https://github.com/moghtech/komodo/commit/15636ad6473ada49393ce290852263b34d4ab427) add support to generate resource json schema - [`ffbc65f`](https://github.com/moghtech/komodo/commit/ffbc65f5873cbf780c831486e02073b9aac7a082) remove unnecessary renames ### 📊 Changes **39 files changed** (+393 additions, -15 deletions) <details> <summary>View changed files</summary> 📝 `.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_ </details> ### 📄 Description Adds support to generate a json schema for resource definitions. This allows for suggestions in editors: <img width="1160" height="434" alt="image" src="https://github.com/user-attachments/assets/f60bf5b6-c075-4388-8671-5f9be0fa6694" /> 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.<br>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_derive2` dependency, the rev points to the PR head) and https://github.com/mbecker20/partial_derive2/pull/2 to include all comments. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-22 00:51:08 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/komodo#5762