Skip to content

Add #[schema(skip)] option for enum variants#1513

Open
notNotDaniel wants to merge 1 commit intojuhaku:masterfrom
notNotDaniel:feature/enum-variant-skip-squashed
Open

Add #[schema(skip)] option for enum variants#1513
notNotDaniel wants to merge 1 commit intojuhaku:masterfrom
notNotDaniel:feature/enum-variant-skip-squashed

Conversation

@notNotDaniel
Copy link

Adds a new #[schema(skip)] option which can be used to filter out enum variants before deciding if the set of variants is mixed or composed only of Unit values. We need this to support our use case, where we have enums with a set of known values, but also want to capture a single Unknown(String) value using #[serde(untagged)], but need the resulting openApi documentation to include just a simple list of enum values.

I had hoped to reuse the existing ignore feature, however since the filtering needs to happen during the schema generation (but not rust code generation), it wasn't clear how the expression included with ignore could be evaluated, and the simple skip option matches nicely with the serde skip option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant