Skip to content
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

Nullable attribute missing for collection type reference. #2028

Open
chrisspre opened this issue Mar 19, 2021 · 4 comments
Open

Nullable attribute missing for collection type reference. #2028

chrisspre opened this issue Mar 19, 2021 · 4 comments
Assignees

Comments

@chrisspre
Copy link
Contributor

chrisspre commented Mar 19, 2021

In section 7.2.1 Nullable the standard states that

In OData 4.01 responses a collection-valued property MUST specify a value for the Nullable attribute.

If no value is specified for a collection-valued property, the client cannot assume any default value. Clients SHOULD be prepared for this situation even in OData 4.01 responses.

but the EDM library leaves out the Nullable attribute, in all cases.

Assemblies affected

Microsoft.OData.Edm -Version 7.8.3

Reproduce steps

The C# code

      @type.AddProperty(new EdmStructuralProperty(@type, "f",
          new EdmCollectionTypeReference(new EdmCollectionType(
             new EdmDecimalTypeReference(@decimal, true)))));

produces CSDL of the form

<Property Name="f" Type="Collection(Edm.Decimal)" />

that is missing the explicit Nullable attribute as stated in the standard

Expected result

<Property Name="f" Type="Collection(Edm.Decimal)" Nullable="true"/>

Actual result

<Property Name="f" Type="Collection(Edm.Decimal)" />
@habbes
Copy link
Contributor

habbes commented Mar 23, 2021

@chrisspre I think you mixed up the "expected" and "actual" results in the issue description?

@chrisspre
Copy link
Contributor Author

@chrisspre I think you mixed up the "expected" and "actual" results in the issue description?

Yes, sorry. fixed it.

@xuzhg
Copy link
Member

xuzhg commented Mar 23, 2021

If the type is collection and nullable of element is true, we should write the nullable="true".

See the code at: https://github.com/OData/odata.net/blob/master/src/Microsoft.OData.Edm/Csdl/Serialization/EdmModelCsdlSchemaWriter.cs#L108

@chrisspre
Copy link
Contributor Author

will be addressed in #2034

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants