MappingMongoJsonSchemaCreator
does not resolve embedded documents subclasses/interfaces implementations attributes
#3870
Labels
type: enhancement
A general enhancement
Milestone
I am trying to setup automatic Client-Side Field Level Encryption via a generated Json Schema using the new
@Encrypted
annotation.Doc. reference : https://docs.spring.io/spring-data/mongodb/docs/3.3.x/reference/html/#mongo.jsonSchema
Example 90. Client-Side Field Level Encryption via Json Schema
I stumbled into a severe limitation that impacts the schema generation through MappingMongoJsonSchemaCreator : embedded documents using subclasses or interfaces implementations have their attributes partially ignored.
Here's a test that highlights the issue :
The resulting schema contains definitions for attributes attr1, embeddedDoc.a and embeddedDocInterface.interfaceAttr only.
I'd expect the schema to contain all a, childBAttr and childCAttr properties defined for 'embeddedDoc', and interfaceAttr + interfaceAttrB for the 'embeddedDocInterface'.
The issue originates here as it will only consider the base class or interface to resolve attributes :
MappingMongoJsonSchemaCreator#computePropertiesForEntity
(L129)Here's a potential solution I'm using in the meantime with a custom version of the class, getSubClasses() being any implementation for extracting the subclasses of a given class or interface :
The text was updated successfully, but these errors were encountered: