Add separate docs for v0.8/v1
This commit is contained in:
parent
3150f98fc8
commit
d511d447f7
61 changed files with 1620 additions and 58 deletions
|
@ -1,5 +1,4 @@
|
|||
---
|
||||
layout: default
|
||||
title: Deriving JsonSchema
|
||||
parent: Examples
|
||||
nav_order: 1
|
||||
|
|
|
@ -1,14 +1,13 @@
|
|||
---
|
||||
layout: default
|
||||
title: Using Serde Attributes
|
||||
parent: Examples
|
||||
nav_order: 2
|
||||
summary: 'Deriving JsonSchema on types that use #[serde] attributes to customise serialization behaviour.'
|
||||
summary: "Deriving JsonSchema on types that use #[serde] attributes to customise serialization behaviour."
|
||||
---
|
||||
|
||||
# Using Serde Attributes
|
||||
|
||||
One of the main aims of this library is compatibility with [Serde](https://github.com/serde-rs/serde). Any generated schema *should* match how [serde_json](https://github.com/serde-rs/json) would serialize/deserialize to/from JSON. To support this, Schemars will check for any `#[serde(...)]` attributes on types that derive `JsonSchema`, and adjust the generated schema accordingly.
|
||||
One of the main aims of this library is compatibility with [Serde](https://github.com/serde-rs/serde). Any generated schema _should_ match how [serde_json](https://github.com/serde-rs/json) would serialize/deserialize to/from JSON. To support this, Schemars will check for any `#[serde(...)]` attributes on types that derive `JsonSchema`, and adjust the generated schema accordingly.
|
||||
|
||||
The list of supported `#[serde]` attributes are [documented here]({{ site.baseurl }}{% link 1.1-attributes.md %}#supported-serde-attributes).
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
---
|
||||
layout: default
|
||||
title: Using Schemars Attributes
|
||||
parent: Examples
|
||||
nav_order: 3
|
||||
summary: 'Deriving JsonSchema on types that use #[schemars] attributes to customise serialization behaviour.'
|
||||
summary: "Deriving JsonSchema on types that use #[schemars] attributes to customise serialization behaviour."
|
||||
---
|
||||
|
||||
# Using Serde Attributes
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
---
|
||||
layout: default
|
||||
title: Custom Schema Settings
|
||||
parent: Examples
|
||||
nav_order: 4
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
---
|
||||
layout: default
|
||||
title: Derive for Remote Crate
|
||||
parent: Examples
|
||||
nav_order: 5
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
---
|
||||
layout: default
|
||||
title: Doc Comments
|
||||
parent: Examples
|
||||
nav_order: 6
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
---
|
||||
layout: default
|
||||
title: Custom Serialization
|
||||
parent: Examples
|
||||
nav_order: 7
|
||||
|
@ -13,7 +12,7 @@ summary: >-
|
|||
|
||||
Serde allows you to change how a field is (de)serialized by setting a [`#[serde(with = "path")]`](https://serde.rs/field-attrs.html#with) attribute, where `$path::serialize` and `$path::deserialize` must be functions with the correct signature. Schemars supports the same attribute, but `path` must be a type implementing `JsonSchema`.
|
||||
|
||||
In order to derive `JsonSchema` on a type which includes a `#[serde(with = "path")]` attribute where `path` is not a type implementing `JsonSchema`, you'll need to override it with a suitable `#[schemars(with = "Type")]` or `#[schemars(schema_with = "path")]` attribute.
|
||||
In order to derive `JsonSchema` on a type which includes a `#[serde(with = "path")]` attribute where `path` is not a type implementing `JsonSchema`, you'll need to override it with a suitable `#[schemars(with = "Type")]` or `#[schemars(schema_with = "path")]` attribute.
|
||||
|
||||
{% include example.md name="custom_serialization" %}
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
---
|
||||
layout: default
|
||||
title: Serialize Enum as Number (serde_repr)
|
||||
parent: Examples
|
||||
nav_order: 8
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
---
|
||||
layout: default
|
||||
title: Generate Schema from Example Value
|
||||
parent: Examples
|
||||
nav_order: 9
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue