This commit is contained in:
Graham Esau 2021-03-26 23:59:35 +00:00
parent 4c238605be
commit 61d64df57d
7 changed files with 6 additions and 8 deletions

View file

@ -1,6 +1,6 @@
# Changelog # Changelog
## [0.8.2] - **In-dev** ## [0.8.2] - 2021-03-27
### Added: ### Added:
- Enable generating a schema from any serializable value using `schema_for_value!(...)` macro or `SchemaGenerator::root_schema_for_value()`/`SchemaGenerator::into_root_schema_for_value()` methods (https://github.com/GREsau/schemars/pull/75) - Enable generating a schema from any serializable value using `schema_for_value!(...)` macro or `SchemaGenerator::root_schema_for_value()`/`SchemaGenerator::into_root_schema_for_value()` methods (https://github.com/GREsau/schemars/pull/75)
- `#[derive(JsonSchema_repr)]` can be used on C-like enums for generating a serde_repr-compatible schema (https://github.com/GREsau/schemars/pull/76) - `#[derive(JsonSchema_repr)]` can be used on C-like enums for generating a serde_repr-compatible schema (https://github.com/GREsau/schemars/pull/76)

View file

@ -20,7 +20,6 @@ If you want more control over how the schema is generated, you can use the [`gen
See the API documentation for more info on how to use those types for custom schema generation. See the API documentation for more info on how to use those types for custom schema generation.
<!-- UNCOMMMENT FOR 0.8.2:
## Schema from Example Value ## Schema from Example Value
If you want a schema for a type that can't/doesn't implement `JsonSchema`, but does implement `serde::Serialize`, then you can generate a JSON schema from a value of that type using the [`schema_for_value!` macro](https://docs.rs/schemars/latest/schemars/macro.schema_for_value.html). However, this schema will generally be less precise than if the type implemented `JsonSchema` - particularly when it involves enums, since schemars will not make any assumptions about the structure of an enum based on a single variant. If you want a schema for a type that can't/doesn't implement `JsonSchema`, but does implement `serde::Serialize`, then you can generate a JSON schema from a value of that type using the [`schema_for_value!` macro](https://docs.rs/schemars/latest/schemars/macro.schema_for_value.html). However, this schema will generally be less precise than if the type implemented `JsonSchema` - particularly when it involves enums, since schemars will not make any assumptions about the structure of an enum based on a single variant.
@ -28,7 +27,7 @@ If you want a schema for a type that can't/doesn't implement `JsonSchema`, but d
```rust ```rust
let value = MyStruct { foo = 123 }; let value = MyStruct { foo = 123 };
let my_schema = schema_for_value!(value); let my_schema = schema_for_value!(value);
``` --> ```
<!-- TODO: <!-- TODO:
create and link to example create and link to example

View file

@ -26,3 +26,4 @@ Schemars can implement `JsonSchema` on types from several popular crates, enable
- [`uuid`](https://crates.io/crates/uuid) (^0.8) - [`uuid`](https://crates.io/crates/uuid) (^0.8)
- [`smallvec`](https://crates.io/crates/smallvec) (^1.0) - [`smallvec`](https://crates.io/crates/smallvec) (^1.0)
- [`arrayvec`](https://crates.io/crates/arrayvec) (^0.5) - [`arrayvec`](https://crates.io/crates/arrayvec) (^0.5)
- [`url`](https://crates.io/crates/url) (^2.0)

View file

@ -5,7 +5,6 @@ parent: Examples
nav_order: 8 nav_order: 8
summary: >- summary: >-
Generating a schema for with a C-like enum compatible with serde_repr. Generating a schema for with a C-like enum compatible with serde_repr.
nav_exclude: true # schemars 0.8.2 currently unreleased
--- ---
# Serialize Enum as Number (serde_repr Compatibility) # Serialize Enum as Number (serde_repr Compatibility)

View file

@ -5,7 +5,6 @@ parent: Examples
nav_order: 9 nav_order: 9
summary: >- summary: >-
Generating a schema for a serializable value. Generating a schema for a serializable value.
nav_exclude: true # schemars 0.8.2 currently unreleased
--- ---
# Generate Schema from Example Value # Generate Schema from Example Value

View file

@ -3,7 +3,7 @@ name = "schemars"
description = "Generate JSON Schemas from Rust code" description = "Generate JSON Schemas from Rust code"
homepage = "https://graham.cool/schemars/" homepage = "https://graham.cool/schemars/"
repository = "https://github.com/GREsau/schemars" repository = "https://github.com/GREsau/schemars"
version = "0.8.1" version = "0.8.2"
authors = ["Graham Esau <gesau@hotmail.co.uk>"] authors = ["Graham Esau <gesau@hotmail.co.uk>"]
edition = "2018" edition = "2018"
license = "MIT" license = "MIT"
@ -13,7 +13,7 @@ categories = ["encoding"]
build = "build.rs" build = "build.rs"
[dependencies] [dependencies]
schemars_derive = { version = "=0.8.1", optional = true, path = "../schemars_derive" } schemars_derive = { version = "=0.8.2", optional = true, path = "../schemars_derive" }
serde = { version = "1.0", features = ["derive"] } serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0" serde_json = "1.0"
dyn-clone = "1.0" dyn-clone = "1.0"

View file

@ -3,7 +3,7 @@ name = "schemars_derive"
description = "Macros for #[derive(JsonSchema)], for use with schemars" description = "Macros for #[derive(JsonSchema)], for use with schemars"
homepage = "https://graham.cool/schemars/" homepage = "https://graham.cool/schemars/"
repository = "https://github.com/GREsau/schemars" repository = "https://github.com/GREsau/schemars"
version = "0.8.1" version = "0.8.2"
authors = ["Graham Esau <gesau@hotmail.co.uk>"] authors = ["Graham Esau <gesau@hotmail.co.uk>"]
edition = "2018" edition = "2018"
license = "MIT" license = "MIT"