Skip to content

Commit

Permalink
feat: impl JsonTypdef for Url (behind a feature flag)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomkarw committed Feb 3, 2024
1 parent 3170098 commit b5de3e7
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 0 deletions.
67 changes: 67 additions & 0 deletions Cargo.lock

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

4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ documentation = "https://docs.rs/jtd-derive"
categories = ["encoding"]
keywords = ["schema", "codegen", "json"]

[features]
url = []

[dependencies]
jtd-derive-macros = { version = "=0.1.3", path = "macros" }
serde = { version = "1.0.115", features = ["derive"] }
serde_json = "1.0.50"
thiserror = "1.0.3"
url = { version = "2", optional = true }

[dev-dependencies]
trybuild = "1.0.49"
5 changes: 5 additions & 0 deletions src/trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ impl_wrappers! {
std::path => Path => String
}

#[cfg(feature = "url")]
impl_wrappers! {
url => Url => String
}

impl JsonTypedef for std::path::PathBuf {
fn schema(gen: &mut Generator) -> Schema {
gen.sub_schema::<std::path::Path>()
Expand Down

0 comments on commit b5de3e7

Please sign in to comment.