Skip to content

fix: support of oneOf - #98

Merged
dotkas merged 2 commits into
developfrom
dotkas/add-oneof-fixes
Aug 11, 2026
Merged

fix: support of oneOf#98
dotkas merged 2 commits into
developfrom
dotkas/add-oneof-fixes

Conversation

@dotkas

@dotkas dotkas commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Copilot AI lite review requested due to automatic review settings August 11, 2026 12:27
@dotkas dotkas changed the title fix: support of oneOf fix: support of oneOf Aug 11, 2026

Copilot AI 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.

Pull request overview

This PR improves oneOf/anyOf support by making generated union enums more readable and safer: inline scalar members now get type-based variant names (e.g., String), x-rust-name can name inline union members, and unions that would contain the same lowered Rust type more than once are rejected with a targeted diagnostic.

Changes:

  • Add union-variant naming rules (including x-rust-name on inline union members and scalar type-based variant names).
  • Reject #[serde(untagged)] unions that contain the same lowered Rust type multiple times, with improved console hints.
  • Extend docs and fixture-based coverage tests for the above behaviors.

Reviewed changes

Copilot reviewed 9 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
docs/extensions.md Documents x-rust-name behavior for inline union members and union variant naming rules.
docs/design.md Adds design rationale around unions and updates x-rust-name guidance.
crates/oapi-codegen/tests/generated/recursive_schema.rs Updates expected generated code for scalar union variant naming.
crates/oapi-codegen/tests/generated/oneof_variant_naming.rs Adds a generated-code snapshot covering the new naming behavior.
crates/oapi-codegen/tests/generated.rs Registers the new generated snapshot module.
crates/oapi-codegen/tests/fixtures/unsupported_duplicate_union_variant.yaml Adds a fixture demonstrating duplicate lowered-type union rejection.
crates/oapi-codegen/tests/fixtures/oneof_variant_naming.yaml Adds a fixture exercising scalar/object/ref/custom union member naming.
crates/oapi-codegen/tests/coverage.rs Adds coverage entries and enables the new fixture-based test.
crates/oapi-codegen/src/lower/schema.rs Implements variant naming tweaks and duplicate-lowered-type detection for unions.
crates/oapi-codegen/src/ir.rs Adds RustType::label() for clearer diagnostics.
crates/oapi-codegen/src/console.rs Adds a dedicated hint for the new “duplicate union type” unsupported-schema diagnostic.
Suppressed comments (1)

crates/oapi-codegen/src/lower/schema.rs:858

  • The doc comment for extension_str is duplicated; it looks like the new example line was added without removing/updating the old one.
/// Extract a string-valued extension (for example `x-rust-type`) from schema data.
/// Extract a string-valued extension (for example `x-rust-name`) from schema data.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/oapi-codegen/src/lower/schema.rs Outdated
Comment thread docs/extensions.md Outdated
Comment thread docs/design.md Outdated
Copilot AI review requested due to automatic review settings August 11, 2026 12:46

Copilot AI 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.

Pull request overview

Copilot reviewed 10 out of 12 changed files in this pull request and generated no new comments.

@dotkas
dotkas merged commit f1c87fb into develop Aug 11, 2026
8 checks passed
@dotkas
dotkas deleted the dotkas/add-oneof-fixes branch August 11, 2026 12:50
@alchemax-housekeeper

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.0.0-dev.34 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@alchemax-housekeeper

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.0.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants