Skip to content

add support for custom keyTo property in belongsTo relation generator…#11648

Open
Abubakar-K-Back wants to merge 1 commit into
loopbackio:masterfrom
Abubakar-K-Back:fix/belongs-to-keyto-support
Open

add support for custom keyTo property in belongsTo relation generator…#11648
Abubakar-K-Back wants to merge 1 commit into
loopbackio:masterfrom
Abubakar-K-Back:fix/belongs-to-keyto-support

Conversation

@Abubakar-K-Back

Copy link
Copy Markdown

Description section:
Fixes #11647

When generating a belongsTo relation with a custom keyTo field, the CLI generator was silently ignoring the keyTo option it was not included in the generated @belongsTo decorator, and the FK type was always resolved from the destination model's primary key type instead of the actual keyTo field type.

Changes:

  • Pass keyTo to getBelongsTo() and include it in the decorator arguments
  • Resolve fktype from the actual keyTo field type using getModelPropertyType()
  • Pass keyTo into artifactInfo in generateControllers() for controller template access
  • Update controller EJS template to reflect the resolved keyTo field in the OpenAPI description

… and controller template

Signed-off-by: Abubakar Awan <abkawan6@gmail.com>
@Abubakar-K-Back Abubakar-K-Back force-pushed the fix/belongs-to-keyto-support branch from e0f623e to 5fc5eea Compare July 6, 2026 15:31
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.

CLI generator ignores keyTo option when creating belongsTo relations

2 participants