Update MSRV to 1.56
This commit is contained in:
parent
386e3d7f5a
commit
e0495c0c87
6 changed files with 111 additions and 36 deletions
9
.github/workflows/ci.yml
vendored
9
.github/workflows/ci.yml
vendored
|
@ -7,16 +7,16 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
# work-around https://github.com/rust-lang/cargo/issues/10303
|
# work-around https://github.com/rust-lang/cargo/issues/10303
|
||||||
CARGO_NET_GIT_FETCH_WITH_CLI: ${{ matrix.rust == '1.45.0' }}
|
CARGO_NET_GIT_FETCH_WITH_CLI: ${{ matrix.rust == '1.56.0' }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
rust:
|
rust:
|
||||||
- 1.45.0
|
- 1.56.0
|
||||||
- stable
|
- stable
|
||||||
- beta
|
- beta
|
||||||
- nightly
|
- nightly
|
||||||
include:
|
include:
|
||||||
- rust: 1.45.0
|
- rust: 1.56.0
|
||||||
test_features: "--features impl_json_schema"
|
test_features: "--features impl_json_schema"
|
||||||
allow_failure: false
|
allow_failure: false
|
||||||
- rust: stable
|
- rust: stable
|
||||||
|
@ -36,9 +36,6 @@ jobs:
|
||||||
profile: minimal
|
profile: minimal
|
||||||
toolchain: ${{ matrix.rust }}
|
toolchain: ${{ matrix.rust }}
|
||||||
override: true
|
override: true
|
||||||
- if: matrix.rust == '1.45.0'
|
|
||||||
# work-around https://github.com/serde-rs/serde/issues/2255 and similar crate/rustc compatibility issues
|
|
||||||
run: cargo update -p serde --precise 1.0.142 && cargo update -p once_cell --precise 1.10.0 && cargo update -p pretty_assertions --precise 1.2.1 && cargo update -p trybuild --precise 1.0.64
|
|
||||||
- name: Check with no feature flags
|
- name: Check with no feature flags
|
||||||
run: cargo check --verbose --no-default-features
|
run: cargo check --verbose --no-default-features
|
||||||
continue-on-error: ${{ matrix.allow_failure }}
|
continue-on-error: ${{ matrix.allow_failure }}
|
||||||
|
|
100
CHANGELOG.md
100
CHANGELOG.md
|
@ -1,90 +1,128 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [0.8.13] - _in-dev_
|
||||||
|
|
||||||
|
### Changed:
|
||||||
|
|
||||||
|
- Minimum supported rust version is now 1.56.0
|
||||||
|
|
||||||
## [0.8.12] - 2023-02-26
|
## [0.8.12] - 2023-02-26
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- Implement `JsonSchema` for `smol_str::SmolStr` (https://github.com/GREsau/schemars/pull/72)
|
- Implement `JsonSchema` for `smol_str::SmolStr` (https://github.com/GREsau/schemars/pull/72)
|
||||||
|
|
||||||
### Changed:
|
### Changed:
|
||||||
|
|
||||||
- Change `serde_json` dependency min version to 1.0.25 (was 1.0.0) (https://github.com/GREsau/schemars/pull/192)
|
- Change `serde_json` dependency min version to 1.0.25 (was 1.0.0) (https://github.com/GREsau/schemars/pull/192)
|
||||||
|
|
||||||
## [0.8.11] - 2022-10-02
|
## [0.8.11] - 2022-10-02
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- Replace auto-inferred trait bounds with bounds specified in `#[schemars(bound = "...")]` attribute
|
- Replace auto-inferred trait bounds with bounds specified in `#[schemars(bound = "...")]` attribute
|
||||||
|
|
||||||
### Changed:
|
### Changed:
|
||||||
|
|
||||||
- Derived `JsonSchema` now respects attributes on unit enum variants (https://github.com/GREsau/schemars/pull/152)
|
- Derived `JsonSchema` now respects attributes on unit enum variants (https://github.com/GREsau/schemars/pull/152)
|
||||||
- Minimum supported rust version is now 1.45.0
|
- Minimum supported rust version is now 1.45.0
|
||||||
|
|
||||||
## [0.8.10] - 2022-05-17
|
## [0.8.10] - 2022-05-17
|
||||||
|
|
||||||
- Undo "Support generic default values in default attributes (https://github.com/GREsau/schemars/pull/83)" as it inadvertently introduced a breaking change (https://github.com/GREsau/schemars/issues/144)
|
- Undo "Support generic default values in default attributes (https://github.com/GREsau/schemars/pull/83)" as it inadvertently introduced a breaking change (https://github.com/GREsau/schemars/issues/144)
|
||||||
|
|
||||||
## [0.8.9] - 2022-05-16
|
## [0.8.9] - 2022-05-16
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- ~~Support generic default values in `default` attributes (https://github.com/GREsau/schemars/pull/83)~~
|
- ~~Support generic default values in `default` attributes (https://github.com/GREsau/schemars/pull/83)~~
|
||||||
- ⚠️ **This inadvertently introduced a breaking change and was removed in 0.8.10**
|
- ⚠️ **This inadvertently introduced a breaking change and was removed in 0.8.10**
|
||||||
- Add missing MIT licence text for usage of code from regex_syntax crate (https://github.com/GREsau/schemars/pull/132)
|
- Add missing MIT licence text for usage of code from regex_syntax crate (https://github.com/GREsau/schemars/pull/132)
|
||||||
- Support uuid v1 and arrayvec 0.7 via feature flags `uuid1` and `arrayvec07` (https://github.com/GREsau/schemars/pull/142)
|
- Support uuid v1 and arrayvec 0.7 via feature flags `uuid1` and `arrayvec07` (https://github.com/GREsau/schemars/pull/142)
|
||||||
- This also adds `uuid08` and `arrayvec05` feature flags for the previously supported versions of these crates. The existing `uuid` and `arrayvec` flags are still supported for backward-compatibility, but they are **deprecated**.
|
- This also adds `uuid08` and `arrayvec05` feature flags for the previously supported versions of these crates. The existing `uuid` and `arrayvec` flags are still supported for backward-compatibility, but they are **deprecated**.
|
||||||
- Similarly, `indexmap1` feature flag is added, and `indexmap` flag is **deprecated**.
|
- Similarly, `indexmap1` feature flag is added, and `indexmap` flag is **deprecated**.
|
||||||
|
|
||||||
## [0.8.8] - 2021-11-25
|
## [0.8.8] - 2021-11-25
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- Implement `JsonSchema` for types from `rust_decimal` and `bigdecimal` crates (https://github.com/GREsau/schemars/pull/101)
|
- Implement `JsonSchema` for types from `rust_decimal` and `bigdecimal` crates (https://github.com/GREsau/schemars/pull/101)
|
||||||
|
|
||||||
### Fixed:
|
### Fixed:
|
||||||
|
|
||||||
- Fixes for internally tagged enums and flattening additional_properties (https://github.com/GREsau/schemars/pull/113)
|
- Fixes for internally tagged enums and flattening additional_properties (https://github.com/GREsau/schemars/pull/113)
|
||||||
|
|
||||||
## [0.8.7] - 2021-11-14
|
## [0.8.7] - 2021-11-14
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- Implement `JsonSchema` for `EnumSet` (https://github.com/GREsau/schemars/pull/92)
|
- Implement `JsonSchema` for `EnumSet` (https://github.com/GREsau/schemars/pull/92)
|
||||||
|
|
||||||
### Fixed:
|
### Fixed:
|
||||||
|
|
||||||
- Do not cause compile error when using a default value that doesn't implement `Serialize` (https://github.com/GREsau/schemars/issues/115)
|
- Do not cause compile error when using a default value that doesn't implement `Serialize` (https://github.com/GREsau/schemars/issues/115)
|
||||||
|
|
||||||
## [0.8.6] - 2021-09-26
|
## [0.8.6] - 2021-09-26
|
||||||
|
|
||||||
### Changed:
|
### Changed:
|
||||||
|
|
||||||
- Use `oneOf` instead of `anyOf` for enums when possible (https://github.com/GREsau/schemars/issues/108)
|
- Use `oneOf` instead of `anyOf` for enums when possible (https://github.com/GREsau/schemars/issues/108)
|
||||||
|
|
||||||
## [0.8.5] - 2021-09-20
|
## [0.8.5] - 2021-09-20
|
||||||
|
|
||||||
### Fixed:
|
### Fixed:
|
||||||
|
|
||||||
- Allow fields with plain `#[validate]` attributes (https://github.com/GREsau/schemars/issues/109)
|
- Allow fields with plain `#[validate]` attributes (https://github.com/GREsau/schemars/issues/109)
|
||||||
|
|
||||||
## [0.8.4] - 2021-09-19
|
## [0.8.4] - 2021-09-19
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- `#[schemars(schema_with = "...")]` attribute can now be set on enum variants.
|
- `#[schemars(schema_with = "...")]` attribute can now be set on enum variants.
|
||||||
- Deriving JsonSchema will now take into account `#[validate(...)]` attributes, compatible with the [validator](https://github.com/Keats/validator) crate (https://github.com/GREsau/schemars/pull/78)
|
- Deriving JsonSchema will now take into account `#[validate(...)]` attributes, compatible with the [validator](https://github.com/Keats/validator) crate (https://github.com/GREsau/schemars/pull/78)
|
||||||
|
|
||||||
## [0.8.3] - 2021-04-05
|
## [0.8.3] - 2021-04-05
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- Support for `#[schemars(crate = "...")]` attribute to allow deriving JsonSchema when the schemars crate is aliased to a different name (https://github.com/GREsau/schemars/pull/55 / https://github.com/GREsau/schemars/pull/80)
|
- Support for `#[schemars(crate = "...")]` attribute to allow deriving JsonSchema when the schemars crate is aliased to a different name (https://github.com/GREsau/schemars/pull/55 / https://github.com/GREsau/schemars/pull/80)
|
||||||
- Implement `JsonSchema` for `bytes::Bytes` and `bytes::BytesMut` (https://github.com/GREsau/schemars/pull/68)
|
- Implement `JsonSchema` for `bytes::Bytes` and `bytes::BytesMut` (https://github.com/GREsau/schemars/pull/68)
|
||||||
|
|
||||||
### Fixed:
|
### Fixed:
|
||||||
|
|
||||||
- Fix deriving JsonSchema on types defined inside macros (https://github.com/GREsau/schemars/issues/59 / https://github.com/GREsau/schemars/issues/66 / https://github.com/GREsau/schemars/pull/79)
|
- Fix deriving JsonSchema on types defined inside macros (https://github.com/GREsau/schemars/issues/59 / https://github.com/GREsau/schemars/issues/66 / https://github.com/GREsau/schemars/pull/79)
|
||||||
|
|
||||||
## [0.8.2] - 2021-03-27
|
## [0.8.2] - 2021-03-27
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- Enable generating a schema from any serializable value using `schema_for_value!(...)` macro or `SchemaGenerator::root_schema_for_value()`/`SchemaGenerator::into_root_schema_for_value()` methods (https://github.com/GREsau/schemars/pull/75)
|
- Enable generating a schema from any serializable value using `schema_for_value!(...)` macro or `SchemaGenerator::root_schema_for_value()`/`SchemaGenerator::into_root_schema_for_value()` methods (https://github.com/GREsau/schemars/pull/75)
|
||||||
- `#[derive(JsonSchema_repr)]` can be used on C-like enums for generating a serde_repr-compatible schema (https://github.com/GREsau/schemars/pull/76)
|
- `#[derive(JsonSchema_repr)]` can be used on C-like enums for generating a serde_repr-compatible schema (https://github.com/GREsau/schemars/pull/76)
|
||||||
- Implement `JsonSchema` for `url::Url` (https://github.com/GREsau/schemars/pull/63)
|
- Implement `JsonSchema` for `url::Url` (https://github.com/GREsau/schemars/pull/63)
|
||||||
|
|
||||||
## [0.8.1] - 2021-03-23
|
## [0.8.1] - 2021-03-23
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- `SchemaGenerator::definitions_mut()` which returns a mutable reference to the generator's schema definitions
|
- `SchemaGenerator::definitions_mut()` which returns a mutable reference to the generator's schema definitions
|
||||||
- Implement `JsonSchema` for slices
|
- Implement `JsonSchema` for slices
|
||||||
|
|
||||||
### Changed:
|
### Changed:
|
||||||
|
|
||||||
- Minimum supported rust version is now 1.37.0
|
- Minimum supported rust version is now 1.37.0
|
||||||
- Deriving JsonSchema on enums now sets `additionalProperties` to false on generated schemas wherever serde doesn't accept unknown properties. This includes non-unit variants of externally tagged enums, and struct-style variants of all enums that have the `deny_unknown_fields` attribute.
|
- Deriving JsonSchema on enums now sets `additionalProperties` to false on generated schemas wherever serde doesn't accept unknown properties. This includes non-unit variants of externally tagged enums, and struct-style variants of all enums that have the `deny_unknown_fields` attribute.
|
||||||
- Schemas for HashSet and BTreeSet now have `uniqueItems` set to true (https://github.com/GREsau/schemars/pull/64)
|
- Schemas for HashSet and BTreeSet now have `uniqueItems` set to true (https://github.com/GREsau/schemars/pull/64)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fix use of `#[serde(transparent)]` in combination with `#[schemars(with = ...)]` (https://github.com/GREsau/schemars/pull/67)
|
- Fix use of `#[serde(transparent)]` in combination with `#[schemars(with = ...)]` (https://github.com/GREsau/schemars/pull/67)
|
||||||
- Fix clippy `field_reassign_with_default` warning in schemars_derive generated code in rust <1.51 (https://github.com/GREsau/schemars/pull/65)
|
- Fix clippy `field_reassign_with_default` warning in schemars_derive generated code in rust <1.51 (https://github.com/GREsau/schemars/pull/65)
|
||||||
- Prevent stack overflow when using `inline_subschemas` with recursive types
|
- Prevent stack overflow when using `inline_subschemas` with recursive types
|
||||||
|
|
||||||
## [0.8.0] - 2020-09-27
|
## [0.8.0] - 2020-09-27
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- `visit::Visitor`, a trait for updating a schema and all schemas it contains recursively. A `SchemaSettings` can now contain a list of visitors.
|
- `visit::Visitor`, a trait for updating a schema and all schemas it contains recursively. A `SchemaSettings` can now contain a list of visitors.
|
||||||
- `into_object()` method added to `Schema` as a shortcut for `into::<SchemaObject>()`
|
- `into_object()` method added to `Schema` as a shortcut for `into::<SchemaObject>()`
|
||||||
- Preserve order of schema properties under `preserve_order` feature flag (https://github.com/GREsau/schemars/issues/32)
|
- Preserve order of schema properties under `preserve_order` feature flag (https://github.com/GREsau/schemars/issues/32)
|
||||||
|
@ -93,112 +131,160 @@
|
||||||
- `SchemaSettings::inline_subschemas` - enforces inlining of all subschemas instead of using references (https://github.com/GREsau/schemars/issues/44)
|
- `SchemaSettings::inline_subschemas` - enforces inlining of all subschemas instead of using references (https://github.com/GREsau/schemars/issues/44)
|
||||||
|
|
||||||
### Removed (**BREAKING CHANGES**):
|
### Removed (**BREAKING CHANGES**):
|
||||||
|
|
||||||
- `SchemaSettings::bool_schemas` - this has been superseded by the `ReplaceBoolSchemas` visitor
|
- `SchemaSettings::bool_schemas` - this has been superseded by the `ReplaceBoolSchemas` visitor
|
||||||
- `SchemaSettings::allow_ref_siblings` - this has been superseded by the `RemoveRefSiblings` visitor
|
- `SchemaSettings::allow_ref_siblings` - this has been superseded by the `RemoveRefSiblings` visitor
|
||||||
- `SchemaSettings` no longer implements `PartialEq`
|
- `SchemaSettings` no longer implements `PartialEq`
|
||||||
- `SchemaGenerator::into_definitions()` - this has been superseded by `SchemaGenerator::take_definitions()`
|
- `SchemaGenerator::into_definitions()` - this has been superseded by `SchemaGenerator::take_definitions()`
|
||||||
|
|
||||||
### Changed:
|
### Changed:
|
||||||
|
|
||||||
- **BREAKING CHANGE** Minimum supported rust version is now 1.36.0
|
- **BREAKING CHANGE** Minimum supported rust version is now 1.36.0
|
||||||
|
|
||||||
### Fixed:
|
### Fixed:
|
||||||
|
|
||||||
- **BREAKING CHANGE** unknown items in `#[schemars(...)]` attributes now cause a compilation error (https://github.com/GREsau/schemars/issues/18)
|
- **BREAKING CHANGE** unknown items in `#[schemars(...)]` attributes now cause a compilation error (https://github.com/GREsau/schemars/issues/18)
|
||||||
|
|
||||||
### Deprecated:
|
### Deprecated:
|
||||||
|
|
||||||
- `make_extensible`, `schema_for_any`, and `schema_for_none` methods on `SchemaGenerator`
|
- `make_extensible`, `schema_for_any`, and `schema_for_none` methods on `SchemaGenerator`
|
||||||
|
|
||||||
## [0.7.6] - 2020-05-17
|
## [0.7.6] - 2020-05-17
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- `#[schemars(example = "...")]` attribute for setting examples on generated schemas (https://github.com/GREsau/schemars/issues/23)
|
- `#[schemars(example = "...")]` attribute for setting examples on generated schemas (https://github.com/GREsau/schemars/issues/23)
|
||||||
|
|
||||||
## [0.7.5] - 2020-05-17
|
## [0.7.5] - 2020-05-17
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- Setting `#[deprecated]` attribute will now cause generated schemas to have the `deprecated` property set to `true`
|
- Setting `#[deprecated]` attribute will now cause generated schemas to have the `deprecated` property set to `true`
|
||||||
- Respect `#[serde(transparent)]` attribute (https://github.com/GREsau/schemars/issues/17)
|
- Respect `#[serde(transparent)]` attribute (https://github.com/GREsau/schemars/issues/17)
|
||||||
- `#[schemars(title = "...", description = "...")]` can now be used to set schema title/description. If present, these values will be used instead of doc comments (https://github.com/GREsau/schemars/issues/13)
|
- `#[schemars(title = "...", description = "...")]` can now be used to set schema title/description. If present, these values will be used instead of doc comments (https://github.com/GREsau/schemars/issues/13)
|
||||||
|
|
||||||
### Changed:
|
### Changed:
|
||||||
|
|
||||||
- schemars_derive is now an optional dependency, but included by default
|
- schemars_derive is now an optional dependency, but included by default
|
||||||
|
|
||||||
## [0.7.4] - 2020-05-16
|
## [0.7.4] - 2020-05-16
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- If a struct is annotated with `#[serde(deny_unknown_fields)]`, generated schema will have `additionalProperties` set to `false` (https://github.com/GREsau/schemars/pull/30)
|
- If a struct is annotated with `#[serde(deny_unknown_fields)]`, generated schema will have `additionalProperties` set to `false` (https://github.com/GREsau/schemars/pull/30)
|
||||||
- Set `type` property to `string` on simple enums (https://github.com/GREsau/schemars/issues/28)
|
- Set `type` property to `string` on simple enums (https://github.com/GREsau/schemars/issues/28)
|
||||||
|
|
||||||
## [0.7.3] - 2020-05-15
|
## [0.7.3] - 2020-05-15
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- `#[schemars(schema_with = "...")]` attribute can be set on variants and fields. This allows you to specify another function which returns the schema you want, which is particularly useful on fields of types that don't implement the JsonSchema trait (https://github.com/GREsau/schemars/issues/15)
|
- `#[schemars(schema_with = "...")]` attribute can be set on variants and fields. This allows you to specify another function which returns the schema you want, which is particularly useful on fields of types that don't implement the JsonSchema trait (https://github.com/GREsau/schemars/issues/15)
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- `#[serde(with = "...")]`/`#[schemars(with = "...")]` attributes on enum variants are now respected
|
- `#[serde(with = "...")]`/`#[schemars(with = "...")]` attributes on enum variants are now respected
|
||||||
- Some compiler errors generated by schemars_derive should now have more accurate spans
|
- Some compiler errors generated by schemars_derive should now have more accurate spans
|
||||||
|
|
||||||
## [0.7.2] - 2020-04-30
|
## [0.7.2] - 2020-04-30
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- Enable deriving JsonSchema on adjacent tagged enums (https://github.com/GREsau/schemars/issues/4)
|
- Enable deriving JsonSchema on adjacent tagged enums (https://github.com/GREsau/schemars/issues/4)
|
||||||
|
|
||||||
## [0.7.1] - 2020-04-11
|
## [0.7.1] - 2020-04-11
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- Added `examples` (https://tools.ietf.org/html/draft-handrews-json-schema-validation-02#section-9.5) to `Metadata`
|
- Added `examples` (https://tools.ietf.org/html/draft-handrews-json-schema-validation-02#section-9.5) to `Metadata`
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed a bug in schemars_derive causing a compile error when the `default`, `skip_serializing_if`, and `serialize_with`/`with` attributes are used together (https://github.com/GREsau/schemars/issues/26)
|
- Fixed a bug in schemars_derive causing a compile error when the `default`, `skip_serializing_if`, and `serialize_with`/`with` attributes are used together (https://github.com/GREsau/schemars/issues/26)
|
||||||
|
|
||||||
## [0.7.0] - 2020-03-24
|
## [0.7.0] - 2020-03-24
|
||||||
|
|
||||||
### Changed:
|
### Changed:
|
||||||
|
|
||||||
- **BREAKING CHANGE** - `SchemaSettings` can no longer be created using struct initialization syntax. Instead, if you need to use custom schema settings, you can use a constructor function and either:
|
- **BREAKING CHANGE** - `SchemaSettings` can no longer be created using struct initialization syntax. Instead, if you need to use custom schema settings, you can use a constructor function and either:
|
||||||
- assign it to a `mut` variable and modify its public fields
|
- assign it to a `mut` variable and modify its public fields
|
||||||
- call the `with(|s| ...)` method on the settings and modify the settings inside the closure/function (as in the custom_settings.rs example)
|
- call the `with(|s| ...)` method on the settings and modify the settings inside the closure/function (as in the custom_settings.rs example)
|
||||||
|
|
||||||
### Fixed:
|
### Fixed:
|
||||||
|
|
||||||
- When deriving `JsonSchema` on structs, `Option<T>` struct fields are no longer included in the list of required properties in the schema (https://github.com/GREsau/schemars/issues/11)
|
- When deriving `JsonSchema` on structs, `Option<T>` struct fields are no longer included in the list of required properties in the schema (https://github.com/GREsau/schemars/issues/11)
|
||||||
- Fix deriving `JsonSchema` when a non-std `String` type is in scope (https://github.com/GREsau/schemars/pull/19)
|
- Fix deriving `JsonSchema` when a non-std `String` type is in scope (https://github.com/GREsau/schemars/pull/19)
|
||||||
- This will now compile: `#[schemars(with="()")]`
|
- This will now compile: `#[schemars(with="()")]`
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- Added `allow_ref_siblings` setting to `SchemaSettings`. When enabled, schemas with a `$ref` property may have other properties set.
|
- Added `allow_ref_siblings` setting to `SchemaSettings`. When enabled, schemas with a `$ref` property may have other properties set.
|
||||||
- Can create JSON Schema 2019-09 schemas using `SchemaSettings::draft2019_09()` (which enables `allow_ref_siblings`)
|
- Can create JSON Schema 2019-09 schemas using `SchemaSettings::draft2019_09()` (which enables `allow_ref_siblings`)
|
||||||
|
|
||||||
## [0.6.5] - 2019-12-29
|
## [0.6.5] - 2019-12-29
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- Implemented `JsonSchema` on types from `smallvec` and `arrayvec` (as optional dependencies)
|
- Implemented `JsonSchema` on types from `smallvec` and `arrayvec` (as optional dependencies)
|
||||||
|
|
||||||
## [0.6.4] - 2019-12-27
|
## [0.6.4] - 2019-12-27
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- Implemented `JsonSchema` on types from `indexmap`, `either` and `uuid` (as optional dependencies)
|
- Implemented `JsonSchema` on types from `indexmap`, `either` and `uuid` (as optional dependencies)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- Remove trait bounds from Map/Set JsonSchema impls. They are unnecessary as we never create/use any instances of these types.
|
- Remove trait bounds from Map/Set JsonSchema impls. They are unnecessary as we never create/use any instances of these types.
|
||||||
|
|
||||||
## [0.6.3] - 2019-12-27
|
## [0.6.3] - 2019-12-27
|
||||||
|
|
||||||
- No actual code changes - this version was just published to fix broken README on crates.io
|
- No actual code changes - this version was just published to fix broken README on crates.io
|
||||||
|
|
||||||
## [0.6.2] - 2019-12-27
|
## [0.6.2] - 2019-12-27
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- Documentation website available at https://graham.cool/schemars/!
|
- Documentation website available at https://graham.cool/schemars/!
|
||||||
|
|
||||||
### Changed:
|
### Changed:
|
||||||
|
|
||||||
- Rename `derive_json_schema` to `impl_json_schema`. `derive_json_schema` is still available for backward-compatibility, but will be removed in a future version.
|
- Rename `derive_json_schema` to `impl_json_schema`. `derive_json_schema` is still available for backward-compatibility, but will be removed in a future version.
|
||||||
- Improve schema naming for deriving on remote types. A `#[serde(remote = "Duration")]` attribute is now treated similarly to `#[serde(rename = "Duration")]`.
|
- Improve schema naming for deriving on remote types. A `#[serde(remote = "Duration")]` attribute is now treated similarly to `#[serde(rename = "Duration")]`.
|
||||||
- Ensure root schemas do not have a `$ref` property. If necessary, wrap the `$ref` in an `allOf`.
|
- Ensure root schemas do not have a `$ref` property. If necessary, wrap the `$ref` in an `allOf`.
|
||||||
|
|
||||||
## [0.6.1] - 2019-12-09
|
## [0.6.1] - 2019-12-09
|
||||||
|
|
||||||
### Fixed:
|
### Fixed:
|
||||||
|
|
||||||
- Fix a compile error that can occur when deriving `JsonSchema` from a project that doesn't reference serde_json
|
- Fix a compile error that can occur when deriving `JsonSchema` from a project that doesn't reference serde_json
|
||||||
|
|
||||||
## [0.6.0] - 2019-12-09
|
## [0.6.0] - 2019-12-09
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- When deriving `JsonSchema`, the schema's `title` and `description` are now set from `#[doc]` comments (https://github.com/GREsau/schemars/issues/7)
|
- When deriving `JsonSchema`, the schema's `title` and `description` are now set from `#[doc]` comments (https://github.com/GREsau/schemars/issues/7)
|
||||||
- When deriving `JsonSchema` on structs using a `#[serde(default)]` attribute, the schema's properties will now include `default`, unless the default value is skipped by the field's `skip_serializing_if` function (https://github.com/GREsau/schemars/issues/6)
|
- When deriving `JsonSchema` on structs using a `#[serde(default)]` attribute, the schema's properties will now include `default`, unless the default value is skipped by the field's `skip_serializing_if` function (https://github.com/GREsau/schemars/issues/6)
|
||||||
|
|
||||||
### Changed:
|
### Changed:
|
||||||
|
|
||||||
- When the `option_nullable` setting is enabled (e.g. for openapi 3), schemas for `Option<T>` will no longer inline `T`'s schema when it should be referenceable.
|
- When the `option_nullable` setting is enabled (e.g. for openapi 3), schemas for `Option<T>` will no longer inline `T`'s schema when it should be referenceable.
|
||||||
|
|
||||||
## [0.5.1] - 2019-10-30
|
## [0.5.1] - 2019-10-30
|
||||||
|
|
||||||
### Fixed:
|
### Fixed:
|
||||||
|
|
||||||
- Added missing doc comment for `title` schema property
|
- Added missing doc comment for `title` schema property
|
||||||
|
|
||||||
## [0.5.0] - 2019-10-30
|
## [0.5.0] - 2019-10-30
|
||||||
|
|
||||||
### Added:
|
### Added:
|
||||||
|
|
||||||
- Implemented `JsonSchema` for more standard library types (https://github.com/GREsau/schemars/issues/3)
|
- Implemented `JsonSchema` for more standard library types (https://github.com/GREsau/schemars/issues/3)
|
||||||
|
|
||||||
### Changed:
|
### Changed:
|
||||||
|
|
||||||
- Unsigned integer types (usize, u8 etc.) now have their [`minimum`](https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.2.4) explicitly set to zero
|
- Unsigned integer types (usize, u8 etc.) now have their [`minimum`](https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6.2.4) explicitly set to zero
|
||||||
- Made prepositions/conjunctions in generated schema names lowercase
|
- Made prepositions/conjunctions in generated schema names lowercase
|
||||||
- e.g. schema name for `Result<MyStruct, Vec<String>>` has changed from "Result_Of_MyStruct_Or_Array_Of_String" to "Result_of_MyStruct_or_Array_of_String"
|
- e.g. schema name for `Result<MyStruct, Vec<String>>` has changed from "Result_Of_MyStruct_Or_Array_Of_String" to "Result_of_MyStruct_or_Array_of_String"
|
||||||
- Some provided `JsonSchema` implementations with the same `type` but different `format`s (e.g. `i8` and `usize`) used the `type` as their name. They have now been updated to use `format` as their name.
|
- Some provided `JsonSchema` implementations with the same `type` but different `format`s (e.g. `i8` and `usize`) used the `type` as their name. They have now been updated to use `format` as their name.
|
||||||
- Previously, schema generation would incorrectly assume types such as `MyStruct<i8>` and `MyStruct<usize>` were identical, and give them a single schema definition called `MyStruct_for_Integer` despite the fact they should have different schemas. Now they will each have their own schema (`MyStruct_for_i8` and `MyStruct_for_usize` respectively).
|
- Previously, schema generation would incorrectly assume types such as `MyStruct<i8>` and `MyStruct<usize>` were identical, and give them a single schema definition called `MyStruct_for_Integer` despite the fact they should have different schemas. Now they will each have their own schema (`MyStruct_for_i8` and `MyStruct_for_usize` respectively).
|
||||||
|
|
35
README.md
35
README.md
|
@ -3,7 +3,7 @@
|
||||||
[](https://github.com/GREsau/schemars/actions)
|
[](https://github.com/GREsau/schemars/actions)
|
||||||
[](https://crates.io/crates/schemars)
|
[](https://crates.io/crates/schemars)
|
||||||
[](https://docs.rs/schemars)
|
[](https://docs.rs/schemars)
|
||||||
[](https://blog.rust-lang.org/2020/07/16/Rust-1.45.0.html)
|
[](https://blog.rust-lang.org/2021/10/21/Rust-1.56.0.html)
|
||||||
|
|
||||||
Generate JSON Schema documents from Rust code
|
Generate JSON Schema documents from Rust code
|
||||||
|
|
||||||
|
@ -39,10 +39,7 @@ println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
"title": "MyStruct",
|
"title": "MyStruct",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": ["my_bool", "my_int"],
|
||||||
"my_bool",
|
|
||||||
"my_int"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"my_bool": {
|
"my_bool": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
@ -67,9 +64,7 @@ println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": ["StringNewType"],
|
||||||
"StringNewType"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"StringNewType": {
|
"StringNewType": {
|
||||||
"type": "string"
|
"type": "string"
|
||||||
|
@ -79,15 +74,11 @@ println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": ["StructVariant"],
|
||||||
"StructVariant"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"StructVariant": {
|
"StructVariant": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": ["floats"],
|
||||||
"floats"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"floats": {
|
"floats": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
@ -106,11 +97,12 @@ println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
### 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};
|
||||||
|
@ -145,10 +137,7 @@ println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
"title": "MyStruct",
|
"title": "MyStruct",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": ["myBool", "myNumber"],
|
||||||
"myBool",
|
|
||||||
"myNumber"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"myBool": {
|
"myBool": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
@ -178,9 +167,7 @@ println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"required": [
|
"required": ["floats"],
|
||||||
"floats"
|
|
||||||
],
|
|
||||||
"properties": {
|
"properties": {
|
||||||
"floats": {
|
"floats": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
|
@ -196,6 +183,7 @@ println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</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's behaviour, 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.
|
||||||
|
@ -257,14 +245,17 @@ println!("{}", serde_json::to_string_pretty(&schema).unwrap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
## Feature Flags
|
## Feature Flags
|
||||||
|
|
||||||
- `derive` (enabled by default) - provides `#[derive(JsonSchema)]` macro
|
- `derive` (enabled by default) - provides `#[derive(JsonSchema)]` macro
|
||||||
- `impl_json_schema` - implements `JsonSchema` for Schemars types themselves
|
- `impl_json_schema` - implements `JsonSchema` for Schemars types themselves
|
||||||
- `preserve_order` - keep the order of struct fields in `Schema` and `SchemaObject`
|
- `preserve_order` - keep the order of struct fields in `Schema` and `SchemaObject`
|
||||||
|
|
||||||
Schemars can implement `JsonSchema` on types from several popular crates, enabled via feature flags (dependency versions are shown in brackets):
|
Schemars can implement `JsonSchema` on types from several popular crates, enabled via feature flags (dependency versions are shown in brackets):
|
||||||
|
|
||||||
- `chrono` - [chrono](https://crates.io/crates/chrono) (^0.4)
|
- `chrono` - [chrono](https://crates.io/crates/chrono) (^0.4)
|
||||||
- `indexmap1` - [indexmap](https://crates.io/crates/indexmap) (^1.2)
|
- `indexmap1` - [indexmap](https://crates.io/crates/indexmap) (^1.2)
|
||||||
- `either` - [either](https://crates.io/crates/either) (^1.3)
|
- `either` - [either](https://crates.io/crates/either) (^1.3)
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
msrv = "1.45.0"
|
|
|
@ -11,6 +11,7 @@ readme = "README.md"
|
||||||
keywords = ["rust", "json-schema", "serde"]
|
keywords = ["rust", "json-schema", "serde"]
|
||||||
categories = ["encoding"]
|
categories = ["encoding"]
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
rust-version = "1.56"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
schemars_derive = { version = "=0.8.12", optional = true, path = "../schemars_derive" }
|
schemars_derive = { version = "=0.8.12", optional = true, path = "../schemars_derive" }
|
||||||
|
|
|
@ -9,6 +9,7 @@ edition = "2018"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
keywords = ["rust", "json-schema", "serde"]
|
keywords = ["rust", "json-schema", "serde"]
|
||||||
|
rust-version = "1.56"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue