Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ while the schema types have been updated to be more flexible and composable.

##### Schema

- Updated `schemars` to v1, which replaces its typed schema model with plain JSON. This reshapes
`JsonSchemaOptions`:
- `visitors: Vec<Box<dyn GenVisitor>>` is now `transforms: Vec<Box<dyn GenTransform>>`.
- `option_nullable` and `option_add_null_type` were removed. Schemars no longer has them, and this
renderer never read them.
- `definitions_path` keeps its meaning as the `$ref` prefix, and is no longer inherited from
schemars, whose field of that name is now a JSON pointer.
- `JsonSchemaRenderer` implements `SchemaRenderer<schemars::Schema>` rather than
`SchemaRenderer<schemars::schema::Schema>`.
- Changed a `$ref` with no sibling keys to render on its own, instead of inside a single-element
`allOf`. The two are equivalent, and a `$ref` that does have siblings is still wrapped.
- Changed `SchemaType::Reference` from a newtype into a struct variant. Serde is unable to
internally tag a newtype whose value isn't a map, so any schema containing a reference (which is
how cycles are represented) previously failed to serialize.
Expand Down
41 changes: 31 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 7 additions & 3 deletions book/src/schema/generator/json-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,13 @@ JsonSchemaRenderer::new(JsonSchemaOptions {
});
```

> This type also contains all fields from the upstream
> [`SchemaSettings`](https://docs.rs/schemars/latest/schemars/gen/struct.SchemaSettings.html) type
> from the `schemars` crate. Refer to their documentation for more information.
> This type also carries some fields from the upstream
> [`SchemaSettings`](https://docs.rs/schemars/latest/schemars/generate/struct.SchemaSettings.html)
> type in the `schemars` crate — `meta_schema`, `transforms`, and `inline_subschemas`. Refer to
> their documentation for more information.

> `definitions_path` is the prefix each `$ref` is built from, such as `#/definitions/`. Schemars
> models its own field of that name as a JSON pointer instead, so the two are not interchangeable.

### Markdown descriptions

Expand Down
4 changes: 2 additions & 2 deletions crates/schematic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ serde_json = { workspace = true, optional = true, features = [

# json schema
markdown = { version = "1.0.0", optional = true }
schemars = { version = "0.8.22", optional = true, default-features = false }
schemars = { version = "1.2.2", optional = true, default-features = false }

# pkl
rpkl = { workspace = true, optional = true }
Expand Down Expand Up @@ -144,7 +144,7 @@ schematic = { path = ".", features = [
serial_test = "4.0.1"
# Only to prove loading works from inside an async runtime
tokio = { version = "1.53.1", features = ["macros", "rt"] }
similar = "3.1.2"
similar = "3.2.0"
starbase_sandbox = { workspace = true }
strip-ansi-escapes = "0.2.1"
derive_more = { version = "2.1.1", features = ["try_into", "as_ref"] }
Expand Down
Loading
Loading