Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new: Add serde_yml support. #144

Merged
merged 5 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Changelog

## Unreleased

#### 🚀 Updates

- Added `yml` and `serde_yml` features, which uses `serde_yml` for parsing instead of `serde_yaml`,
as the latter has been deprecated for sometime.

#### ⚙️ Internal

- Updated `garde` (validation) to v0.22.
- Updated dependencies.

## 0.17.9

#### 🚀 Updates
Expand Down
61 changes: 47 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ members = ["crates/*"]

[workspace.dependencies]
chrono = "0.4.39"
indexmap = "2.7.0"
indexmap = "2.7.1"
miette = "7.4.0"
regex = "1.11.1"
relative-path = "1.9.3"
reqwest = { version = "0.12.12", default-features = false }
rpkl = "0.3.5"
rpkl = "0.4.0"
rust_decimal = "1.36.0"
semver = "1.0.24"
semver = "1.0.25"
serde = { version = "1.0.217", features = ["derive"] }
serde_json = "1.0.135"
serde_json = "1.0.137"
serde_yaml = "0.9.34"
serde_yml = "0.0.12"
starbase_sandbox = "0.8.1"
toml = "0.8.19"
tracing = "0.1.41"
Expand Down
6 changes: 4 additions & 2 deletions book/src/config/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ Schematic is powered entirely by [serde](https://serde.rs), and supports the fol
- JSON - Uses `serde_json` and requires the `json` Cargo feature.
- Pkl (experimental) - Uses `rpkl` and requires the `pkl` Cargo feature.
- TOML - Uses `toml` and requires the `toml` Cargo feature.
- YAML - Uses `serde_yaml` and requires the `yaml` Cargo feature.
- YAML - Uses `serde_yml` and requires the `yml` Cargo feature.
- YAML (deprecated) - Uses `serde_yaml` and requires the `yaml` Cargo feature.

## Cargo features

Expand All @@ -144,4 +145,5 @@ The following Cargo features are available:
- `tracing` - Wrap generated code in tracing instrumentations.
- `url` - Enables loading, extending, and parsing configs from URLs.
- `validate` (default) - Enables setting value validation.
- `yaml` - Enables YAML.
- `yaml` - Enables YAML (deprecated).
- `yml` - Enables YAML.
7 changes: 7 additions & 0 deletions book/src/schema/external.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ Implements schemas for `Value`, `Number`, and `Map` from the
Implements schemas for `Value`, `Number`, and `Mapping` from the
[serde_yaml](https://crates.io/crates/serde_yaml) crate.

## serde_yml

> Requires the `type_serde_yml` Cargo feature.

Implements schemas for `Value`, `Number`, and `Mapping` from the
[serde_yml](https://crates.io/crates/serde_yml) crate.

## toml

> Requires the `type_serde_toml` Cargo feature.
Expand Down
9 changes: 6 additions & 3 deletions crates/schematic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ thiserror = "2.0.3"
tracing = { workspace = true }

# config
garde = { version = "0.21.0", default-features = false, optional = true, features = [
garde = { version = "0.22.0", default-features = false, optional = true, features = [
"regex",
] }
serde = { workspace = true }
Expand All @@ -52,6 +52,7 @@ toml = { workspace = true, optional = true }

# yaml
serde_yaml = { workspace = true, optional = true }
serde_yml = { workspace = true, optional = true }

# url
reqwest = { workspace = true, optional = true, features = ["blocking"] }
Expand All @@ -78,6 +79,7 @@ json = ["dep:serde_json", "schematic_types/serde_json"]
pkl = ["dep:rpkl", "schematic_types/serde_rpkl"]
toml = ["dep:toml", "schematic_types/serde_toml"]
yaml = ["dep:serde_yaml", "schematic_types/serde_yaml"]
yml = ["dep:serde_yml", "schematic_types/serde_yml"]

# Renderers
renderer_json_schema = ["json", "schema", "dep:markdown", "dep:schemars"]
Expand Down Expand Up @@ -122,14 +124,15 @@ schematic = { path = ".", features = [
"validate",
"validate_email",
"validate_url",
"yaml",
# "yaml",
"yml",
] }
reqwest = { workspace = true, features = [
"blocking",
"rustls-tls-native-roots",
] }
serial_test = "3.2.0"
similar = "2.6.0"
similar = "2.7.0"
starbase_sandbox = { workspace = true }

# Types
Expand Down
4 changes: 2 additions & 2 deletions crates/schematic/src/config/formats/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mod json;
mod pkl;
#[cfg(feature = "toml")]
mod toml;
#[cfg(feature = "yaml")]
#[cfg(any(feature = "yaml", feature = "yml"))]
mod yaml;

use super::error::ConfigError;
Expand Down Expand Up @@ -47,7 +47,7 @@ impl Format {
#[cfg(feature = "toml")]
Format::Toml => toml::parse(location, content),

#[cfg(feature = "yaml")]
#[cfg(any(feature = "yaml", feature = "yml"))]
Format::Yaml => yaml::parse(location, content),
}
}
Expand Down
Loading
Loading