Commit
Message
Changed Files (16)
-
modified CHANGELOG.md
diff --git a/CHANGELOG.md b/CHANGELOG.md index 630883c..a8e2ea3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ### 🚀 Features - If a `static` dir is found in custom theme folder, copy it to output +- Add opengraph metadata to site generation ### ⚙️ Miscellaneous Tasks -
modified Cargo.lock
diff --git a/Cargo.lock b/Cargo.lock index ce5c5f0..76792a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -15,6 +15,7 @@ dependencies = [ "ignore", "miette", "pulldown-cmark", + "schemars", "semver", "serde", "serde_json", @@ -398,6 +399,12 @@ dependencies = [ "crypto-common", ] +[[package]] +name = "dyn-clone" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" + [[package]] name = "equivalent" version = "1.0.2" @@ -1134,6 +1141,26 @@ dependencies = [ "bitflags", ] +[[package]] +name = "ref-cast" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" +dependencies = [ + "ref-cast-impl", +] + +[[package]] +name = "ref-cast-impl" +version = "1.0.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "regex" version = "1.12.3" @@ -1197,6 +1224,31 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "schemars" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2b42f36aa1cd011945615b92222f6bf73c599a102a300334cd7f8dbeec726cc" +dependencies = [ + "dyn-clone", + "ref-cast", + "schemars_derive", + "serde", + "serde_json", +] + +[[package]] +name = "schemars_derive" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d115b50f4aaeea07e79c1912f645c7513d81715d0420f8bc77a18c6260b307f" +dependencies = [ + "proc-macro2", + "quote", + "serde_derive_internals", + "syn", +] + [[package]] name = "scopeguard" version = "1.2.0" @@ -1239,6 +1291,17 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_derive_internals" +version = "0.29.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "serde_json" version = "1.0.150" -
modified Cargo.toml
diff --git a/Cargo.toml b/Cargo.toml index 682161d..9bd2992 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,6 +20,7 @@ human-panic = "2.0.5" ignore = "0.4" miette = { version = "7.6.0", features = ["fancy", "serde"] } pulldown-cmark = "0.12" +schemars = "1" semver = "1" serde = { version = "1.0.228", features = ["derive"] } serde_json = "1" -
added abbaye.schema.json
diff --git a/abbaye.schema.json b/abbaye.schema.json new file mode 100644 index 0000000..32eecea --- /dev/null +++ b/abbaye.schema.json @@ -0,0 +1,350 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "AbbayeConfig", + "description": "A full configuration for the Abbaye site generator.\n\nHere's a sample configuration that works well as a starting point for rust projects:\n\n```toml\n[site]\nname = \"Abbaye\"\n\n[version_extractor]\ntype = \"cargo\" # extract version from Cargo.toml\n\n[changelog]\n# let's use the default changelog extractor\n\n[[builders]]\ntype = \"cargo\" # calls `cargo build --release` for each target\ntargets = [\"x86_64-unknown-linux-gnu\", \"x86_64-unknown-linux-musl\"]\n[[builders]]\ntype = \"cargo_doc\" # generates documentation using `cargo doc`\nno_deps = true\n\n[[builders]]\ntype = \"archive\" # creates a compressed tarball of the source code\n```\n\nYou can learn more about each builder type in the [builders module documentation](crate::builders).", + "type": "object", + "properties": { + "builders": { + "description": "Builders to run during the build process.", + "type": "array", + "items": { + "$ref": "#/$defs/AnyBuilder" + } + }, + "changelog": { + "description": "Configuration for the changelog extractor.", + "$ref": "#/$defs/ChangelogConfig" + }, + "output_dir": { + "description": "Where to output generated files. Defaults to `public`.", + "type": [ + "string", + "null" + ], + "default": "public" + }, + "site": { + "description": "Metadata about the site.", + "$ref": "#/$defs/SiteConfig" + }, + "version_extractor": { + "description": "which version extractor to use to extract the version(s) of the project", + "$ref": "#/$defs/AnyVersionExtractor" + } + }, + "required": [ + "site", + "version_extractor", + "changelog", + "builders" + ], + "$defs": { + "AnyBuilder": { + "oneOf": [ + { + "description": "Creates a `.tar.gz` archive of the source tree, automatically excluding\nfiles and directories matched by any `.gitignore` found in the hierarchy.\n\n```toml\n[[builders]]\ntype = \"archive\"\nsource_dir = \".\" # optional, defaults to CWD\noutput = \"myproject-1.0.0.tar.gz\" # optional, defaults to source.tar.gz\nprefix = \"myproject-1.0.0\" # optional, defaults to source_dir name\n```", + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "archive" + } + }, + "$ref": "#/$defs/ArchiveBuilderConfig", + "required": [ + "type" + ] + }, + { + "description": "Compiles the crate in release mode with `cargo build --release`.\nOne or more target triples can be specified for cross-compilation;\nomitting `targets` builds for the host platform.\n\n```toml\n[[builders]]\ntype = \"cargo\"\ntargets = [\"x86_64-unknown-linux-musl\", \"aarch64-unknown-linux-musl\"]\nmanifest_path = \"Cargo.toml\" # optional\n```", + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "cargo" + } + }, + "$ref": "#/$defs/CargoBuilderConfig", + "required": [ + "type" + ] + }, + { + "description": "Generates API documentation with `cargo doc`.\nReturns the per-crate doc directory (e.g. `target/doc/my_crate`) as an\nartifact so it can be published or archived by a later pipeline step.\n\n```toml\n[[builders]]\ntype = \"cargo_doc\"\nno_deps = true # optional, skip dependency docs\nmanifest_path = \"Cargo.toml\" # optional\n```", + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "cargo_doc" + } + }, + "$ref": "#/$defs/CargoDocBuilderConfig", + "required": [ + "type" + ] + } + ] + }, + "AnyVersionExtractor": { + "oneOf": [ + { + "description": "Reads the version from the `version` field in the `[package]` section\nof a `Cargo.toml` file.\n\n```toml\n[version_extractor]\ntype = \"cargo\"\nmanifest_path = \"Cargo.toml\" # optional, defaults to ./Cargo.toml\n```", + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "cargo" + } + }, + "$ref": "#/$defs/CargoVersionConfig", + "required": [ + "type" + ] + }, + { + "description": "Derives the version from the most recent Git tag using\n`git describe --tags --always`.\nSupports stripping a tag prefix (e.g. `\"v\"`) and customising the\nsuffix appended when the working tree has uncommitted changes.\n\n```toml\n[version_extractor]\ntype = \"git\"\ntag_prefix = \"v\" # optional, strips leading \"v\"\ndirty_suffix = \"-dev\" # optional, defaults to \"-dirty\"\n```", + "type": "object", + "properties": { + "type": { + "type": "string", + "const": "git" + } + }, + "$ref": "#/$defs/GitVersionConfig", + "required": [ + "type" + ] + } + ] + }, + "ArchiveBuilderConfig": { + "description": "Configuration for [`ArchiveBuilder`].", + "type": "object", + "properties": { + "ignore_patterns": { + "description": "Glob patterns for files and directories to exclude from the archive.\nEach pattern is matched against every component of a path, so a pattern\nlike `\".git\"` excludes the `.git` directory and all its contents, and\n`\"*.local\"` excludes any entry whose name ends with `.local`.\nDefaults to `[\".git\", \"*.local\"]`.", + "type": "array", + "default": [ + ".git", + "*.local" + ], + "items": { + "type": "string" + } + }, + "output": { + "description": "Output path for the generated `.tar.gz` archive.\nDefaults to `source.tar.gz` in the current working directory.", + "type": [ + "string", + "null" + ] + }, + "prefix": { + "description": "Prefix applied to every entry path inside the archive.\nFor example, `\"myproject-1.0.0\"` produces entries like\n`myproject-1.0.0/src/main.rs`.\nDefaults to the source directory's name.", + "type": [ + "string", + "null" + ] + }, + "source_dir": { + "description": "Root directory to archive. Defaults to the current working directory.", + "type": [ + "string", + "null" + ] + } + } + }, + "CargoBuilderConfig": { + "description": "Configuration for [`CargoBuilder`].", + "type": "object", + "properties": { + "bins": { + "description": "Restrict collected artifacts to these binary (or cdylib) target names.\n\nWhen empty every artifact produced by a **workspace member or local\npath-dependency** is kept. Use this to avoid picking up extra binaries\nfrom dev-tools or examples that live in the same workspace.\n\n```toml\n[[builders]]\ntype = \"cargo\"\nbins = [\"my_binary\", \"my_cdylib\"]\n```", + "type": "array", + "default": [], + "items": { + "type": "string" + } + }, + "manifest_path": { + "description": "Optional path to the Cargo.toml manifest.\n\nPassed verbatim as `--manifest-path`. Defaults to the manifest in the\ncurrent working directory when absent.", + "type": [ + "string", + "null" + ] + }, + "targets": { + "description": "Cargo target triples to build for (e.g. `\"x86_64-unknown-linux-musl\"`).\n\nEach entry is passed as `--target <triple>` in a separate `cargo build`\ninvocation. When the list is empty, cargo builds for the host target.", + "type": "array", + "default": [], + "items": { + "type": "string" + } + } + } + }, + "CargoDocBuilderConfig": { + "description": "Configuration for [`CargoDocBuilder`].", + "type": "object", + "properties": { + "manifest_path": { + "description": "Optional path to the Cargo.toml manifest.\n\nPassed verbatim as `--manifest-path`. Defaults to the manifest in the\ncurrent working directory when absent.", + "type": [ + "string", + "null" + ] + }, + "no_deps": { + "description": "Skip building documentation for dependencies (`--no-deps`).", + "type": "boolean", + "default": false + } + } + }, + "CargoVersionConfig": { + "description": "Configuration for [`CargoVersion`].", + "type": "object", + "properties": { + "manifest_path": { + "description": "Path to the `Cargo.toml` to read the version from.\nDefaults to `Cargo.toml` in the current working directory.", + "type": [ + "string", + "null" + ] + } + } + }, + "ChangelogConfig": { + "description": "Configuration for [`ChangelogExtractor`].", + "type": "object", + "properties": { + "directory": { + "description": "Directory that contains the `CHANGELOG.md`.\nDefaults to the current working directory.", + "type": [ + "string", + "null" + ] + } + } + }, + "GitVersionConfig": { + "description": "Configuration for [`GitVersion`].", + "type": "object", + "properties": { + "dirty_suffix": { + "description": "Suffix appended to the version when the working tree has uncommitted\nchanges. Forwarded verbatim as `--dirty=<suffix>` to `git describe`.\nDefaults to `\"-dirty\"`.", + "type": "string", + "default": "-dirty" + }, + "tag_prefix": { + "description": "Strip this prefix from the tag name before returning the version.\nFor example, `\"v\"` turns `\"v1.2.3\"` into `\"1.2.3\"`.", + "type": [ + "string", + "null" + ] + } + } + }, + "OpenGraphConfig": { + "description": "OpenGraph configuration for the website.", + "type": "object", + "properties": { + "author": { + "description": "Author of the website. Used on release notes pages to indicate the author.", + "type": [ + "string", + "null" + ] + }, + "image": { + "description": "URL of the website's image.", + "type": "string" + }, + "image_alt_text": { + "description": "Alt text for the website's image.", + "type": [ + "string", + "null" + ] + }, + "type": { + "description": "OpenGraph type of the website. It will be used as the `og:type` meta tag.\nNote: by default, the value \"website\" will be enforced for the version listing page and \"article\" for the release notes page.", + "type": [ + "string", + "null" + ] + }, + "url": { + "description": "URL of the website. If not set, the `base_url` will be used instead. If `base_url` is not set either, the world explodes. Think of the kittens.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "image" + ] + }, + "SiteConfig": { + "description": "General website metadata.", + "type": "object", + "properties": { + "base_url": { + "description": "Canonical base URL of the published site (e.g. `\"https://example.com\"`).\nWhen set, the generated `releases.atom` feed will include absolute links\nand proper entry IDs. Trailing slashes are stripped automatically.", + "type": [ + "string", + "null" + ] + }, + "fediverse_creator": { + "description": "If you have a Fediverse account, you can set this to your username to enable Fediverse integration. (don't forget the starting '@' !)", + "type": [ + "string", + "null" + ] + }, + "lang": { + "description": "An optional language code for the website (e.g. `\"en\"` or `\"fr\"`).\nWhen set, the generated HTML will include a `lang` attribute on the `<html>` tag. Defaults to `\"en\"`.", + "type": [ + "string", + "null" + ] + }, + "name": { + "description": "Display name of the project, used in page titles and headings.", + "type": "string" + }, + "opengraph": { + "description": "OpenGraph configuration for the website.", + "anyOf": [ + { + "$ref": "#/$defs/OpenGraphConfig" + }, + { + "type": "null" + } + ] + }, + "readme": { + "description": "Path to the README file rendered on each version page.\nDefaults to `README.md` in the current working directory.", + "type": [ + "string", + "null" + ] + }, + "repo_url": { + "description": "URL of the project's repository (e.g. `\"https://git.sr.ht/~ololduck/abbaye\"`).\nWhen set, we will show the repository link in the generated website.", + "type": [ + "string", + "null" + ] + } + }, + "required": [ + "name" + ] + } + } +} -
modified abbaye.toml
diff --git a/abbaye.toml b/abbaye.toml index 43b9070..c583416 100644 --- a/abbaye.toml +++ b/abbaye.toml @@ -1,3 +1,5 @@ +"$schema" = "./abbaye.schema.json" + [site] name = "Abbaye" base_url = "http://vit.am/~ololduck/abbaye/" -
modified mise.toml
diff --git a/mise.toml b/mise.toml index f81810e..69fc990 100644 --- a/mise.toml +++ b/mise.toml @@ -49,9 +49,21 @@ flag "-o --output <file>" help="output file path" default="CHANGELOG.md" """ outputs = ["CHANGELOG.md"] +[tasks.generate-schema] +description = "generates a JSON schema for abbaye.toml" +run = [ + "cargo run --bin abbaye dump-schema > abbaye.schema.json && git add abbaye.schema.json" +] +outputs = ["abbaye.schema.json"] +sources = ["src/**.rs"] + [tasks.build] alias = "b" -depends = ["generate-readme", "generate-changelog -o CHANGELOG.md"] +depends = [ + "generate-readme", + "generate-changelog -o CHANGELOG.md", + "generate-schema" +] description = "build the project" run = ["cargo build"] sources = ["Cargo.toml", "Cargo.lock", "*.rs", "**/*.rs"] @@ -67,6 +79,7 @@ sources = ["Cargo.toml", "Cargo.lock", "*.rs", "**/*.rs"] depends = [ "generate-readme", "generate-changelog", + "generate-schema", "build::release", "fmt", "lint", -
modified src/builders/archive.rs
diff --git a/src/builders/archive.rs b/src/builders/archive.rs index 7758e6a..44bd88b 100644 --- a/src/builders/archive.rs +++ b/src/builders/archive.rs @@ -7,6 +7,7 @@ use flate2::{Compression, write::GzEncoder}; use globset::{Glob, GlobSet, GlobSetBuilder}; use ignore::WalkBuilder; use miette::{IntoDiagnostic, Result}; +use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use crate::builders::{ArtifactPath, Builder}; @@ -16,7 +17,7 @@ fn default_ignore_patterns() -> Vec<String> { } /// Configuration for [`ArchiveBuilder`]. -#[derive(Debug, Clone, Deserialize, Serialize)] +#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)] pub struct ArchiveBuilderConfig { /// Root directory to archive. Defaults to the current working directory. pub source_dir: Option<PathBuf>, -
modified src/builders/cargo.rs
diff --git a/src/builders/cargo.rs b/src/builders/cargo.rs index d51c41c..8cc85c4 100644 --- a/src/builders/cargo.rs +++ b/src/builders/cargo.rs @@ -4,6 +4,7 @@ use std::{ }; use miette::{IntoDiagnostic, Result, miette}; +use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use tokio::io::{AsyncBufReadExt, BufReader}; use tokio::process::Command; @@ -11,7 +12,7 @@ use tokio::process::Command; use crate::builders::{ArtifactPath, Builder}; /// Configuration for [`CargoBuilder`]. -#[derive(Debug, Default, Clone, Deserialize, Serialize)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema)] pub struct CargoBuilderConfig { /// Cargo target triples to build for (e.g. `"x86_64-unknown-linux-musl"`). /// @@ -237,7 +238,7 @@ async fn read_crate_version(manifest_path: Option<&Path>) -> Result<String> { // ── CargoDocBuilder ────────────────────────────────────────────────────────── /// Configuration for [`CargoDocBuilder`]. -#[derive(Debug, Default, Clone, Deserialize, Serialize)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema)] pub struct CargoDocBuilderConfig { /// Optional path to the Cargo.toml manifest. /// -
modified src/builders/mod.rs
diff --git a/src/builders/mod.rs b/src/builders/mod.rs index f08b8ce..3665d7d 100644 --- a/src/builders/mod.rs +++ b/src/builders/mod.rs @@ -1,4 +1,5 @@ use miette::Result; +use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use std::path::PathBuf; @@ -8,7 +9,7 @@ pub mod cargo; use archive::{ArchiveBuilder, ArchiveBuilderConfig}; use cargo::{CargoBuilder, CargoBuilderConfig, CargoDocBuilder, CargoDocBuilderConfig}; -#[derive(Debug, Clone, Deserialize, Serialize)] +#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)] #[serde(tag = "type", rename_all = "snake_case")] pub enum AnyBuilder { /// Creates a `.tar.gz` archive of the source tree, automatically excluding -
modified src/changelog.rs
diff --git a/src/changelog.rs b/src/changelog.rs index 4016251..0da4e7c 100644 --- a/src/changelog.rs +++ b/src/changelog.rs @@ -1,10 +1,11 @@ use std::{collections::HashMap, path::PathBuf}; use miette::{IntoDiagnostic, Result, miette}; +use schemars::JsonSchema; use serde::{Deserialize, Serialize}; /// Configuration for [`ChangelogExtractor`]. -#[derive(Debug, Default, Clone, Deserialize, Serialize)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema)] pub struct ChangelogConfig { /// Directory that contains the `CHANGELOG.md`. /// Defaults to the current working directory. -
modified src/cli.rs
diff --git a/src/cli.rs b/src/cli.rs index 9120feb..9b4655c 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -27,4 +27,10 @@ pub enum CliCommand { BuildAll, /// Dumps the default theme to `.abbaye/theme` so you can inspect and modify it. It will be used afterwards when building the site. DumpTheme, + /// Print a JSON Schema for `abbaye.toml` to stdout. + /// + /// Redirect the output to a file (e.g. `abbaye dump-schema > abbaye.schema.json`) and + /// point your editor or TOML language server at it to get field descriptions and + /// auto-completion while editing `abbaye.toml`. + DumpSchema, } -
modified src/config.rs
diff --git a/src/config.rs b/src/config.rs index a457246..ef0340c 100644 --- a/src/config.rs +++ b/src/config.rs @@ -7,12 +7,14 @@ use figment::{ use miette::{IntoDiagnostic, Result}; use serde::{Deserialize, Serialize}; +use schemars::JsonSchema; + use crate::{ builders::AnyBuilder, changelog::ChangelogConfig, version_extractors::AnyVersionExtractor, }; /// General website metadata. -#[derive(Debug, Clone, Deserialize, Serialize)] +#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)] pub struct SiteConfig { /// Display name of the project, used in page titles and headings. pub name: String, @@ -36,7 +38,7 @@ pub struct SiteConfig { } /// OpenGraph configuration for the website. -#[derive(Debug, Clone, Deserialize, Serialize)] +#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)] pub struct OpenGraphConfig { /// OpenGraph type of the website. It will be used as the `og:type` meta tag. /// Note: by default, the value "website" will be enforced for the version listing page and "article" for the release notes page. @@ -78,7 +80,7 @@ pub struct OpenGraphConfig { /// /// You can learn more about each builder type in the [builders module documentation](crate::builders). /// -#[derive(Debug, Clone, Deserialize, Serialize)] +#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)] pub struct AbbayeConfig { /// Metadata about the site. pub site: SiteConfig, -
modified src/main.rs
diff --git a/src/main.rs b/src/main.rs index 6cdd0c9..2a1fce1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -313,6 +313,13 @@ async fn main() -> Result<()> { cli::CliCommand::BuildAll => { build_all().await?; } + cli::CliCommand::DumpSchema => { + let schema = schemars::schema_for!(config::AbbayeConfig); + println!( + "{}", + serde_json::to_string_pretty(&schema).into_diagnostic()? + ); + } cli::CliCommand::DumpTheme => { let theme_path = PathBuf::from(".abbaye").join("theme"); create_dir_all(&theme_path).await.into_diagnostic()?; -
modified src/version_extractors/cargo.rs
diff --git a/src/version_extractors/cargo.rs b/src/version_extractors/cargo.rs index 06ef7b2..53c6232 100644 --- a/src/version_extractors/cargo.rs +++ b/src/version_extractors/cargo.rs @@ -1,12 +1,13 @@ use std::path::PathBuf; use miette::{IntoDiagnostic, Result, miette}; +use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use super::{VersionExtractor, VersionInfo}; /// Configuration for [`CargoVersion`]. -#[derive(Debug, Default, Clone, Deserialize, Serialize)] +#[derive(Debug, Default, Clone, Deserialize, Serialize, JsonSchema)] pub struct CargoVersionConfig { /// Path to the `Cargo.toml` to read the version from. /// Defaults to `Cargo.toml` in the current working directory. -
modified src/version_extractors/git.rs
diff --git a/src/version_extractors/git.rs b/src/version_extractors/git.rs index cda6364..cb86f78 100644 --- a/src/version_extractors/git.rs +++ b/src/version_extractors/git.rs @@ -1,5 +1,6 @@ use chrono::{DateTime, Utc}; use miette::{IntoDiagnostic, Result, miette}; +use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use super::{VersionExtractor, VersionInfo}; @@ -9,7 +10,7 @@ fn default_dirty_suffix() -> String { } /// Configuration for [`GitVersion`]. -#[derive(Debug, Clone, Deserialize, Serialize)] +#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)] pub struct GitVersionConfig { /// Strip this prefix from the tag name before returning the version. /// For example, `"v"` turns `"v1.2.3"` into `"1.2.3"`. -
modified src/version_extractors/mod.rs
diff --git a/src/version_extractors/mod.rs b/src/version_extractors/mod.rs index e370250..8b1ab61 100644 --- a/src/version_extractors/mod.rs +++ b/src/version_extractors/mod.rs @@ -1,5 +1,6 @@ use chrono::{DateTime, Utc}; use miette::{Result, bail}; +use schemars::JsonSchema; use serde::{Deserialize, Serialize}; pub mod cargo; @@ -32,7 +33,7 @@ pub trait VersionExtractor { } } -#[derive(Debug, Clone, Deserialize, Serialize)] +#[derive(Debug, Clone, Deserialize, Serialize, JsonSchema)] #[serde(tag = "type", rename_all = "snake_case")] pub enum AnyVersionExtractor { /// Reads the version from the `version` field in the `[package]` section