Skip to content

Commit

Permalink
deploy: 8ea3025
Browse files Browse the repository at this point in the history
  • Loading branch information
milesj committed Feb 16, 2024
1 parent e07dd0a commit 1fec343
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 6 deletions.
46 changes: 44 additions & 2 deletions print.html
Original file line number Diff line number Diff line change
Expand Up @@ -2356,10 +2356,52 @@ <h2 id="options-1"><a class="header" href="#options-1">Options</a></h2>
});
<span class="boring">}</span></code></pre></pre>
<blockquote>
<p>This type is just a re-export of the
<p>This type also contains all fields from the upstream
<a href="https://docs.rs/schemars/latest/schemars/gen/struct.SchemaSettings.html"><code>SchemaSettings</code></a> type
from <code>schemars</code>. Refer to their documentation for more information.</p>
from the <code>schemars</code> crate. Refer to their documentation for more information.</p>
</blockquote>
<h3 id="markdown-descriptions"><a class="header" href="#markdown-descriptions">Markdown descriptions</a></h3>
<p>By default, the <code>description</code> field in the JSON schema specification is supposed to be a plain text
string, but some tools support markdown through another field called <code>markdownDescription</code>.</p>
<p>To support this pattern, enable the <code>markdown_description</code> option, which will inject the
<code>markdownDescription</code> field if markdown was detected in the <code>description</code> field.</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>JsonSchemaOptions {
// ...
markdown_description: true,
}
<span class="boring">}</span></code></pre></pre>
<blockquote>
<p>This is a non-standard extension to the JSON schema specification.</p>
</blockquote>
<h3 id="required-fields-1"><a class="header" href="#required-fields-1">Required fields</a></h3>
<p>When a struct is rendered, automatically mark all non-<code>Option</code> struct fields as required, and
include them in the JSON schema
<a href="https://json-schema.org/understanding-json-schema/reference/object#required"><code>required</code> field</a>.
This is enabled by default.</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>JsonSchemaOptions {
// ...
mark_struct_fields_required: false,
}
<span class="boring">}</span></code></pre></pre>
<h3 id="field-titles"><a class="header" href="#field-titles">Field titles</a></h3>
<p>The JSON schema specification supports a
<a href="https://json-schema.org/understanding-json-schema/reference/annotations"><code>title</code> annotation</a> for
each field, which is a human-readable string. By default this is the name of the Rust struct, enum,
or type field.</p>
<p>But depending on the tool that consumes the schema, this may not be the best representation. As an
alternative, the <code>set_field_name_as_title</code> option can be enabled to use the field name itself as the
<code>title</code>.</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>JsonSchemaOptions {
// ...
set_field_name_as_title: true,
}
<span class="boring">}</span></code></pre></pre>
<div style="break-before: page; page-break-before: always;"></div><h1 id="typescript-types"><a class="header" href="#typescript-types">TypeScript types</a></h1>
<blockquote>
<p>Requires the <code>typescript</code> Cargo feature.</p>
Expand Down
46 changes: 44 additions & 2 deletions schema/generator/json-schema.html
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,52 @@ <h2 id="options"><a class="header" href="#options">Options</a></h2>
});
<span class="boring">}</span></code></pre></pre>
<blockquote>
<p>This type is just a re-export of the
<p>This type also contains all fields from the upstream
<a href="https://docs.rs/schemars/latest/schemars/gen/struct.SchemaSettings.html"><code>SchemaSettings</code></a> type
from <code>schemars</code>. Refer to their documentation for more information.</p>
from the <code>schemars</code> crate. Refer to their documentation for more information.</p>
</blockquote>
<h3 id="markdown-descriptions"><a class="header" href="#markdown-descriptions">Markdown descriptions</a></h3>
<p>By default, the <code>description</code> field in the JSON schema specification is supposed to be a plain text
string, but some tools support markdown through another field called <code>markdownDescription</code>.</p>
<p>To support this pattern, enable the <code>markdown_description</code> option, which will inject the
<code>markdownDescription</code> field if markdown was detected in the <code>description</code> field.</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>JsonSchemaOptions {
// ...
markdown_description: true,
}
<span class="boring">}</span></code></pre></pre>
<blockquote>
<p>This is a non-standard extension to the JSON schema specification.</p>
</blockquote>
<h3 id="required-fields"><a class="header" href="#required-fields">Required fields</a></h3>
<p>When a struct is rendered, automatically mark all non-<code>Option</code> struct fields as required, and
include them in the JSON schema
<a href="https://json-schema.org/understanding-json-schema/reference/object#required"><code>required</code> field</a>.
This is enabled by default.</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>JsonSchemaOptions {
// ...
mark_struct_fields_required: false,
}
<span class="boring">}</span></code></pre></pre>
<h3 id="field-titles"><a class="header" href="#field-titles">Field titles</a></h3>
<p>The JSON schema specification supports a
<a href="https://json-schema.org/understanding-json-schema/reference/annotations"><code>title</code> annotation</a> for
each field, which is a human-readable string. By default this is the name of the Rust struct, enum,
or type field.</p>
<p>But depending on the tool that consumes the schema, this may not be the best representation. As an
alternative, the <code>set_field_name_as_title</code> option can be enabled to use the field name itself as the
<code>title</code>.</p>
<pre><pre class="playground"><code class="language-rust"><span class="boring">#![allow(unused)]
</span><span class="boring">fn main() {
</span>JsonSchemaOptions {
// ...
set_field_name_as_title: true,
}
<span class="boring">}</span></code></pre></pre>

</main>

Expand Down
2 changes: 1 addition & 1 deletion searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion searchindex.json

Large diffs are not rendered by default.

0 comments on commit 1fec343

Please sign in to comment.