From 692958353d564f681b0813954c398f80566bb593 Mon Sep 17 00:00:00 2001 From: Graham Esau Date: Sun, 9 Jun 2024 19:26:40 +0100 Subject: [PATCH] Add `extend` attribute to docs --- docs/1.1-attributes.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/1.1-attributes.md b/docs/1.1-attributes.md index 66e5736..2e6aa66 100644 --- a/docs/1.1-attributes.md +++ b/docs/1.1-attributes.md @@ -48,6 +48,7 @@ TABLE OF CONTENTS - [`example`](#example) - [`deprecated`](#deprecated) - [`crate`](#crate) + - [`extend`](#extend) - [Doc Comments (`doc`)](#doc) @@ -314,6 +315,21 @@ struct Struct { } ``` +

+ +`#[schemars(extend("key" = value))]` + +

+ +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; +``` +

Doc Comments (`#[doc = "..."]`)