Radish alpha
h
rad:z3gqcJUoA1n9HaHKufZs5FCSGazv5
Radicle Heartwood Protocol & Stack
Radicle
Git
radicle-schemars: A crate for extracting JSON schemas
Merged lorenz opened 11 months ago

JSON Schema for the Control Socket

JSON Schema extraction via schemars is provided for configurations. There are other interfaces that use JSON for (de-)serialization, such as the communication with radicle-node via the control socket.

To ease implementation of tools that want to communicate via the control socket, we add the respective schemars annotations.

Extracting of JSON Schemas

Extracting JSON Schemas from the Radicle crate can be done via radicle-cli for radicle::profile::Config by executing:

rad config schema

However, for other JSON Schema metadata, this is not possible.

To allow other tools to extract JSON schemas as part of their build process, introduce a new crate that only depends on radicle, schemars, and serde, with a tiny binary that will reproduce various schemas.

schemars as workspace dependency

The schemars crate is a dependency of multiple workspace crates in the same version. Its version number is repeated multiple times in the respective */Cargo.toml files. This requires more maintenance effort and risks versions drifting.

As long as all crates depend on the same version, it makes more sense to have schemars as a workspace dependency.

See: https://doc.rust-lang.org/cargo/reference/workspaces.html#the-dependencies-table

lorenz opened with revision 7bafe3d5 on base f4c8ff7a +287 -12 11 months ago

JSON Schema for the Control Socket

JSON Schema extraction via schemars is provided for configurations. There are other interfaces that use JSON for (de-)serialization, such as the communication with radicle-node via the control socket.

To ease implementation of tools that want to communicate via the control socket, we add the respective schemars annotations.

Extracting of JSON Schemas

Extracting JSON Schemas from the Radicle crate can be done via radicle-cli for radicle::profile::Config by executing:

rad config schema

However, for other JSON Schema metadata, this is not possible.

To allow other tools to extract JSON schemas as part of their build process, introduce a new crate that only depends on radicle, schemars, and serde, with a tiny binary that will reproduce various schemas.

schemars as workspace dependency

The schemars crate is a dependency of multiple workspace crates in the same version. Its version number is repeated multiple times in the respective */Cargo.toml files. This requires more maintenance effort and risks versions drifting.

As long as all crates depend on the same version, it makes more sense to have schemars as a workspace dependency.

See: https://doc.rust-lang.org/cargo/reference/workspaces.html#the-dependencies-table

fintohaps pushed revision 2 a1955053 on base f4c8ff7a +305 -12 11 months ago

FEEDBACK: better error messaging for incorrect args/schemas

lorenz pushed revision 3 07afd838 on base f4c8ff7a +314 -12 11 months ago

radicle-schemars: Improve handling of list of schema names.

fintohaps pushed revision 4 c967add1 on base f4c8ff7a +334 -12 11 months ago

FEEDBACK: use an enum

fintohaps pushed revision 5 a5e2b911 on base 9dae540c +334 -12 11 months ago

Rebased

fintohaps merged revision a5e2b911 at 4cd0782f 11 months ago