Skip to content

Commit 2bc2ee3

Browse files
authored
Merge branch 'master' into add_im_impls
2 parents f0ad233 + e04e3a3 commit 2bc2ee3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1198
-493
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ jobs:
77
runs-on: ubuntu-latest
88
env:
99
# work-around https://github.com/rust-lang/cargo/issues/10303
10-
CARGO_NET_GIT_FETCH_WITH_CLI: ${{ matrix.rust == '1.45.0' }}
10+
CARGO_NET_GIT_FETCH_WITH_CLI: ${{ matrix.rust == '1.60.0' }}
1111
strategy:
1212
matrix:
1313
rust:
14-
- 1.45.0
14+
- 1.60.0
1515
- stable
1616
- beta
1717
- nightly
1818
include:
19-
- rust: 1.45.0
19+
- rust: 1.60.0
2020
test_features: "--features impl_json_schema"
2121
allow_failure: false
2222
- rust: stable
@@ -35,10 +35,7 @@ jobs:
3535
with:
3636
profile: minimal
3737
toolchain: ${{ matrix.rust }}
38-
override: true
39-
- if: matrix.rust == '1.45.0'
40-
# work-around https://github.com/serde-rs/serde/issues/2255 and similar crate/rustc compatibility issues
41-
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
38+
override: true
4239
- name: Check with no feature flags
4340
run: cargo check --verbose --no-default-features
4441
continue-on-error: ${{ matrix.allow_failure }}

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"rust-analyzer.check.command": "clippy",
3+
"rust-analyzer.showUnlinkedFileNotification": false
4+
}

CHANGELOG.md

Lines changed: 133 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,161 @@
11
# Changelog
22

