Add extend attribute to docs

This commit is contained in:
Graham Esau 2024-06-09 19:26:40 +01:00
parent d511d447f7
commit 692958353d

View file

@ -48,6 +48,7 @@ TABLE OF CONTENTS
- [`example`](#example) - [`example`](#example)
- [`deprecated`](#deprecated) - [`deprecated`](#deprecated)
- [`crate`](#crate) - [`crate`](#crate)
- [`extend`](#extend)
- [Doc Comments (`doc`)](#doc) - [Doc Comments (`doc`)](#doc)
</details> </details>
@ -314,6 +315,21 @@ struct Struct {
} }
``` ```
<h3 id="extend">
`#[schemars(extend("key" = value))]`
</h3>
Set on a container, variant or field to add properties (or replace existing properties) in a generated schema. This can contain multiple key/value pairs and/or be specified multiple times, as long as each key is unique.
The key must be a quoted string, and the value can be any expression that produces a type implementing `serde::Serialize`. The value can also be a JSON literal which can interpolate other values.
```plaintext
#[schemars(extend("simple" = "string value", "complex" = {"array": [1, 2, 3]}))]
struct Struct;
```
<h3 id="doc"> <h3 id="doc">
Doc Comments (`#[doc = "..."]`) Doc Comments (`#[doc = "..."]`)