Skip to content

Expose displayId in API v3 work package endpoints#22710

Merged
akabiru merged 3 commits intodevfrom
feature/73735-expose-project-based-semantic-work-package-identifier-on-the-api
Apr 14, 2026
Merged

Expose displayId in API v3 work package endpoints#22710
akabiru merged 3 commits intodevfrom
feature/73735-expose-project-based-semantic-work-package-identifier-on-the-api

Conversation

@akabiru
Copy link
Copy Markdown
Member

@akabiru akabiru commented Apr 9, 2026

Ticket

https://community.openproject.org/work_packages/73735

What are you trying to accomplish?

Expose a displayId field on API v3 work package endpoints that is always present and returns the appropriate user-facing identifier: the semantic identifier (e.g. "PROJ-42") when semantic mode is active, or the numeric ID as a string (e.g. "123") in classic mode. This replaces the earlier conditional semanticId field so that API consumers (frontend, mobile) never need conditional logic — they just read displayId.

Also adds a display_id model method on WorkPackage that encapsulates the mode check, and updates both the Ruby and SQL representers to render the new field unconditionally.

What approach did you choose and why?

The earlier semanticId was only rendered when semantic mode was active, forcing every consumer to handle both cases. By renaming to displayId and making it always-present, downstream code can treat it as the single source of truth for the user-facing identifier. The SQL representer switches between identifier and id::text at the SQL level so there's no Ruby overhead for collection endpoints.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

@akabiru akabiru added this to the 17.4.x milestone Apr 9, 2026
@akabiru akabiru self-assigned this Apr 9, 2026
@akabiru akabiru added the feature label Apr 9, 2026
@akabiru akabiru force-pushed the feature/73735-expose-project-based-semantic-work-package-identifier-on-the-api branch from 56acdca to 4f5db49 Compare April 9, 2026 16:26
@akabiru akabiru changed the title Expose semanticId in API v3 work package endpoints Expose displayId in API v3 work package endpoints Apr 10, 2026
@akabiru akabiru force-pushed the feature/73735-expose-project-based-semantic-work-package-identifier-on-the-api branch 2 times, most recently from 2839dc2 to 47c4b8a Compare April 10, 2026 15:47
@akabiru akabiru changed the base branch from poc/71645-convert-to-wp-semantic-ids to dev April 10, 2026 15:48
akabiru added 2 commits April 13, 2026 14:04
Adds the computed semanticId property to the HAL representer,
SQL collection representer, and schema representer. The property is
gated behind the semantic_work_package_ids feature flag and returns the
value from WorkPackage#identifier. Includes OpenAPI docs
and the translation key for the schema name.
Replace the conditional `semanticId` API field with `displayId` which is
always present in work package responses. In semantic mode it returns the
project-based identifier (e.g. "PROJ-42"), in classic mode it returns the
numeric ID as a string. This gives API consumers (frontend, mobile) a
single field to read without conditional logic.

- Add `WorkPackage#display_id` method that encapsulates the mode check
- Update both representers (JSON and SQL) to render `displayId` unconditionally
- Update OpenAPI schema documentation
@akabiru akabiru force-pushed the feature/73735-expose-project-based-semantic-work-package-identifier-on-the-api branch from 47c4b8a to 5bbc4e7 Compare April 13, 2026 11:04
@akabiru akabiru marked this pull request as ready for review April 14, 2026 08:44
@akabiru akabiru requested a review from a team April 14, 2026 08:44
Copy link
Copy Markdown
Contributor

@judithroth judithroth left a comment

Choose a reason for hiding this comment

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

LGTM. Nice work!
I have one suggestion on improving the description, but that should not be a big thing.

@akabiru akabiru merged commit 54423b8 into dev Apr 14, 2026
21 checks passed
@akabiru akabiru deleted the feature/73735-expose-project-based-semantic-work-package-identifier-on-the-api branch April 14, 2026 14:17
@github-actions github-actions bot locked and limited conversation to collaborators Apr 14, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Development

Successfully merging this pull request may close these issues.

2 participants