Skip to content

Conversation

@rpanackal
Copy link
Member

@rpanackal rpanackal commented Dec 5, 2025

Context

NamingUtils currently makes unintentional changes to the mappings in serviceNameMappings.properties
If the file name is API MATERIAL DOCUMENT SRV.edmx

First run:

  • Input: "API_MATERIAL_DOCUMENT_SRV" (from .edmx filename)
  • After transformations: "APIMaterialDocumentSrv"
  • .replace("Api", ""): No match (looking for "Api", found "API")
  • Resulting className: "APIMATERIALDOCUMENTSRV"
  • Resulting packageName: "APIMATERIALDOCUMENTSRV".toLowerCase() = "apimaterialdocumentsrv"

Second run (re-processing stored value):

  • Input: APIMATERIALDOCUMENTSRV for className and "apimaterialdocumentsrv" for packageName (from mapping)
  • For packageName:
    • After transformations: "Apimaterialdocumentsrv"
    • .replace("Api", ""): MATCHES! Removes "Api"
    • Resulting packageName: "materialdocumentsrv"
  • For className, the same flow as first run -> no change

Even though the className stays consistent across runs, the result is semantically flawed since prefix "Api" is not removed.

Feature scope:

  • Stay consistent across runs
  • Remove "Api" case insensitively on both packageName and className
  • Fix other prefixes as well which has the same issue

Definition of Done

  • Functionality scope stated & covered
  • Tests cover the scope above
  • Error handling created / updated & covered by the tests above
  • Documentation updated
  • Release notes updated

.replaceAll("^(?i)ODataServiceFor", "")
.replaceAll("^(?i)RemoteApiFor", "")
.replaceAll("^(?i)ApiFor", "")
.replaceAll("^(?i)Api", "")
Copy link
Contributor

@newtork newtork Dec 5, 2025

Choose a reason for hiding this comment

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

(Major)

Wouldn't this match edge-cases like "SapInvoice"?
I would probably rather go with something like "A(pi|PI)" or straight up two lines.

Edit: I realize you changed the replacement from "anywhere in the string" to "only in the beginning". Therefore potentially bringing a breaking change for existing users that rely on "Api" being removed from their service name(?).

Which would be fine if we had a major release or sth.

Copy link
Member Author

@rpanackal rpanackal Dec 5, 2025

Choose a reason for hiding this comment

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

Yes, It is breaking change.

My rational was, to be consistent across regeneration, we have three options

  1. Always remove "Api"
    • breaking to users relying on Api
  2. Always keep "Api"
    • breaking to users who have been regenerating with .edmx file updates.
  3. Don't apply any transformations to mappings that are read from serviceNameMappings.properties
    • I didn't feel confident about removing this additional transformation as it might be a safety measure (?). But, it would be non-breaking.

What do you think about Option 3?

Copy link
Member Author

Choose a reason for hiding this comment

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

I didnt get your comment the first time. I have updated the regex.

Copy link
Member Author

Choose a reason for hiding this comment

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

It still is not edge-case free. Eg: "Apiary" would be matched. But this is unavoidable

@rpanackal rpanackal changed the title fix: [OData] Name mapping bug in NamingUtils fix: [OData] Name mapping bug in NamingUtils Dec 5, 2025
@rpanackal rpanackal merged commit 67b3eb3 into main Dec 10, 2025
14 checks passed
@rpanackal rpanackal deleted the fix/odata/service-name-maping branch December 10, 2025 13:33
@rpanackal rpanackal self-assigned this Dec 11, 2025
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.

4 participants