Add examples to docs
This commit is contained in:
parent
d67abbdbb1
commit
f387a0ec56
11 changed files with 223 additions and 17 deletions
13
docs/examples/1-derive_jsonschema.md
Normal file
13
docs/examples/1-derive_jsonschema.md
Normal file
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
layout: default
|
||||
title: Deriving JsonSchema
|
||||
parent: Examples
|
||||
nav_order: 1
|
||||
summary: Deriving JsonSchema on a struct and enum.
|
||||
---
|
||||
|
||||
# Deriving JsonSchema
|
||||
|
||||
This is the simplest usage of Schemars. Both types are made to derive `JsonSchema`, and the `schema_for!` macro is used to generate the schema itself.
|
||||
|
||||
{% include example.md name="main" %}
|
15
docs/examples/2-serde_attrs.md
Normal file
15
docs/examples/2-serde_attrs.md
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
layout: default
|
||||
title: Using Serde Attributes
|
||||
parent: Examples
|
||||
nav_order: 2
|
||||
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.
|
||||
|
||||
The list of supported `#[serde]` attributes are [documented here]({{ site.baseurl }}/deriving/attributes/#supported-serde-attributes).
|
||||
|
||||
{% include example.md name="serde_attrs" %}
|
|
@ -1,9 +0,0 @@
|
|||
---
|
||||
layout: default
|
||||
title: Example 1
|
||||
parent: Examples
|
||||
nav_order: 1
|
||||
summary: blah blah blahhh
|
||||
---
|
||||
|
||||
# Examples 1: A Meta-Example
|
|
@ -1,8 +0,0 @@
|
|||
---
|
||||
layout: default
|
||||
title: Example 2
|
||||
parent: Examples
|
||||
nav_order: 2
|
||||
---
|
||||
|
||||
# Examples 2: Another Meta-Example
|
Loading…
Add table
Add a link
Reference in a new issue