Commit graph

24 commits

Author SHA1 Message Date
Graham Esau
342cd5fd09
Define Schema as a newtype around serde_json::Value (#289) 2024-05-12 19:23:54 +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
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
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
5f841f2e5c Refactoring 2021-04-16 17:02:57 +01:00
Graham Esau
60a9869448 Refactor out add_schema_as_property 2021-04-16 10:42:03 +01:00
Graham Esau
55b860428e Refactory of private functions 2021-04-15 13:34:04 +01:00
Graham Esau
dada8582ee Fix rustc 1.37 build 2021-03-27 10:34:39 +00:00
Graham Esau
29dc025629 Clippy fixes 2021-03-27 00:45:06 +00:00
Jan Michael Auer
d85eec3b7a
Fix clippy field_reassign_with_default in generated code (#65) 2021-03-21 18:31:58 +00:00
Graham Esau
3a7d7ad905 Apply some clippy suggestions 2021-03-19 23:20:16 +00:00
Graham Esau
e259955809 Attribute for defining examples (#23) 2020-05-17 16:41:19 +01:00
Graham Esau
75419fa3d5 Fix rustc 1.32 build 2020-05-17 11:27:11 +01:00
Graham Esau
1b42dc7e3e Allow overriding title/desc from doc comments (#13) 2020-05-17 11:19:48 +01:00
Graham Esau
509a1c3b7b Check for #[deprecated] attributes 2020-05-16 16:44:44 +01:00
Graham Esau
63af0ceb73 Fix skip_serializing_if/serialize_with handling
Previously whenever a field with a default value has both `skip_serializing_if` and `with`/`serialize_with` attributes, the value would be converted to a type that performs the custom serialization before checking if it should be serialized. This would cause the wrong type to be given to the skip_serializing_if function, causing a compile error.

Issue #26
2020-04-11 22:06:48 +01:00
Graham Esau
4ad5000232
Make Option<T> fields optional in generated schemas (#16) 2020-02-29 19:37:20 +00:00
Graham Esau
e151d21d6d v0.6.1
Fix a compile error that can occur when deriving `JsonSchema` from a project that doesn't reference serde_json
2019-12-09 21:25:37 +00:00
Graham Esau
3fb625e08c Refactoring of schemars_derive 2019-12-09 20:57:38 +00:00
Graham Esau
26c4099bbe Do not serialize schema default if it would be skipped by skip_serializing_if attribute 2019-12-09 12:34:28 +00:00
Graham Esau
b748a90c3f Respect serialize_with attr when serializing default 2019-12-08 20:04:54 +00:00
Graham Esau
7e23e2ad7a Set "default" on generated schemas (#6) 2019-12-08 15:17:08 +00:00
Graham Esau
ba79de696a Document SchemaGenerator.make_extensible() 2019-12-08 12:03:46 +00:00
Graham Esau
feefd418d4 Set schema title and description from #[doc]s
Work in progress
2019-12-08 12:03:46 +00:00