Skip to content

feat(block-kit): add composition object examples - #70

Merged
zimeg merged 11 commits into
mainfrom
composition-object-examples
Sep 1, 2026
Merged

feat(block-kit): add composition object examples#70
zimeg merged 11 commits into
mainfrom
composition-object-examples

Conversation

@zimeg

@zimeg zimeg commented Aug 28, 2026

Copy link
Copy Markdown
Member

Adds composition object examples to the block-kit showcase, the third Block Kit category after blocks and block elements. Mirrors the block element examples: one exampleNN() per documented reference payload, each returning the full host block or view so the reference JSON round-trips verbatim, with tests asserting the complete serialized payload via GsonFactory.createSnakeCase().

What's on display

Composition object Payloads Implementation
Text 1 (section host) compositions/Text.java
Option 2 (bare option, static select host) compositions/Option.java
Option group 1 (static select host) compositions/OptionGroup.java
Confirmation dialog 1 (button host) compositions/ConfirmationDialog.java
Dispatch action configuration 1 (plain-text input host) compositions/DispatchActionConfiguration.java
Conversation filter 1 (modal view host) compositions/ConversationFilter.java
Slack file 2 (image block by url, by id) compositions/SlackFile.java
Trigger 1 (workflow button host) compositions/Trigger.java
Workflow 1 (workflow button host) compositions/Workflow.java

Every reference payload documented on each page becomes one exampleNN(), and each test asserts the full hosted payload exactly as the docs page shows it. Input-block examples additionally assert the SDK's default-emitted fields (for example optional: false), matching the existing blocks/InputTest convention in this repo.

Deferred

  • Slack icon — this object is a sub-object of the card block, and the card block is not implemented in the Slack Java SDK's com.slack.api.model.block package. Its docs page ships no standalone JSON example, so there is no reference payload to reproduce. Deferred until the card block lands in the SDK.

Testing

Ran the CI gate locally from block-kit/ exactly as .github/workflows/test.yml defines:

  • mvn --batch-mode spotless:check — passes
  • mvn --batch-mode test -Dspotless.apply.skip — passes (39 tests, 0 failures)

Add composition object examples to the block-kit showcase, mirroring the
block element examples: one exampleNN() per documented reference payload,
each returning the full host block/view so the reference JSON round-trips
verbatim, with tests asserting the complete serialized payload.

Ships 9 of the 10 documented composition objects (text, option,
option-group, confirmation-dialog, dispatch-action-configuration,
conversation-filter, slack-file, trigger, workflow). The slack-icon object
is deferred: it is a card-block sub-object and the card block is absent from
the SDK, so no example payload can be produced.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg zimeg self-assigned this Aug 28, 2026
zimeg and others added 2 commits September 1, 2026 00:06
Renames the composition-object example directory from composition_objects/
(compositionobjects/ in Java) to compositions/, matching the shorter path.
Directory + all references (test imports, README impl links, Java package
declarations) updated together via git mv so history is preserved.

Canonical docs.slack.dev/reference/block-kit/composition-objects/ URLs are
left untouched (hyphenated, never the underscore token) — only local
relative implementation-link paths changed.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…amples

These examples are surfaced in docs.slack.dev as focused snippets — only the
exampleNN() body is shown, so the static imports at the top of the file are
invisible to the reader and a bare plainText(...)/markdownText(...) reads as
an unattributed free function.

Drop the static imports and qualify every call (BlockCompositions.plainText,
BlockCompositions.markdownText) so each helper in the surfaced range names
its class, consistent with the sibling Blocks.*/BlockElements.* calls.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
zimeg and others added 7 commits September 1, 2026 03:14
…sition index

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…rose

Match "a section block containing a text object" from the text-object reference page.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…aining' phrasing

Drop 'hosting'/divergent wording; unify all langs on 'An image block containing a Slack file object referenced by url/id.'

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
…image example

Duplicate the canonical 'An image block using slack_file with a url/id.' phrasing rather than diverging — the composition example demonstrates the same payload as blocks/image, so the wording matches by design.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Match "a static select menu containing the option group object" from the option-group-object reference page; drop 'hosted'/divergent per-lang wording.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Use "A static select menu element with several option objects." (from the option-object reference page); drop 'hosted'/divergent per-lang wording.

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>

@zimeg zimeg left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

☕ Notes on test expectations but implementations are reading solid!

"text": "Choose the conversation to publish your result to:",
"emoji": true
},
"optional": false

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

📣 note: This is an extra... "optional"... argument added from the SDK serialization but shouldn't impact the API values!

"type": "section",
"text": {
"type": "mrkdwn",
"text": "*<fakeLink.toYourApp.com|Use Case Catalogue>*\\nUse Case Catalogue for the following departments/roles..."

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🦠 note: The escaped \n is expected for these multiline string values IIUC.

@zimeg zimeg added enhancement New feature or request java Pull requests that update java code labels Sep 1, 2026
@zimeg
zimeg marked this pull request as ready for review September 1, 2026 23:46
@zimeg
zimeg requested a review from a team as a code owner September 1, 2026 23:46
@zimeg

zimeg commented Sep 1, 2026

Copy link
Copy Markdown
Member Author

⚡ Let's merge this while matching reference and slack-samples/bolt-js-examples#216 and slack-samples/bolt-python-examples#228!

@zimeg
zimeg merged commit 276240c into main Sep 1, 2026
4 checks passed
@zimeg
zimeg deleted the composition-object-examples branch September 1, 2026 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request java Pull requests that update java code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant