Clean up README
This commit is contained in:
parent
fba1753bba
commit
5ede1c1c3a
1 changed files with 4 additions and 11 deletions
15
README.md
15
README.md
|
@ -9,7 +9,7 @@ Work in progress!
|
||||||
|
|
||||||
## Basic Usage
|
## Basic Usage
|
||||||
|
|
||||||
If you don't really care about the specifics, the easiest way to generate a JSON schema for you types is to `#[derive(JsonSchema)]` and use the `schema_for!` macro:
|
If you don't really care about the specifics, the easiest way to generate a JSON schema for your types is to `#[derive(JsonSchema)]` and use the `schema_for!` macro. All fields of the type must also implement `JsonSchema` - Schemars implements this for many standard library types.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use schemars::{schema_for, JsonSchema};
|
use schemars::{schema_for, JsonSchema};
|
||||||
|
@ -93,7 +93,7 @@ fn main() {
|
||||||
|
|
||||||
### Serde Compatibility
|
### Serde Compatibility
|
||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
use schemars::{schema_for, JsonSchema};
|
use schemars::{schema_for, JsonSchema};
|
||||||
|
@ -170,18 +170,11 @@ fn main() {
|
||||||
```
|
```
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
`#[serde(...)]` attributes can be overriden using `#[schemars(...)]` attributes, which behave identically (e.g. `#[schemars(rename_all = "camelCase")]`). You may find this useful if you want to change the generated schema without affecting Serde, or if you're just not using Serde.
|
`#[serde(...)]` attributes can be overriden using `#[schemars(...)]` attributes, which behave identically (e.g. `#[schemars(rename_all = "camelCase")]`). You may find this useful if you want to change the generated schema without affecting Serde's behaviour, or if you're just not using Serde.
|
||||||
|
|
||||||
## Feature Flags
|
## Feature Flags
|
||||||
- `chrono` - implements `JsonSchema` for all [Chrono](https://github.com/chronotope/chrono) types which are serializable by Serde.
|
- `chrono` - implements `JsonSchema` for all [Chrono](https://github.com/chronotope/chrono) types which are serializable by Serde.
|
||||||
- `derive_json_schema` - implements `JsonSchema` for Schemars types themselves
|
- `derive_json_schema` - implements `JsonSchema` for Schemars types themselves
|
||||||
|
|
||||||
## Customizing Schema Generation
|
## Customizing Schema Generation
|
||||||
TODO document!
|
TODO document this!
|
||||||
|
|
||||||
## TODO
|
|
||||||
- Documentation
|
|
||||||
- Benchmark/optimise memory usage and allocations
|
|
||||||
- Note to self: https://crates.io/crates/graphannis-malloc_size_of looks useful
|
|
||||||
- Implement `JsonSchema` for more standard library types
|
|
||||||
- Allow deriving `JsonSchema` for adjacent tagged enums
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue