Commit graph

179 commits

Author SHA1 Message Date
Graham Esau
9770301218
Read #[garde(...)] attributes in addition to #[validate(...)] (#331) 2024-08-29 17:12:06 +01:00
Graham Esau
56cdd45c5a Allow validate (but not schemars) attributes to have extra values where necessary 2024-08-28 09:59:24 +01:00
Graham Esau
d7ff81de96 Fix regex attribute when it uses dereferencing 2024-08-27 19:26:02 +01:00
Maximilian Güntner
04fa0713da
fix: honor rename_all_fields, add tests (#304) 2024-08-27 17:55:21 +01:00
Graham Esau
d07a1be031
Rewrite attribute handling code (#330) 2024-08-27 16:50:47 +01:00
Graham Esau
66f17fff0e
Allow regex(path = ...) value to be a non-string expression (#328) 2024-08-24 18:27:27 +01:00
Graham Esau
dc1245bbd8 Test MSRV with --all-features 2024-08-24 17:27:04 +01:00
Graham Esau
df06fc5f66
Allow arbitrary expressions in doc/title/description attributes (#327) 2024-08-24 14:35:30 +01:00
Graham Esau
9658c42d6a
Fix some cases of unsatisfiable schemas when flattening enums (#325)
Addresses #164 and #165
2024-08-22 19:56:31 +01:00
Graham Esau
b4f214f6dc
Remove usages of gen identifier (#323)
`gen` is a reserved keyword in rust 2024, making it very awkward to use as a module/variable name.
2024-08-21 16:15:13 +01:00
Romain Lebran
5d5837741c
Add support for multiple flatten enums (#320)
Co-authored-by: Graham Esau <gesau@hotmail.co.uk>
2024-08-19 22:30:11 +01:00
Graham Esau
30a9a384e2 Improve flatten behavioure with additionalProperties 2024-08-19 12:08:47 +01:00
Graham Esau
89a34e7a63
Add no_std support via disabling the new default feature std (#319) 2024-08-17 19:46:11 +01:00
Graham Esau
705aba1cef Fix flattening of serde_json::Value
It should behave similarly to flattening a `Map<String,Value>` in that it allows any properties
2024-08-13 20:19:22 +01:00
Graham Esau
14b06e71ba
Add transform = ... attribute (#312)
This allows running arbitrary transforms on generated schemas when deriving `JsonSchema`
2024-08-10 09:56:52 +01:00
Graham Esau
324be32de6 Replace visit::Visitor with transform::Transform 2024-08-07 19:20:01 +01:00
Graham Esau
71b45a8ba3 Remove irrelevant comments
I'm reasonably satisfied that the current behaviour of enum variants with `with`/`schema_with` attributes is correct
2024-08-04 17:26:08 +01:00
Graham Esau
ce15380863
Do not collapse newlines in doc comments (#310) 2024-08-04 16:43:22 +01:00
Graham Esau
840315b2dd
Add #[schemars(extend("key" = value))] attribute (#297) 2024-06-05 21:09:52 +01:00
Graham Esau
760403e2f5 Update doc comments and make SchemaGenerator available from crate root 2024-05-27 11:09:15 +01:00
Graham Esau
1819dceb24 Merge branch 'master' into v1 2024-05-23 17:31:52 +01:00
Graham Esau
a9a9c7e8ed
Fix "null" default not being set on schema (#296)
Fixes #295
2024-05-23 17:25:07 +01:00
Graham Esau
3aa0e7fa3c
Support JSON Schema draft 2020-12 and use it by default (#294) 2024-05-19 20:49:45 +01:00
Graham Esau
95475ad1b4 Use $defs instead of definitions in draft 2019-09
This also changes the strategy for running visitors on subschemas - it is now done eagerly, as soon as they're added to the definitions map.
2024-05-19 18:07:51 +01:00
Graham Esau
d3b6ff5aeb Re-add preserve_order feature, to preserve order of struct fields in a schema's properties 2024-05-18 21:55:05 +01:00
Graham Esau
c4d42ec11a Refactor flatten and move it to _private, remove TempFixupForTests, regenerate test schemas 2024-05-13 22:02:32 +01:00
Graham Esau
18300c67bb
Use const instead of single-valued enum (#291) 2024-05-13 21:30:51 +01:00
Graham Esau
cf5be1b266 Ignore failing test
The failure reason is arguably a bug in `Schema`'s `PartialEq` impl. This bug is not present in the v1 branch, so the test passes there.
2024-05-13 21:29:16 +01:00
Graham Esau
f5d2142714 Regenerate test schemas 2024-05-13 18:33:48 +01:00
Graham Esau
4dde683358 Update OpenAPI 3.0 schema URI 2024-05-13 18:17:21 +01:00
Graham Esau
dec3c67e87 Remove test schemas for now-removed RootSchema 2024-05-13 17:58:09 +01:00
Graham Esau
efff7e2606 Merge branch 'master' into v1 2024-05-13 17:55:02 +01:00
Graham Esau
449bb1a0ca Add more tests for different schema settings
This is mainly to keep this coverage around in v1, where the `schema_for_schema` tests are no longer viable
2024-05-13 17:53:56 +01:00
Graham Esau
3b3870ca82 Simplify flatten
No longer use it for internally-tagged enums. Instead, use a private helper that adds the tag property.
2024-05-13 10:52:42 +01:00
Graham Esau
342cd5fd09
Define Schema as a newtype around serde_json::Value (#289) 2024-05-12 19:23:54 +01:00
Graham Esau
1a40d1b06c Fix deriving JsonSchema on enum without variants
Fixes #287
2024-05-06 18:12:20 +01:00
Graham Esau
9501fe319f Update to syn 2 and serde_derive_internals 0.29 2024-04-28 18:56:06 +01:00
Graham Esau
a8d723342f Cleanup and test updates for bigdecimal04 2023-09-17 21:10:22 +01:00
Graham Esau
342b2dff33
Add schema_id(), handles different types with the same name (#247) 2023-09-17 20:36:52 +01:00
Graham Esau
db1dd47039
Fix schemas for bigdecimal/rust_decimal (#248)
Both of these crates serialise decimals as strings, not as plain numbers
2023-09-17 20:31:24 +01:00
Jakub Jirutka
a5e51b22b3
Add #[schemars(inner(...)] attribute to specify schema for array items (#234) 2023-09-09 13:35:53 +01:00
David Knaack
aeb989486e Add support for indexmap v2 2023-08-27 23:01:12 +01:00
Graham Esau
37478d764e
Support types with const generics (#239)
Co-authored-by: Spencer Sharkey <spsharkey@tesla.com>
2023-08-27 20:50:20 +01:00
Graham Esau
0303f0334e
add support for semver crate (#238)
---------

Co-authored-by: Omar Tawfik <15987992+OmarTawfik@users.noreply.github.com>
2023-08-27 20:00:36 +01:00
Graham Esau
824993ca76 Apply clippy fixes 2023-02-26 19:59:17 +00:00
Graham Esau
39bae201eb Run cargo fmt 2023-02-26 19:47:10 +00:00
Gleb Pomykalov
587176fe9f
add optional smol_str support (#72)
Co-authored-by: Graham Esau <gesau@hotmail.co.uk>
2023-02-26 19:42:16 +00:00
Graham Esau
104dccca50 Add #[schemars(bound = ...)] attribute
Based on https://github.com/GREsau/schemars/pull/162

Co-authored-by: teozkr <teo@nullable.se>
2022-10-02 19:46:29 +01:00
Adam Leventhal
76427ef384
Fix handling of attributes applied to unit variant types (#152) 2022-08-12 15:37:34 +01:00
Graham Esau
d93bdc43e3 Revert "Support generic default values"
This feature inadvertently introduced a breaking change (#144)

This reverts commits: feb6c4b2fe
b38a55331b.
2022-05-17 18:17:17 +01:00