Skip to content

Fix embedded ID relation response schemas - #3334

Open
hej090224 wants to merge 2 commits into
springdoc:mainfrom
hej090224:issue-3136-embedded-id-schema
Open

Fix embedded ID relation response schemas#3334
hej090224 wants to merge 2 commits into
springdoc:mainfrom
hej090224:issue-3136-embedded-id-schema

Conversation

@hej090224

@hej090224 hej090224 commented Aug 25, 2026

Copy link
Copy Markdown

Summary

  • Convert nested response references for non-exported Spring Data REST associations to response schemas.
  • Preserve embedded ID scalar properties while preventing association objects from being expanded in read response schemas.
  • Add a minimal @EmbeddedId/@MapsId regression fixture and compare the complete generated OpenAPI 3.1 document with a golden file.

Root cause

SpringDocDataRestUtils rewrote top-level and _embedded entity response references, but did not rewrite associations to entities that were not themselves exported as repositories. Those properties retained the raw ModelConverters schema, which expanded the @EmbeddedId and @MapsId association fields recursively.

Compatibility

The change is limited to non-exported Spring Data REST association properties in generated response schemas. Existing exported relation handling, request schemas, and relation-free embeddables remain unchanged.

Testing

  • mvn -pl springdoc-openapi-tests/springdoc-openapi-data-rest-tests -am -Dtest=SpringDocApp40Test '-Dsurefire.failIfNoSpecifiedTests=false' test
  • mvn -pl springdoc-openapi-tests/springdoc-openapi-data-rest-tests -Dtest=SpringDocApp40Test '-Dsurefire.failIfNoSpecifiedTests=false' test
  • mvn -pl springdoc-openapi-tests/springdoc-openapi-data-rest-tests test (79 tests pass)
  • mvn install (the reactor reached springdoc-openapi-javadoc-tests, where existing Javadoc golden-output tests fail because descriptions, summaries, and tags are missing; the targeted app40 test and data REST module pass)

Fixes #3136

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.

Incorrect schema/example with @EmbeddedId + relations (Spring Data REST)

2 participants