Commit graph

187 commits

Author SHA1 Message Date
Graham Esau
5e20a37a1a v0.8.21 2024-05-23 17:26:07 +01:00
Graham Esau
7ecaa7feab
Revert unintentional change in behaviour when combining default and required attributes (#293)
Never add a field with the `default` attribute to a schema's `required` properties
2024-05-18 22:37:40 +01:00
Graham Esau
8da70a4d45 v0.8.19 2024-05-06 18:13: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
4b90b6f8c8 v0.8.18 2024-05-06 13:58:49 +01:00
Graham Esau
d04c17bda4
Simplify generated enum code (#286)
* simplify the code generated for unit enums
* simplify generated code for validating object properties
* optimize internal and externally tagged enums

---------

Co-authored-by: Robin Appelman <robin@icewind.nl>
2024-05-06 13:54:13 +01:00
Graham Esau
e5ef0f8d7b v0.8.17 2024-04-28 19:03:40 +01:00
Graham Esau
df00e2fd71 Add comment explaining why we double-parse an Expr 2024-04-28 18:59:42 +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
e04e3a3a81 v0.8.16 2023-11-11 20:35:26 +00:00
Graham Esau
ae9544aaf9 Put schema value into a variable before calling apply_metadata
This reduces size of MIR output, which should somewhat mitigate #246
2023-11-11 20:28:10 +00:00
Graham Esau
9415fcb57b v0.8.15 2023-09-17 21:13:54 +01:00
Graham Esau
0084f1a655 v0.8.14 2023-09-17 20:56:13 +01:00
Graham Esau
342b2dff33
Add schema_id(), handles different types with the same name (#247) 2023-09-17 20:36:52 +01:00
Jakub Jirutka
a5e51b22b3
Add #[schemars(inner(...)] attribute to specify schema for array items (#234) 2023-09-09 13:35:53 +01:00
Graham Esau
6931d70e0a v0.8.13 2023-08-28 21:19:01 +01:00
Graham Esau
5dbfa49c5e Update MSRV to 1.60 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
3d56977ecf Update to rust 2021 edition 2023-08-20 18:14:04 +01:00
Graham Esau
072730f6f6 Resolve clippy warnings 2023-08-20 18:14:04 +01:00
Graham Esau
e0495c0c87 Update MSRV to 1.56 2023-08-20 18:14:04 +01:00
Graham Esau
386e3d7f5a v0.8.12 2023-02-26 21:00:48 +00: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
Graham Esau
5268080b01 v0.8.11 2022-10-02 20:01:43 +01:00
Graham Esau
c59e5b5e1c Fix test 2022-10-02 19:46:29 +01:00
Graham Esau
4754a13fb3 Ignore bound set in serde attrs 2022-10-02 19:46:29 +01: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
9464118c3a v0.8.10 2022-05-17 18:33:47 +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
Graham Esau
1610294af4 v0.8.9 2022-05-16 22:41:14 +01:00
Graham Esau
74974d3e95
Support uuid v1 and arrayvec 0.7 (#142) 2022-05-16 22:39:48 +01:00
Andy Weiss
115a9eebf2 Add license notice to regex_syntax.rs
The comment in the code says this code was copied from another source
with an appropriate link. However just local to this file it is not
clear what the license terms of that code are. I added the license
notice to this file that governs the particular code that was copied
over.

I would like to use this crate in an environment where we want to be
clear about licensing. Hopefully this is an okay change otherwise I
would be more than happy to do this a different way as long as the
license provenance is clear.
2022-05-15 22:33:24 +01:00
Graham Esau
feb6c4b2fe Use as instead of immediately-invoked typed function 2022-05-15 22:30:38 +01:00
Graeme Coupar
b38a55331b Support generic default values
I'm trying to `derive(JsonSchema)` on a field with a default that relies
on type inference to determine it's return type.  This causes compile
errors because schemars calls the default function without providing
any types for inference to use.

This changes that - wraps the `default` in a closure with a defined
return value that it immediately calls.  Feels a bit hacky, but I
couldn't think of a better way to fix this.
2022-05-15 22:30:38 +01:00
Graham Esau
e9d5f4057e v0.8.8 2021-11-25 22:28:38 +00:00
Adam H. Leventhal
98ad16288b Internally tagged enums don't honor deny_unknown_fields as precisely as
they might.

flatten doesn't act quite as intended with regard to
additional_properties
2021-11-25 21:55:48 +00:00
Graham Esau
1a13ba9f9b v0.8.7 2021-11-14 19:23:15 +00:00
Graham Esau
690fe44343 Allow non-Serialize default values.
Default values that don't implement Serialize are now ignored, rather than causing a compile error.
This is done by simulating specialization using a technique copied from Rocket:
5ebefa97c9/core/lib/src/sentinel.rs (L391-L445)

Fixes #115
2021-11-14 19:16:46 +00:00
Graham Esau
33e54d3c42 v0.8.6 2021-09-26 18:39:11 +01:00
Adam Leventhal
0a1200baac
Use oneOf for enums when possible (#108) 2021-09-26 18:02:44 +01:00
Graham Esau
dec8bcc3b7 v0.8.5 2021-09-20 16:49:50 +01:00
Graham Esau
de7314f305 Allow empty #[validate] attributes.
Fixes #109
2021-09-20 16:48:16 +01:00
Graham Esau
00e482c3a1 v0.8.4 2021-09-19 10:43:29 +01:00
Graham Esau
605db3bba8 Emit compilation errors for duplicate validation attributes 2021-09-17 23:04:37 +01:00
Graham Esau
d99a96fc8a Add some doc comments 2021-04-24 11:46:07 +01:00
Graham Esau
7914593d89 Allow setting validation attributes via #[schemars(...)] 2021-04-18 22:17:53 +01:00
Graham Esau
c013052f59 Support inline regex 2021-04-16 22:31:03 +01:00
Graham Esau
5f841f2e5c Refactoring 2021-04-16 17:02:57 +01:00