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

Support Omit-values prefer header #672

Open
xuzhg opened this issue Aug 24, 2022 · 1 comment
Open

Support Omit-values prefer header #672

xuzhg opened this issue Aug 24, 2022 · 1 comment
Labels

Comments

@xuzhg
Copy link
Member

xuzhg commented Aug 24, 2022

Assemblies affected
Which assemblies and versions are known to be affected e.g. ASP.NET Core OData 8.x

Describe the bug
OData specs has the following at: http://docs.oasis-open.org/odata/odata/v4.01/cs01/part1-protocol/odata-v4.01-cs01-part1-protocol.html#_Toc505771137

 8.2.8.6 [Preference omit-values](http://docs.oasis-open.org/odata/odata/v4.01/cs01/part1-protocol/odata-v4.01-cs01-part1-protocol.html#sec_Preferenceomitvalues)
The omit-values preference specifies values that MAY be omitted from a response payload. Valid values are nulls or defaults.

If nulls is specified, then the service MAY omit properties containing null values from the response, in which case it MUST specify the Preference-Applied response header with omit-values=nulls.

If defaults is specified, then the service MAY omit properties containing default values from the response, including nulls for properties that have no other defined default value. Nulls MUST be included for properties that have a non-null default value defined. If the service omits default values it MUST specify the Preference-Applied response header with omit-values=defaults.

Properties with null or default values MUST be included in delta payloads, if modified.

The response to a POST operation MUST include any properties not set to their default value, and the response to a PUT/PATCH operation MUST include any properties whose values were changed as part of the operation.

The omit-values preference does not affect a request payload. 

To omit null value properties is a common requirement from our customers. We provide the extensions that developers can override to achieve this goal. But, it's the server-side extension. The client can't control it.

Omit-values prefer header is used for client. We should consider to support this header at server side.

Additional context
We should figure out the way that client can distinguish the "omit-values" from "$select".

For example:

~/customers?$select=Name,Age
Prefer: omit-values=nulls

So when the client receives the response payload, it should have the way to understand "the missing properties" is from $select limitation or from omit-values=nulls.

Maybe the context url can help to distinguish.

@xuzhg xuzhg added the feature label Aug 24, 2022
@xuzhg
Copy link
Member Author

xuzhg commented Aug 24, 2022

See the proposal PR at: #657

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

No branches or pull requests

1 participant