-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nullability information for properties that are collections of complex or entity types is inconsistent #467
Comments
In the case of user.appRoleAssignments, the property cannot be nullable = true, and should always be defined because according to the spec.:
|
How does this specification apply here? I was commenting the OpenAPI result, and this spec applies to the CSDL input. |
Aren't we translating the structural properties to OpenAPI based on their attribute values as defined in the CSDL schema? And according to OData rules, a collection nav. prop cannot be nullable, however it can be an empty collection. And also, it cannot have the attribute, |
If we take an example : Group.memberOf (collection navigation property) In a POST scenario, clients might not perform a deep insert, or default the property to an empty array. And the service doesn't need the property to be able to create a group. Which means the payload would again not validate the current schema.
This is a little like asking whether literal or semantic translation is the better one for human languages. Yes this library is in the translation business, but to me having a result that makes sense is more important than being able to map "words" one to one between the source and the result. |
We seem to be conflating a few things. The nullable in the example below is unrelated to the nullability of the collection.
The schema above says the following JSON is valid: {
"identities": [
{... objectIdentity... },
null,
{... objectIdentity... }
]
} I'm not sure why we would ever want to allow that, but it isn't related to a collection property being null. The schema above does not say the following is valid. {
"identities": null
}
Having effectively This presents two interesting questions:
I guess the OData serializer is going to make the first happen automatically. My concern about Kiota is that I don't want the deserialization process to be creating many empty collection objects. It is unnecessary allocations. |
Between the OData spec quote from Irvine and your clarification I'd say no:
I'd say no for the reason you've outlined. Because properties are not required by default, I think that resolves a lot of my initial concern. (sorry about the confusion, thanks for clarifying) Maybe the only case that might need fixing is the following identities:
type: array
items:
anyOf:
- $ref: '#/components/schemas/microsoft.graph.objectIdentity'
- type: object
nullable: true as I'm not sure why would anyone include null in an array? |
For the above schema in question to make sense I believe we should use identities:
type: array
items:
oneOf:
- $ref: '#/components/schemas/microsoft.graph.objectIdentity'
- type: object
nullable: true Otherwise, how else can we validate that the array can be empty? |
This [] Would already validate that identities:
type: array
items:
- $ref: '#/components/schemas/microsoft.graph.objectIdentity' The only thing the one/any Of with nullable true allows the example above wouldn't allow is this [null] But I'm not sure that makes any sense, hence my suggestion to remove the union type all together here. Which I think is also what Darrel was suggestion earlier. |
I have had a side chat with @darrelmiller just for more clarity. We are in agreement about removing the |
properties that are collections of complex or entity types seem to have inconsistent nullability information.
e.g.
user.identities is
but should be this since nullable true is the default value when not added as an attribute in the CSDL
user.assignedLicences is
but should be
user.appRoleAssignments is
should be
The text was updated successfully, but these errors were encountered: