Skip to content

[rust-server] Validate model-valued wrapper fields - #25262

Open
EricLiu2000 wants to merge 1 commit into
OpenAPITools:masterfrom
EricLiu2000:codex/recursive-model-validation
Open

EricLiu2000 wants to merge 1 commit into
OpenAPITools:masterfrom
EricLiu2000:codex/recursive-model-validation

Conversation

@EricLiu2000

@EricLiu2000 EricLiu2000 commented Oct 15, 2026 •

Copy link
Copy Markdown

Fixes #25261.

Generated model-valued wrappers derive Validate without marking their inner field for nested validation. A root validation call can therefore miss invalid children. Add nested validation to array, map, and reference wrappers, and keep it on object fields that also have bounds.

Model-only union wrappers delegate to the wrapped type's existing Validate implementation. Primitive and mixed union wrappers keep their current behavior. Wrapped types remain responsible for their own validation.

Array values use min_items and max_items instead of string-length annotations. Nullable array fields keep their existing bound annotations for compatibility with the released runtime. This change does not add nullable collection-size support or change dependency versions.

Validation for 23b7f992:

  • CLI build and all 56 Rust generator Java tests pass with ./mvnw -q -pl modules/openapi-generator-cli -am package -Dtest='org.openapitools.codegen.rust.*Test' -Dsurefire.failIfNoSpecifiedTests=false -Dmaven.javadoc.skip=true.
  • All eight Rust server samples regenerated with ./bin/generate-samples.sh bin/configs/rust-server*.yaml.
  • All seven committed Rust tests pass against the generated dependency declarations, using crates.io Swagger 7.0.1 and serde_valid 2.0.4. They check wrapper recursion, collection bounds, bounded fields, nullable-array compatibility, and model/primitive union compilation. recursive-validation.rs includes the steps to run them; Maven checks generated source but does not execute these Rust tests.
  • The generated fixture passes cargo check --no-default-features --features client,server,validate --lib.
  • The full suite for other generator languages was not run locally.

@EricLiu2000
EricLiu2000 force-pushed the codex/recursive-model-validation branch from cfd2856 to 14190f0 Compare October 15, 2026 04:26
@EricLiu2000
EricLiu2000 marked this pull request as ready for review October 15, 2026 04:26

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 8 files

Reply to a comment to ask cubic a question or push back. It learns from your replies.

View guided diff | Re-trigger cubic

@EricLiu2000
EricLiu2000 force-pushed the codex/recursive-model-validation branch from 14190f0 to 3e3cecb Compare October 15, 2026 04:47

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

@EricLiu2000
EricLiu2000 force-pushed the codex/recursive-model-validation branch from 3e3cecb to bbde794 Compare October 15, 2026 05:45

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 6 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

@EricLiu2000
EricLiu2000 force-pushed the codex/recursive-model-validation branch from bbde794 to 85c4016 Compare October 15, 2026 06:13
@EricLiu2000 EricLiu2000 changed the title [rust-server] Validate nested models through generated wrappers [rust-server] Validate model-valued wrapper fields Oct 15, 2026
@EricLiu2000
EricLiu2000 marked this pull request as draft October 15, 2026 06:16
@EricLiu2000
EricLiu2000 marked this pull request as ready for review October 15, 2026 06:20

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 7 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Signed-off-by: Eric Liu <ericxliu@gmail.com>
@EricLiu2000
EricLiu2000 force-pushed the codex/recursive-model-validation branch from 85c4016 to 23b7f99 Compare October 15, 2026 06:47
@wing328

wing328 commented Oct 27, 2026

Copy link
Copy Markdown
Member

thanks for the PR

cc @frol (2017/07) @farcaller (2017/08) @richardwhiuk (2019/07) @paladinzh (2020/05) @jacob-pro (2022/10) @dsteeley (2025/07)

This branch has not been deployed

No deployments
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.

[BUG][rust-server] serde_valid validation stops at generated model wrappers

2 participants