v0.6.1
Fix a compile error that can occur when deriving `JsonSchema` from a project that doesn't reference serde_json
This commit is contained in:
parent
351ff1572a
commit
e151d21d6d
5 changed files with 60 additions and 52 deletions
|
@ -1,5 +1,9 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [0.6.1] - 2019-12-09
|
||||||
|
### Fixed:
|
||||||
|
- Fix a compile error that can occur when deriving `JsonSchema` from a project that doesn't reference serde_json
|
||||||
|
|
||||||
## [0.6.0] - 2019-12-09
|
## [0.6.0] - 2019-12-09
|
||||||
### Added:
|
### Added:
|
||||||
- When deriving `JsonSchema`, the schema's `title` and `description` are now set from `#[doc]` comments (https://github.com/GREsau/schemars/issues/7)
|
- When deriving `JsonSchema`, the schema's `title` and `description` are now set from `#[doc]` comments (https://github.com/GREsau/schemars/issues/7)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name = "schemars"
|
name = "schemars"
|
||||||
description = "Generate JSON Schemas from Rust code"
|
description = "Generate JSON Schemas from Rust code"
|
||||||
repository = "https://github.com/GREsau/schemars"
|
repository = "https://github.com/GREsau/schemars"
|
||||||
version = "0.6.0"
|
version = "0.6.1"
|
||||||
authors = ["Graham Esau <gesau@hotmail.co.uk>"]
|
authors = ["Graham Esau <gesau@hotmail.co.uk>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
@ -12,7 +12,7 @@ categories = ["encoding"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
schemars_derive = { version = "0.6.0", path = "../schemars_derive" }
|
schemars_derive = { version = "=0.6.1", path = "../schemars_derive" }
|
||||||
serde = { version = "1.0", features = ["derive"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
chrono = { version = "0.4", default-features = false, optional = true }
|
chrono = { version = "0.4", default-features = false, optional = true }
|
||||||
|
|
|
@ -195,6 +195,10 @@ pub mod schema;
|
||||||
|
|
||||||
pub use schemars_derive::*;
|
pub use schemars_derive::*;
|
||||||
|
|
||||||
|
// Export serde_json so schemars_derive can use it
|
||||||
|
#[doc(hidden)]
|
||||||
|
pub use serde_json as _serde_json;
|
||||||
|
|
||||||
use schema::Schema;
|
use schema::Schema;
|
||||||
|
|
||||||
/// A type which can be described as a JSON Schema document.
|
/// A type which can be described as a JSON Schema document.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
name = "schemars_derive"
|
name = "schemars_derive"
|
||||||
description = "Macros for #[derive(JsonSchema)], for use with schemars"
|
description = "Macros for #[derive(JsonSchema)], for use with schemars"
|
||||||
repository = "https://github.com/GREsau/schemars"
|
repository = "https://github.com/GREsau/schemars"
|
||||||
version = "0.6.0"
|
version = "0.6.1"
|
||||||
authors = ["Graham Esau <gesau@hotmail.co.uk>"]
|
authors = ["Graham Esau <gesau@hotmail.co.uk>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
|
@ -59,12 +59,12 @@ pub fn set_metadata_on_schema(schema_expr: TokenStream, metadata: &SchemaMetadat
|
||||||
{
|
{
|
||||||
let default = #default;
|
let default = #default;
|
||||||
if !#skip_if(&default) {
|
if !#skip_if(&default) {
|
||||||
metadata.default = serde_json::value::to_value(default).ok();
|
metadata.default = schemars::_serde_json::value::to_value(default).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
(Some(default), None) => setters.push(quote! {
|
(Some(default), None) => setters.push(quote! {
|
||||||
metadata.default = serde_json::value::to_value(#default).ok();
|
metadata.default = schemars::_serde_json::value::to_value(#default).ok();
|
||||||
}),
|
}),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue