Skip to content

[Java] Model discovery issues in Entity class #1801

@ramsessanchez

Description

@ramsessanchez

Currently we are unable to publish java V1 and beta SDKs due to compilation errors relating to the namespace and sub-namespaces in which some of the models are generated into.
The Entity class, found in com/microsoft/graph/models/Entity.java references nearly every generated model in the function createFromDiscriminatorValue(). Upon compiling we were running into an issue as the package namespace of the Entity class was described as Microsoft.Graph.models where it should have been com.Mircosoft.Graph.models in order to accurately reflect the structure of our java project. This issue is addressed in this PR.
Upon addressing this issue a second issue became apparent. There are sub namespaces in the Models package, ex: com.microsoft.graph.models.security, which also store other generated models. These models are also referenced in the aforementioned Entity class. The issue here is that we are not able to discover these models without explicitly importing the sub namespaces in which these models are held, i.e.. 'import com.microsoft.graph.models.security.*'.
Furthermore, there is a class which is referenced in the Entity class, Identity.java, which has two definitions. The first definition is defined in com/microsoft/graph/models/Identity and the second in com/microsoft/graph/models/externalConnectors/Identity. The issue here is that naturally it will reference the first definition since it lives in the same namespace as the Entity class referring to it, however that class is not of the correct return type thus causing a return type error. These issues can be seen here.
The fixes that would lead to solving these issues can be seen here. I have taken the liberty to merge these changes into the feature/6.0 branch of the Java v1 and beta Sdk repositories although I am aware they will eventually be replaced by next weeks generation, however we have been tasked with releasing a preview of these Libraries thus the necessity to make these changes while we figure out a solution. I believe that we can either add these import statements or we can explicitly refer to every model by it's fully qualified name in order to prevent ambiguity and referencing issues at compile time. I believe the second would be a more complete solution, please let me know your thoughts. Thanks!

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions