Add example for schemars attributes
This commit is contained in:
parent
601fc3aaad
commit
b11536e527
7 changed files with 175 additions and 2 deletions
|
@ -10,6 +10,6 @@ summary: 'Deriving JsonSchema on types that use #[serde] attributes to customise
|
|||
|
||||
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 }}/deriving/attributes/#supported-serde-attributes).
|
||||
The list of supported `#[serde]` attributes are [documented here]({{ site.baseurl }}{% link 1.1-attributes.md %}#supported-serde-attributes).
|
||||
|
||||
{% include example.md name="serde_attrs" %}
|
||||
|
|
13
docs/examples/3-schemars_attrs.md
Normal file
13
docs/examples/3-schemars_attrs.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
layout: default
|
||||
title: Using Schemars Attributes
|
||||
parent: Examples
|
||||
nav_order: 3
|
||||
summary: 'Deriving JsonSchema on types that use #[schemars] attributes to customise serialization behaviour.'
|
||||
---
|
||||
|
||||
# Using Serde Attributes
|
||||
|
||||
`#[serde(...)]` attributes can be overriden (or replaced) with `#[schemars(...)]` attributes, which behave identically. You may find this useful if you want to change the generated schema without affecting Serde's behaviour, or if you're just not using Serde.
|
||||
|
||||
{% include example.md name="schemars_attrs" %}
|
|
@ -2,7 +2,7 @@
|
|||
layout: default
|
||||
title: Custom Schema Settings
|
||||
parent: Examples
|
||||
nav_order: 3
|
||||
nav_order: 4
|
||||
summary: Generating a schema using custom settings which changes how Option<T> is handled.
|
||||
---
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue