Update docs for v1
This commit is contained in:
parent
692958353d
commit
91ee3f915c
5 changed files with 34 additions and 27 deletions
|
@ -12,13 +12,20 @@ The easiest way to generate a schema for a type that implements is to use the [`
|
|||
let my_schema = schema_for!(MyStruct);
|
||||
```
|
||||
|
||||
This will create a schema that conforms to [JSON Schema Draft 7](https://json-schema.org/specification-links.html#draft-7), but this is liable to change in a future version of Schemars if support for other JSON Schema versions is added.
|
||||
This will create a schema that conforms to [JSON Schema 2020-12](https://json-schema.org/specification-links#2020-12), but this is liable to change in a future version of Schemars if support for other JSON Schema versions is added.
|
||||
|
||||
If you want more control over how the schema is generated, you can use the [`gen` module](https://docs.rs/schemars/latest/schemars/gen/). There are two main types in this module:
|
||||
|
||||
- [`SchemaSettings`](https://docs.rs/schemars/latest/schemars/gen/struct.SchemaSettings.html), which defines what JSON Schema features should be used when generating schemas (for example, how `Option`s should be represented).
|
||||
- [`SchemaGenerator`](https://docs.rs/schemars/latest/schemars/gen/struct.SchemaGenerator.html), which manages the generation of a schema document.
|
||||
|
||||
For example, to generate a schema that conforms to [JSON Schema Draft 7](https://json-schema.org/specification-links.html#draft-7):
|
||||
|
||||
```rust
|
||||
let generator = SchemaSettings::draft07().into_generator();
|
||||
let my_schema = generator.into_root_schema_for::<MyStruct>();
|
||||
```
|
||||
|
||||
See the API documentation for more info on how to use those types for custom schema generation.
|
||||
|
||||
## Schema from Example Value
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue