Repository navigation
Description
Describe the bug
ManagedObjectApiDescription.build reads the type of a relationship property as a single string. A relationship attribute marked as "Nullable" has the type array ["relationship", "null"]: SchemaUtils.setNullableProperties in the Admin UI saves it that way, and SchemaField accepts it as a nullable relationship. build then throws JsonValueException: /type: Expecting a java.lang.String, logs Failed to generate API Description for managed.json section: <name> and returns null. The whole managed object endpoint is then missing from the API description, with the same symptom as #266.
There are two such reads on master (d3d5567):
ManagedObjectApiDescription.java:120, for a singleton relationship:SchemaField.TYPE_RELATIONSHIP.equals(relationshipSchema.get(Constants.TYPE).asString());ManagedObjectApiDescription.java:127, for the items of a relationship collection ("items": {"type": ["relationship", "null"]}):SchemaField.TYPE_RELATIONSHIP.equals(itemsType.asString()).
This is the OpenIDM part of #266. The commons part, where OpenApiTransformer failed on a type array such as ["string", "null"], is fixed in OpenIdentityPlatform/commons#382. The relationship case fails before the transformer runs, so that fix does not reach it.
The missing description also turns off relationship checks. ReverseRelationshipValidator.getReverseReferenceType asks the managed object for its API description. If there is none, it logs "Exception caught determining reverse reference type. This means duplicate assignment and cardinality checks cannot be performed" and returns NA. The singleton and duplicate-assignment checks are then skipped for every relationship whose reverse property belongs to that managed object.
To reproduce
- In
conf/managed.json, change thetypeof themanagerproperty ofuserfrom"relationship"to["relationship", "null"]. - The log shows
Failed to generate API Description for managed.json section: user, andmanaged/useris missing from the API Explorer (/openidm/?_api).
This was traced by reading the code on master and has not been run on an instance.
Expected behavior
- A type array that lists
"relationship"next to"null"is treated like"relationship"."relationship"is replaced with"object","null"is kept, andisRelationship: trueis added. The schema then reads["object", "null"], which the transformer from commons#382 describes asobjectwithx-nullable: true. ReverseRelationshipValidator.ReverseReferenceType.parseReverseReferenceTypealso reads the type of the reverse property withasString()(:64,:66). It has to accept["object", "null"]as well. Otherwise, a reverse property that is a Nullable singleton relationship still givesNA.
Activity
[OpenIdentityPlatform#267] [OpenIdentityPlatform#269] [OpenIdentityPl…
[OpenIdentityPlatform#267] [OpenIdentityPlatform#269] [OpenIdentityPl…
[#267] [#269] [#270] Read the type arrays of Nullable relationship pr…