Skip to content

[BUG] i18n tag labels are corrupted by camelCase word-splitting in the OpenAPI compiler #180

Description

@lucasvaccaro

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Relates to a fix done in @cap-js/ord plugin: cap-js/ord#532

Processing of OpenAPI tags disregards the idea of i18n placeholders.

When an entity has a camelCase i18n @label/@title, the OpenAPI compiler's normaliseTag() splits it into words before localization occurs. This corrupts the i18n key, causing the localization step to fail — the key no longer exists in .properties and the raw broken key is emitted as-is.

e.g.

  1. Entity annotated with title as '{i18n>entity.TasksPlural}'
  2. OpenAPI processes it and transforms it into {i18n>entity.Tasks Plural}
  3. Localization is applied (e.g. see chore: Introduce localization for resource definitions ord#532)
  4. Text is not replaced correctly

Expected Behavior

The resolved translation value should appear (e.g. Tasks).

Steps To Reproduce

  1. Annotate a CDS entity with a camelCase i18n label:

    annotate MyService.Tasks @label: '{i18n>entity.TasksPlural}';
  2. Add the key to i18n_en.properties:

    entity.TasksPlural=Tasks
    
  3. Compile to OpenAPI (e.g. cds compile --to openapi)

  4. Observe the generated tag name is entity.Tasks Plural

Environment

| Package                 | Version | Location                                                   |
 | ----------------------- | ------- | ---------------------------------------------------------- |
 | @sap/cds-dk             | 9.9.1   | ./node_modules/@sap/cds-dk                                 |
 | @sap/cds                | 9.9.1   | ./node_modules/@sap/cds                                    |
 | @sap/cds                | 9.9.1   | ./node_modules/@sap/cds-dk/node_modules/@sap/cds           |
 | @sap/cds-compiler       | 6.6.2   | ./node_modules/@sap/cds-compiler                           |
 | @sap/cds-compiler       | 6.9.1   | ./node_modules/@sap/cds-dk/node_modules/@sap/cds-compiler  |
 | @sap/cds-fiori          | 2.1.1   | ./node_modules/@sap/cds-fiori                              |
 | @sap/cds-fiori          | 2.3.0   | ./node_modules/@sap/cds-dk/node_modules/@sap/cds-fiori     |
 | @sap/cds-mtxs           | 3.9.7   | ./node_modules/@sap/cds-mtxs                               |
 | @sap/cds-mtxs           | 3.9.0   | ./node_modules/@sap/cds-dk/node_modules/@sap/cds-mtxs      |
 | @cap-js/asyncapi        | 1.1.0   | ./node_modules/@cap-js/asyncapi                            |
 | @cap-js/asyncapi        | 1.0.3   | ./node_modules/@sap/cds-dk/node_modules/@cap-js/asyncapi   |
 | @cap-js/attachments     | 3.6.1   | ./node_modules/@cap-js/attachments                         |
 | @cap-js/cds-test        | 1.0.1   | ./node_modules/@cap-js/cds-test                            |
 | @cap-js/cds-types       | 0.15.0  | ./node_modules/@cap-js/cds-types                           |
 | @cap-js/change-tracking | 1.1.4   | ./node_modules/@cap-js/change-tracking                     |
 | @cap-js/db-service      | 2.8.1   | ./node_modules/@cap-js/db-service                          |
 | @cap-js/db-service      | 2.11.0  | ./node_modules/@sap/cds-dk/node_modules/@cap-js/db-service |
 | @cap-js/hana            | 2.5.1   | ./node_modules/@cap-js/hana                                |
 | @cap-js/openapi         | 1.6.0   | ./node_modules/@cap-js/openapi                             |
 | @cap-js/openapi         | 1.4.0   | ./node_modules/@sap/cds-dk/node_modules/@cap-js/openapi    |
 | @cap-js/ord             | 1.9.2   | ./node_modules/@cap-js/ord                                 |
 | @cap-js/sqlite          | 2.1.2   | ./node_modules/@cap-js/sqlite                              |
 | @cap-js/sqlite          | 2.4.0   | ./node_modules/@sap/cds-dk/node_modules/@cap-js/sqlite     |
 | @cap-js/telemetry       | 2.0.1   | ./node_modules/@cap-js/telemetry                           |
 | cds.home                |         | ./node_modules/@sap/cds                                    |
 | npm root -l             |         | ./node_modules                                             |
 | npm root -g             |         | ~/.nvm/versions/node/v22.23.1/lib/node_modules             |
 | Node.js                 | 22.23.1 | ~/.nvm/versions/node/v22.23.1/bin/node                     |

Repository Containing a Minimal Reproducible Example

Internal.

Anything else?

No response

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions