-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for auto-populating field default values (#533)
* Add support for auto-populating field default values Add support for `#[schema(default)]` and `#[serde(default)]` attributes on named field structs and unnamed field structs to use `<struct_name>::default().<field_name>` as the default value for all of its fields. In the example below the `default` value generated to the `value` field in OpenAPI schema would become 10.0. ```rust #[derive(ToSchema)] #[schema(default)] struct Value { value: f64 } impl Default for Value { fn default() -> Self { Self { value: 10.0 } } } ```
- Loading branch information
1 parent
39ef61f
commit 9d483a3
Showing
5 changed files
with
188 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters