Skip to content

fix: export-jdl now preserves field-level annotations (@Id, custom op…#32655

Merged
mshima merged 2 commits intojhipster:mainfrom
model-driven-development:fix/export-jdl-field-annotations
Mar 11, 2026
Merged

fix: export-jdl now preserves field-level annotations (@Id, custom op…#32655
mshima merged 2 commits intojhipster:mainfrom
model-driven-development:fix/export-jdl-field-annotations

Conversation

@trifonnt
Copy link
Contributor

The JSON-to-JDL entity converter was not passing field.options to the JDLField constructor, causing all field-level annotations to be silently dropped during JDL export.

Summary

  • Field-level annotations (like @Id, custom @AnnotationName(value)) were silently dropped during export-jdl because field.options was not passed to the JDLField constructor in json-to-jdl-entity-converter.ts
  • Added options: field.options to the constructor call (1-line fix)
  • Added test coverage with @Id and @CustomAnnotation("customValue") field options

Test plan

  • Run npx esmocha generators/export-jdl --no-insight — all 5 tests pass
  • Snapshots updated to verify @Id and @CustomAnnotation("customValue") appear in exported JDL
  • Manual test: run jhipster export-jdl on a project with field annotations and verify they appear in the output

Please make sure the below checklist is followed for Pull Requests.

When you are still working on the PR, consider converting it to Draft (below reviewers) and adding skip-ci label, you can still see CI build result at your branch.

Closes #32435

…tions)

The JSON-to-JDL entity converter was not passing field.options to the JDLField constructor, causing all field-level annotations to be silently dropped during JDL export.
Copilot AI review requested due to automatic review settings March 11, 2026 14:36
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes export-jdl dropping field-level annotations by ensuring .jhipster field options are carried into JDLField, so annotations like @Id and custom @AnnotationName("value") are preserved in generated JDL (addresses #32435).

Changes:

  • Pass field.options into the JDLField constructor during JSON→JDL conversion.
  • Extend export-jdl test fixtures to include field options for @Id and a custom annotation.
  • Update snapshots to assert the exported JDL contains @Id and @CustomAnnotation("customValue").

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
lib/jdl/converters/json-to-jdl-entity-converter.ts Preserves field-level annotations by forwarding field.options into JDLField.
generators/export-jdl/export-jdl.spec.ts Adds test inputs that include options to validate annotation export behavior.
generators/export-jdl/snapshots/export-jdl.spec.ts.snap Updates expected exported JDL output to include the new annotations.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

DanielFran
DanielFran previously approved these changes Mar 11, 2026
@mshima mshima merged commit 4e0dc16 into jhipster:main Mar 11, 2026
60 checks passed
@mshima
Copy link
Member

mshima commented Mar 11, 2026

I’ve forgot to check relationships.

@trifonnt trifonnt deleted the fix/export-jdl-field-annotations branch March 11, 2026 20:49
@trifonnt
Copy link
Contributor Author

I’ve forgot to check relationships.

@mshima Good catch!
I have checked how custom annotations for relationships behave and I found one issue.
#32662 is fixing it.

Should I open new issue?

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.

[JDL] Fields annotations are not been correctly exported.

4 participants