3+
## [0.8.16] - 2023-11-11
4+
5+
### Fixed:
6+
7+
- Reduce size of MIR output (and improve release-mode compile time) when deriving `JsonSchema`
8+
9+
## [0.8.15] - 2023-09-17
10+
11+
### Added:
12+
13+
- Implement `JsonSchema` for `BigDecimal` from `bigdecimal` 0.4 (https://github.com/GREsau/schemars/pull/237)
14+
15+
## [0.8.14] - 2023-09-17
16+
17+
### Added:
18+
19+
- Add `#[schemars(inner(...)]` attribute to specify schema for array items (https://github.com/GREsau/schemars/pull/234)
20+
21+
### Changed:
22+
23+
- New optional associated function on `JsonSchema` trait: `schema_id()`, which is similar to `schema_name()`, but does not have to be human-readable, and defaults to the type name including module path. This allows schemars to differentiate between types with the same name in different modules/crates (https://github.com/GREsau/schemars/issues/62 / https://github.com/GREsau/schemars/pull/247)
24+
25+
### Fixed:
26+
27+
- Schemas for `rust_decimal::Decimal` and `bigdecimal::BigDecimal` now match how those types are serialized by default, i.e. as numeric strings (https://github.com/GREsau/schemars/pull/248)
28+
29+
## [0.8.13] - 2023-08-28
30+
31+
### Added:
32+
33+
- Implement `JsonSchema` for `semver::Version` (https://github.com/GREsau/schemars/pull/195 / https://github.com/GREsau/schemars/pull/238)
34+
- Include const generics in generated schema names (https://github.com/GREsau/schemars/pull/179 / https://github.com/GREsau/schemars/pull/239)
35+
- Implement `JsonSchema` for types from indexmap v2 (https://github.com/GREsau/schemars/pull/226 / https://github.com/GREsau/schemars/pull/240)
36+
- Implement `JsonSchema` for `serde_json::value::RawValue` (https://github.com/GREsau/schemars/pull/183)
37+
38+
### Changed:
39+
40+
- Minimum supported rust version is now 1.60.0
41+
42+
## [0.8.12] - 2023-02-26
43+
44+
### Added:
45+
46+
- Implement `JsonSchema` for `smol_str::SmolStr` (https://github.com/GREsau/schemars/pull/72)
47+
48+
### Changed:
49+
50+
- Change `serde_json` dependency min version to 1.0.25 (was 1.0.0) (https://github.com/GREsau/schemars/pull/192)
51+
352
## [0.8.11] - 2022-10-02
53+
454
### Added:
55+
556
- Replace auto-inferred trait bounds with bounds specified in `#[schemars(bound = "...")]` attribute
657

758
### Changed:
59+
860
- Derived `JsonSchema` now respects attributes on unit enum variants (https://github.com/GREsau/schemars/pull/152)
961
- Minimum supported rust version is now 1.45.0
1062

1163
## [0.8.10] - 2022-05-17
64+
1265
- 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)
1366

1467
## [0.8.9] - 2022-05-16
68+
1569
### Added:
70+
1671
- ~~Support generic default values in `default` attributes (https://github.com/GREsau/schemars/pull/83)~~
17-
- ⚠️ **This inadvertently introduced a breaking change and was removed in 0.8.10**
72+
- ⚠️ **This inadvertently introduced a breaking change and was removed in 0.8.10**
1873
- Add missing MIT licence text for usage of code from regex_syntax crate (https://github.com/GREsau/schemars/pull/132)
1974
- Support uuid v1 and arrayvec 0.7 via feature flags `uuid1` and `arrayvec07` (https://github.com/GREsau/schemars/pull/142)
20-
- 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**.
21-
- Similarly, `indexmap1` feature flag is added, and `indexmap` flag is **deprecated**.
75+
- 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**.
76+
- Similarly, `indexmap1` feature flag is added, and `indexmap` flag is **deprecated**.
2277

2378
## [0.8.8] - 2021-11-25
79+
2480
### Added:
81+
2582
- Implement `JsonSchema` for types from `rust_decimal` and `bigdecimal` crates (https://github.com/GREsau/schemars/pull/101)
2683

2784
### Fixed:
85+
2886
- Fixes for internally tagged enums and flattening additional_properties (https://github.com/GREsau/schemars/pull/113)
2987

3088
## [0.8.7] - 2021-11-14
89+
3190
### Added:
91+
3292
- Implement `JsonSchema` for `EnumSet` (https://github.com/GREsau/schemars/pull/92)
3393

3494
### Fixed:
95+
3596
- Do not cause compile error when using a default value that doesn't implement `Serialize` (https://github.com/GREsau/schemars/issues/115)
3697

3798
## [0.8.6] - 2021-09-26
99+
38100
### Changed:
101+
39102
- Use `oneOf` instead of `anyOf` for enums when possible (https://github.com/GREsau/schemars/issues/108)
40103

41104
## [0.8.5] - 2021-09-20
105+
42106
### Fixed:
107+
43108
- Allow fields with plain `#[validate]` attributes (https://github.com/GREsau/schemars/issues/109)
44109

45110
## [0.8.4] - 2021-09-19
111+
46112
### Added:
113+
47114
- `#[schemars(schema_with = "...")]` attribute can now be set on enum variants.
48115
- 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)
49116

50117
## [0.8.3] - 2021-04-05
118+
51119
### Added:
120+
52121
- 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)
53122
- Implement `JsonSchema` for `bytes::Bytes` and `bytes::BytesMut` (https://github.com/GREsau/schemars/pull/68)
54123

55124
### Fixed:
125+
56126
- 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)
57127

58128
## [0.8.2] - 2021-03-27
129+
59130
### Added:
131+
60132
- 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)
61133
- `#[derive(JsonSchema_repr)]` can be used on C-like enums for generating a serde_repr-compatible schema (https://github.com/GREsau/schemars/pull/76)
62134
- Implement `JsonSchema` for `url::Url` (https://github.com/GREsau/schemars/pull/63)
63135

64136
## [0.8.1] - 2021-03-23
137+
65138
### Added:
139+
66140
- `SchemaGenerator::definitions_mut()` which returns a mutable reference to the generator's schema definitions
67141
- Implement `JsonSchema` for slices
68142

69143
### Changed:
144+
70145
- Minimum supported rust version is now 1.37.0
71146
- 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.
72147
- Schemas for HashSet and BTreeSet now have `uniqueItems` set to true (https://github.com/GREsau/schemars/pull/64)
73148

74149
### Fixed
150+
75151
- Fix use of `#[serde(transparent)]` in combination with `#[schemars(with = ...)]` (https://github.com/GREsau/schemars/pull/67)
76152
- Fix clippy `field_reassign_with_default` warning in schemars_derive generated code in rust <1.51 (https://github.com/GREsau/schemars/pull/65)
77153
- Prevent stack overflow when using `inline_subschemas` with recursive types
78154

79155
## [0.8.0] - 2020-09-27
156+
80157
### Added:
158+
81159
- `visit::Visitor`, a trait for updating a schema and all schemas it contains recursively. A `SchemaSettings` can now contain a list of visitors.
82160
- `into_object()` method added to `Schema` as a shortcut for `into::<SchemaObject>()`
83161
- Preserve order of schema properties under `preserve_order` feature flag (https://github.com/GREsau/schemars/issues/32)
@@ -86,112 +164,160 @@
86164
- `SchemaSettings::inline_subschemas` - enforces inlining of all subschemas instead of using references (https://github.com/GREsau/schemars/issues/44)
87165

88166
### Removed (**BREAKING CHANGES**):
167+
89168
- `SchemaSettings::bool_schemas` - this has been superseded by the `ReplaceBoolSchemas` visitor
90169
- `SchemaSettings::allow_ref_siblings` - this has been superseded by the `RemoveRefSiblings` visitor
91170
- `SchemaSettings` no longer implements `PartialEq`
92171
- `SchemaGenerator::into_definitions()` - this has been superseded by `SchemaGenerator::take_definitions()`
93172

94173
### Changed:
174+
95175
- **BREAKING CHANGE** Minimum supported rust version is now 1.36.0
96176

97177
### Fixed:
178+
98179
- **BREAKING CHANGE** unknown items in `#[schemars(...)]` attributes now cause a compilation error (https://github.com/GREsau/schemars/issues/18)
99180

100181
### Deprecated:
182+
101183
- `make_extensible`, `schema_for_any`, and `schema_for_none` methods on `SchemaGenerator`
102184

103185
## [0.7.6] - 2020-05-17
186+
104187
### Added:
188+
105189
- `#[schemars(example = "...")]` attribute for setting examples on generated schemas (https://github.com/GREsau/schemars/issues/23)
106190

107191
## [0.7.5] - 2020-05-17
192+
108193
### Added:
194+
109195
- Setting `#[deprecated]` attribute will now cause generated schemas to have the `deprecated` property set to `true`
110196
- Respect `#[serde(transparent)]` attribute (https://github.com/GREsau/schemars/issues/17)
111197
- `#[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)
112198

113199
### Changed:
200+
114201
- schemars_derive is now an optional dependency, but included by default
115202

116203
## [0.7.4] - 2020-05-16
204+
117205
### Added:
206+
118207
- 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)
119208
- Set `type` property to `string` on simple enums (https://github.com/GREsau/schemars/issues/28)
120209

121210
## [0.7.3] - 2020-05-15
211+
122212
### Added:
213+
123214
- `#[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)
124215

125216
### Fixed
217+
126218
- `#[serde(with = "...")]`/`#[schemars(with = "...")]` attributes on enum variants are now respected
127219
- Some compiler errors generated by schemars_derive should now have more accurate spans
128220

129221
## [0.7.2] - 2020-04-30
222+
130223
### Added:
224+
131225
- Enable deriving JsonSchema on adjacent tagged enums (https://github.com/GREsau/schemars/issues/4)
132226

133227
## [0.7.1] - 2020-04-11
228+
134229
### Added:
230+
135231
- Added `examples` (https://tools.ietf.org/html/draft-handrews-json-schema-validation-02#section-9.5) to `Metadata`
136232

137233
### Fixed
234+
138235
- 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)
139236

140237
## [0.7.0] - 2020-03-24
238+
141239
### Changed:
240+
142241
- **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:
143-
- assign it to a `mut` variable and modify its public fields
144-
- call the `with(|s| ...)` method on the settings and modify the settings inside the closure/function (as in the custom_settings.rs example)
242+
- assign it to a `mut` variable and modify its public fields
243+
- call the `with(|s| ...)` method on the settings and modify the settings inside the closure/function (as in the custom_settings.rs example)
244+
145245
### Fixed:
246+
146247
- 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)
147248
- Fix deriving `JsonSchema` when a non-std `String` type is in scope (https://github.com/GREsau/schemars/pull/19)
148249
- This will now compile: `#[schemars(with="()")]`
250+
149251
### Added:
252+
150253
- Added `allow_ref_siblings` setting to `SchemaSettings`. When enabled, schemas with a `$ref` property may have other properties set.
151254
- Can create JSON Schema 2019-09 schemas using `SchemaSettings::draft2019_09()` (which enables `allow_ref_siblings`)
152255

153256
## [0.6.5] - 2019-12-29
257+
154258
### Added:
259+
155260
- Implemented `JsonSchema` on types from `smallvec` and `arrayvec` (as optional dependencies)
156261

157262
## [0.6.4] - 2019-12-27
263+
158264
### Added:
265+
159266
- Implemented `JsonSchema` on types from `indexmap`, `either` and `uuid` (as optional dependencies)
267+
160268
### Changed
269+
161270
- Remove trait bounds from Map/Set JsonSchema impls. They are unnecessary as we never create/use any instances of these types.
162271

163272
## [0.6.3] - 2019-12-27
273+
164274
- No actual code changes - this version was just published to fix broken README on crates.io
165275

166276
## [0.6.2] - 2019-12-27
277+
167278
### Added:
279+
168280
- Documentation website available at https://graham.cool/schemars/!
281+
169282
### Changed:
283+
170284
- 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.
171285
- Improve schema naming for deriving on remote types. A `#[serde(remote = "Duration")]` attribute is now treated similarly to `#[serde(rename = "Duration")]`.
172286
- Ensure root schemas do not have a `$ref` property. If necessary, wrap the `$ref` in an `allOf`.
173287

174288
## [0.6.1] - 2019-12-09
289+
175290
### Fixed:
291+
176292
- Fix a compile error that can occur when deriving `JsonSchema` from a project that doesn't reference serde_json
177293

178294
## [0.6.0] - 2019-12-09
295+
179296
### Added:
297+
180298
- When deriving `JsonSchema`, the schema's `title` and `description` are now set from `#[doc]` comments (https://github.com/GREsau/schemars/issues/7)
181299
- 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)
300+
182301
### Changed:
302+
183303
- 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.
184304

185305
## [0.5.1] - 2019-10-30
306+
186307
### Fixed:
308+
187309
- Added missing doc comment for `title` schema property
188310

189311
## [0.5.0] - 2019-10-30
312+
190313
### Added:
314+
191315
- Implemented `JsonSchema` for more standard library types (https://github.com/GREsau/schemars/issues/3)
316+
192317
### Changed:
318+
193319
- 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
194320
- Made prepositions/conjunctions in generated schema names lowercase
195-
- 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"
321+
- 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"
196322
- 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.
197-
- 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).
323+
- 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).

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ members = [
33
"schemars",
44
"schemars_derive"
55
]
6+
resolver = "2"

0 commit comments

Comments
 (0)