Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle default field #67

Open
clux opened this issue May 2, 2022 · 1 comment
Open

handle default field #67

clux opened this issue May 2, 2022 · 1 comment
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@clux
Copy link
Member

clux commented May 2, 2022

Problem

Some schemas can set explicit default: replace to define what defaults are, but we will always just output #[serde(default)] on non-required properties.

Solution

Add an OutputImpls struct and collect things like impl Default for MemberStruct that will ensure #[serde(default)] works and takes into account the correct default values. This is especially important for enums where no default can be derived.

EDIT: This must also handle enums.

@clux clux added the enhancement New feature or request label May 2, 2022
@clux clux added the help wanted Extra attention is needed label Aug 2, 2022
@clux
Copy link
Member Author

clux commented Mar 11, 2023

We actually won't need to impl Default for SomeEnum for enums because of the rust 1.62 feature allowing us to do:

#[derive(Default)]
enum Maybe<T> {
    #[default]
    Nothing,

    Something(T),
}

i.e. we just need pushing "#[default]" to the m.extra_annot vec

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant