Skip to content

Idea for Introducing "oneOf" - #798

Draft
schneidermic0 wants to merge 9 commits into
mainfrom
feature-one-of
Draft

Idea for Introducing "oneOf"#798
schneidermic0 wants to merge 9 commits into
mainfrom
feature-one-of

Conversation

@schneidermic0

@schneidermic0 schneidermic0 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

DISCLAIMER This is just an idea. I share it to get some feedback here.

Introduce oneOf (Union Types) Documentation for ABAP File Formats

New Features

✨ Added documentation for a new oneOf union type feature in ABAP file formats, enabling developers to model mutually exclusive alternatives in JSON files using ABAP Doc annotations.

Changes

  • docs/json.md: Added a new section "Union Types (oneOf)" covering:
    • New ABAP Doc annotations: $oneOfGroup, $oneOfDiscriminatorFor, and $oneOfValue with supported syntax variants (plain names and {@link ...} references)
    • How discriminator values are resolved (explicit $enumValue or camel-case transformation)
    • Recommended usage guidelines to avoid duplication and ensure consistency with enum definitions
    • A minimal ABAP code example demonstrating a two-branch payload_variant group
    • Description of the generated JSON Schema output using const constraints and required fields per branch
    • Deserialization behavior clarifying that oneOf is enforced at the JSON Schema validation layer, not at the ABAP transformation layer
    • A note that changes to oneOf constraints are typically incompatible and require bumping formatVersion
    • Added the new section to the Table of Contents
  • 🔄 Regenerate and Update Summary
PR Bot Information

Version: 1.26.0

  • Event Trigger: issue_comment.edited
  • Correlation ID: c09bcdb9-b7dd-4972-97c4-20d8feb9fd13

@hyperspace-pr-bot hyperspace-pr-bot 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.

(deleted)

schneidermic0 and others added 2 commits June 19, 2026 18:29
Co-authored-by: hyperspace-insights[bot] <209611008+hyperspace-insights[bot]@users.noreply.github.com>

@hyperspace-pr-bot hyperspace-pr-bot 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.

(deleted)

@hyperspace-pr-bot hyperspace-pr-bot 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.

(deleted)

@hyperspace-pr-bot hyperspace-pr-bot 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.

(deleted)

@hyperspace-pr-bot

hyperspace-pr-bot Bot commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Control Panel

Hi, I'm an AI-powered Review Bot that helps you with summarizing and reviewing pull requests.
To interact with me, just use the following actions:

  • 📝 Summarize PR
  • 🔍 Review
  • 🗑️ Delete all bot comments and reviews

@hyperspace-pr-bot hyperspace-pr-bot 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.

The example code in the new section is missing shorttext title annotations on struct types and fields, which contradicts the documentation standards enforced throughout the rest of this file. Please address the flagged annotation gaps before merging.

PR Bot Information

Version: 1.26.0

Comment thread docs/json.md
Comment thread docs/json.md
Comment thread docs/json.md

@hyperspace-pr-bot hyperspace-pr-bot 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.

The new "Union Types (oneOf)" section introduces a useful and well-structured feature, but has several concrete issues: the ABAP example and the generated JSON Schema are inconsistent (a default value appears in the JSON with no corresponding $default annotation in ABAP), the Table of Contents is not updated, and the JSON output silently omits the formatVersion/header fields that are explicitly $required in the ABAP source. Please address these before merging.

PR Bot Information

Version: 1.26.0

Comment thread docs/json.md Outdated
Comment thread docs/json.md
Comment thread docs/json.md
Comment thread docs/json.md
@schneidermic0 schneidermic0 self-assigned this Jun 22, 2026

@wurzka wurzka 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.

I like the approach 👍
We have so many object types with components that are only required dependent on some boolean or enum value.
Having a better validation option in the schema is an improvement.

@marcushoepfner

Copy link
Copy Markdown
Contributor

"not": { "required": ["referencePayload"] } could be added to the first branch,
while "not": { "required": ["inlinePayload"] } can be added to the second branch.

Otherwise it is not mutual exclusive and referencePayload and inlinePayload can co-exist in the same object.

Apart from that, looks really good, also with the const to always have exact match to a oneOf-branch.
Otherwise it might be hard to find the correct branch when not all properties are filled yet; the branch might not be uniquely identifiable.

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.

3 participants